frptools / collectable

High-performance immutable data structures for modern JavaScript and TypeScript applications. Functional interfaces, deep/composite operations API, mixed mutability API, TypeScript definitions, ES2015 module exports.
MIT License
273 stars 14 forks source link

feature request: Implement CHAMP for increased performance. #63

Open NodeGuy opened 6 years ago

NodeGuy commented 6 years ago

CHAMP (Compressed Hash-Array Mapped Prefix-tree) is an incremental improvement over HAMT that simplifies the code, decreases the memory footprint, and increases performance.

Leveling up Clojure’s Hash Maps is an easily accessible introduction to it by the guy who replaced Clojure(Script)'s HAMT implementation with it.

The original paper: Optimizing Hash-Array Mapped Tries for Fast and Lean Immutable JVM Collections

The reference implementation in Java: The Capsule Hash Trie Collections Library

The Clojure implementation in Java and ClojureScript implementations look more easily grokkable to me.

axefrog commented 6 years ago

Thanks for the link David, I'll definitely file that away for future upgrades!

wishfoundry commented 6 years ago

just as an FYI, I've attempted a similar effort in porting CHAMP to JS over here

I'm still spinning out variants and comparing benchmarks, but in general these tend to have faster writes with slightly slower reads available HAMT libs in JS today. Unlike what the article claims, there's no magic 5x faster though I'm afraid, maybe 50% faster writes, and 5% slower reads

NodeGuy commented 6 years ago

Huh. That's disappointing. Thanks for sharing your experience.