cujojs / most

Ultra-high performance reactive programming
MIT License
3.5k stars 231 forks source link

thanks! (questions about performance) #458

Closed DarkMarmot closed 7 years ago

DarkMarmot commented 7 years ago

Summary

After coming across most.js and seeing the performance benchmarks, I simple couldn't believe them. I ended up running them locally and verifying that the operations were actually taking place and was just floored. Utterly impressive!

I've been working on a fairly different streaming library (named composite/multicast streams, intentionally synchronous or batched, hot observables only, etc.).

I used your benchmark suite for the tests that I could replicate easily (filter-map-reduce, skip/take, etc.).

Your library helped me go from the level of Bacon/Kefir speed up to about 30-90% that of most.js' speed (after two solid refactors).

I still feel like there is something in the code or optimizations that I am missing, though.

I would love any links or suggestions or techniques that you could suggest for further research.

Thanks again for creating such a great library!

briancavalier commented 7 years ago

Hey @DarkMarmot, thank you for the kind words. I'm glad to hear most's code has proven to be helpful.

It's important to note up front that the perf tests are microbenchmarks that try to squeeze as much out of each library as possible. IOW, they represent best possible cases.

In general, the most important things are isolating try/catch (v8 TurboFan can optimize functions containing try/catch, but other engines cannot), and monomorphic objects and functions. Monomorphic objects are ones whose shape doesn't change after construction, and monomorphic functions are ones which are always called with the same parameter types (and shapes).

Constructing lots of closures at runtime is also usually a good way to kill performance by eating lots of memory. There are all sorts of other edge-case optimization killers, but in general, using simplicity as a guiding principle works out well.

Here are a couple other good links related to v8 optimization:

https://github.com/petkaantonov/bluebird/wiki/Optimization-killers http://mrale.ph/blog/

If you have specific questions about most.js internals, feel free to join us in gitter to discuss.

Closing, since this isn't an issue per se, but if you have other questions please do ask here or in gitter.

Hope that helps!