4 ms·
Thanks—this looks pretty exciting! I've been using Mori, but this appears to have a more JS-ish API. Can you give some other comparisons to Mori (i.e. feature s
by dahjelle 12y ago
Thanks—this looks pretty exciting! I've been using Mori, but this appears to have a more JS-ish API. Can you give some other comparisons to Mori (i.e. feature set, performance, etc.)?
- leebyron 12y agoThe feature set is comparable sans yet to come SortedSet and SortedMap (aka Red Black Tree). Performance should also be comparable if not slightly faster than mori in some iteration cases, as it's tuned for JS instead of ClojureScript and I've forgone some of the functional purity for speed. But this is anecdotal and I don't have any perf tests yet.
- moomin 12y agoI think you might be surprised exactly what running code through an optimising compiler achieves.
- taeric 12y agoI'm curious at what you are hinting at here. Especially when you are discussing the data structure, I've not seen too much magic that an optimizing compiler can really achieve. That is, the compilers are usually more geared to help speed up the code, not so much the data. Any good links showing otherwise?
- swannodette 12y agoFirst off it's very exciting and cool to see a company like Facebook release an open source persistent data structure library for JavaScript. Mori just has more stuff and the benefit of 3 years of development and production use. This becomes quite apparent on the metrics you asked about: - mori is a 32K gzipped browser dependency, tons of helpers functions - immutable-js is a 10K gzipped browser dependency (with Uglify and aggressive mangling), mostly just data structures ClojureScript (and thus Mori) has been continuously tuned for 3 different major JS engines - JavaScriptCore, V8, and SpiderMonkey. Running some basic benchmarks overall Mori comes out ahead on most operations. But there's nothing surprising here, immutable-js is brand spanking new :). Also there are micro-optimizations (which add up) in ClojureScript that are impossible to expose to JS users w/o a compiler. In anycase this is great stuff and I'm excited to see how JavaScript and more specifically React devs leverage these to explore the ideas currently be played around with in ClojureScript/Om/Elm/etc.
- grayrest 12y agoI've run across a couple HAMT implementations you might not have seen: https://github.com/mattbierner/hamt/ https://github.com/mattbierner/hamt/ https://github.com/Tvaroh/moreartyjs https://github.com/Tvaroh/moreartyjs The first implementation (hamt) is interesting because it's in a same semantics compile-to-js language (by the author) called Khepri and it benchmarks pretty well on datastructure microbenchmarks. http://khepri-lang.com/ http://khepri-lang.com/ https://github.com/mattbierner/js-hashtrie-benchmark https://github.com/mattbierner/js-hashtrie-benchmark The second is a less interesting pure JS implementation that I show as faster than mori and slower than hamt on the hashtrie-benchmark. I've been meaning to test them on a wider variety of benchmarks (more aggregate operations and vs transients) but I only ran across them last week and I've been busy.
- swannodette 12y agoThanks for the links. Sadly doing mori benchmarks like this does't say as much about the performance of ClojureScript data structures than it does about mori specifically - in many cases you are likely just benchmarking multi-arity function dispatch overhead because you don't have the ClojureScript compiler doing direct dispatch for you. If you want accurate benchmarking of ClojureScript data structures you will need to write the benchmark in ClojureScript for the time being and call them from JavaScript. Also benchmarking in Node.js doesn't reflect the wide variance you find in JS engines. In several cases in the past we avoided V8 specific optimizations because it punished other JS engines. UPDATE: I also ran some benchmarks and I can't replicate the perf degradation as the size of the hash map increases. My suspicion is that the random key generation may result in many hash collisions w/ Murmur3 which would explain the dramatic perf degradation which is unlikely to occur in the wild.
- grayrest 12y agoI appreciate the response. I was wondering about the lower Mori numbers here because I was sure I'd seen much higher numbers in cljs benchmarks.
- mattbierner 12y ago