[erlang-questions] Erlang Cost Model

zxq9 zxq9@REDACTED
Thu Sep 17 06:17:24 CEST 2015

On Wednesday 16 September 2015 19:25:41 Eric des Courtis wrote:
> As a first step lets focus on the complexity of the operations (ignoring
> any associated constants or specific time measurements). Just so newcomers
> to Erlang can validate their assumptions.
> I will start:
> Adding to the beginning of a list is O(1)
> Adding to the end of a list is O(n)
> Sending a large binary to another node is O(n)
> Sending a large binary to other processes on the same node is O(1)
> etc...

That is going to wind up reading very similarly to the cost model for any language that uses similar data structures and executes in a managed environment.

And its not very useful.

Here is why: "Just so newcomers to Erlang can validate their assumptions."

Their assumptions are going to be totally invalid (which is different from being wrong) because using concurrent processes as a basic component of a model of computation is *a different model of computation* than these cost models assume. So whatever these "newcomer assumptions" are will not make sense in real programs, unless newcomers only write sequential Erlang programs.

This is like trying to tune a violin by drum tempo or tune a drum to output from a spectroscope. Sure, each involves a "frequency", but the underlying concept is so different in each case they simply don't compare.

The only place cost models make sense is:
1- Dealing with a technically ignorant bureaucracy that doesn't understand why this makes no sense, but have the power to can your project if you can't justify it to some Soviet standard
2- Trying to squeeze the last bit of performance out of a bottleneck you can't imagine a way around

Case 1 is in error, as Erlang will fail in most competitions that measure sequential speed. Meh.

Case 2 is generally in error as well, as the goal should usually be to avoid having bottlenecks to begin with, not making bottlenecks more performant. (There are standard answers for that one time when you really, genuinely need to make a pig fly.)

The mapping of operations to cost in terms of scheduler reductions is the closest thing to a meaningful number I think there is. (If this is wrong someone please correct me or expand on this -- I am sort of curious, though only morbidly so. But don't go on and on about how l33t dirty schedulers and NIFs are.)

In actual programs I've written (and am writing) that handle actual problems for actual users I've had to think about this exactly one time, ever, and that turned out to be a big fat waste of time once I stepped back and took a second look from above.

What is the purpose of such a cost model? What is its use? Why is this needed?

The concept is so different that I think this is probably a sort of X-Y problem. If, instead of asking for a cost model, the intended utility of the cost model were explained perhaps more useful things would start popping up on the ML.


More information about the erlang-questions mailing list