[erlang-questions] Erlang Cost Model

Joe Armstrong erlang@REDACTED
Wed Sep 16 22:56:37 CEST 2015


On Wed, Sep 16, 2015 at 10:27 PM, Pierre Fenoll <pierrefenoll@REDACTED> wrote:
> On a side note I would be happy if we had a way to add a documentation clause that advertises the complexity of the documented function.

And I would be *even happier* if the *specifications* had information like
"this function must take no more than XXXX ms." - this I have
virtually *never* seen. (I've even asked the people who wrote the
specs. and they
usually haven't a clue, and I don't view "as quickly as possible" as a
good answer).

With the absence of a "target" value in the specification it is pretty
meaningless to measure *anything*.

Mostly specification say very little about non-functional behaviour. They
specify functional behaviour but not non-functional behaviour (how
long, how much memory, ...) - most systems I've worked with failed
because the
non-functional behaviour was terrible (they crashed).

I've seen huge projects that were functionally perfect - the functions
computed the correct values - but oops - the system crashed after a
while.

All I can say is  "beware measuring the wrong thing"

/Joe


>
> Maybe the complexity can even be computed automatically.

Maybe the moon is made of blue cheese.

>
> And combining cost of atomic actions could give an idea of the cost of these complexities constants.

If computing was a science this might be so, right now it's a craft.

Programs don't obey basic algebraic properties. If A takes time Ta and B Tb
how long will A+B take? Ta + Tb ???? It would be nice if this were
true but it's not.

Good 'ol  Turing's halting problem illustrated the fact that no algorithm
can decide if another program will halt or not, let alone figure out
how long it would take ...

/Joe



>
>> On 16 Sep 2015, at 13:09, Joe Armstrong <erlang@REDACTED> wrote:
>>
>>> On Wed, Sep 16, 2015 at 9:03 PM, Theepan <vasdeveloper@REDACTED> wrote:
>>> I have never heard of such a cost model for Erlang’s basic operations, but
>>> most of the time I profiled the code to find out the cost of a code-segment,
>>> using tools and functions provided by Erlang/OTP. The Erlang documents list
>>> do-s and don’t-s, and from the engineering school I know good programing
>>> practices. And most of the time I use common sense of how to write a good
>>> piece of code. This is my story, and wrote it to give my one cent on the
>>> crowd sourcing part.
>>>
>>>
>>>
>>> At an Erlang process level operations can be timed, as they directly map to
>>> the operations at the underlying OS. And then you will have to add some
>>> extra cost for the process management by the OTP. This extra cost is a
>>> function of many variables like number of cores, configuration of
>>> schedulers, yielding frequency, length of process queue, GC and so on.
>>
>> Right - the problem is not measuring how long the primitives take
>> it is making sense of the measurements.
>>
>> Even arithmetic is problematic - how long does an integer multiply take?
>> - answer "it depends" - Erlang has bignums not fixnums.
>> The python cost model gives a time for multiplying integers, but for
>> bignums the time will depend upon the size of the  bignums and this
>> depends upon the algorithm. Just looking at code, you can't see how
>> large the integers are.
>>
>> From what I've seen extrapolation from "programs in the small" (ie
>> answering question like - "how long does an integer multiply take") to
>> "programs in the large" (ie millions of processes collaborating to
>> provide a service) is very hard.
>>
>> Cheers
>>
>> /Joe
>>
>>
>>
>> There
>>> is no straightforward way, but through a deeper analysis they can be
>>> determined.
>>>
>>>
>>>
>>> Theepan
>>>
>>>
>>> On Wed, Sep 16, 2015 at 8:33 PM, Eric des Courtis
>>> <eric.des.courtis@REDACTED> wrote:
>>>>
>>>> What is the cost model of all operations in Erlang 18?
>>>>
>>>> For example Python has this cost model
>>>> http://scripts.mit.edu/~6.006/fall07/wiki/index.php?title=Python_Cost_Model
>>>> .
>>>>
>>>> I either want a link to a single source for this information or I would
>>>> like to crowd source the information here now.
>>>>
>>>> Thanks for your cooperation.
>>>>
>>>> Eric des Courtis
>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> erlang-questions@REDACTED
>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list