26 ms·
there is a major flaw in the erlang version which causes unnecessary list allocation and garbage collection multiplied by 1 million times. I would try to replac
by nivertech 11y ago
there is a major flaw in the erlang version which causes unnecessary list allocation and garbage collection multiplied by 1 million times. I would try to replace lists:seq(0,9) with a tail recursion.
Even that it's a small list of 10 integers, it is still created 1 million times.
https://github.com/atemerev/skynet/blob/master/erlang/skynet.erl#L10 https://github.com/atemerev/skynet/blob/master/erlang/skynet...
EDIT: it seems that list:seq overhead is insignificant - so it doesn't matter, maybe erlang compiler already optimizing it. I even inlined the calls to spawn - it still the same result.
But I found another problem: it seems that some processes are stuck - so if you run benchmark the 3rd time - yo get out of processes.
EDIT2:
Note, that unlike other solutions. Erlang has process isolation, i.e. if there is a panic in one of your goroutines - your entire server will crash, but if there is an exception in your erlang process - only that process will crash, not affecting other processes in your server (unless they linked with it).
- masklinn 11y ago> there is a major flaw in the erlang version which causes unnecessary list allocation and garbage collection multiplied by 1 million times. There's probably an alloc cost, but there should be no GC cost: erlang processes get a 233 words heap by default, a list of 10 integers is 21 words, so the process should die without needing to run GC.
- nivertech 11y agoyes, when process ends/dies all the heap is reclaimed without regular GC. I also tried spawn_opt/5 with reduced min_heap_size option - it doesn't help.
- masklinn 11y ago> I also tried spawn_opt/5 with reduced min_heap_size option - it doesn't help. Yeah whether using spawn_opt or VM options (-hms and -hpds) it doesn't look possible to reduce the process heap (or process dict) below the initial size, only to increase it.
- jlouis 11y agoJust tune the VM: https://github.com/atemerev/skynet/issues/33 https://github.com/atemerev/skynet/issues/33 and speed doubles :)