node --prof examples/benchmark.js node-tick-processor | less
I tried profiling before but in this case I ran it on my Arch laptop and the [C++] was suddenly present. Oh what an idiot I am. So, tl;dw:
- now setting "running" only if coastline.trace is on
- now updating "coastline.active" array only if coastline.trace is on
- array shifting actually looks quite optimized so I brought it back in processQueue, at least the garbage will be collected faster
c.each 102987 ops/sec, 971ms c.loop 77280 ops/sec, 1294ms recursive 252525 ops/sec, 396ms recursive2 226244 ops/sec, 442ms all in 227790 ops/sec, 439ms
Even better for 10k test:
c.each 156250 ops/sec, 64ms c.loop 65789 ops/sec, 152ms recursive 384615 ops/sec, 26ms recursive2 344828 ops/sec, 29ms all in 454545 ops/sec, 22ms
Still not that good, but at this point it looks like most of the time is spent on allocation and garbage-collection. It would be great if I could reuse context objects somehow, but it doesn't seem to be possible with how coastline works right now. The profile also shows that while most of the time the functions are optimized, sometimes they aren't. Unfortunately there is little useful info in --trace-opt or --trace-deopt.
One day I'll just rewrite the bloody thing in C++.