by reitzensteinm · 5y ago · 0 comments
Aeron comes to mind as an example in regards to high performance solutions that uses them. But a more fundamental reason is that immutability can be part of your domain logic. Think video games like braid, or business applications where you need to derive a lot of different views and go back and forth between them, or domains where data just is inherently immutable such as accounting and so on.
> Think video games like braid
Braid doesn't use immutable data structures, it uses a historical record (and immutability would be incompatible with some of the mechanics).[1] The author of Braid is actually quite famous for his dislike of functional languages and immutability. He doesn't even like garbage collection because of the overhead it introduces.
Interestingly, he was talking about data structures for codebase representation (in the context of a compiler) a while back, and someone mentioned HAMTs. I'm definitely curious if they would work well there.
Continuing with the example regardless, change records and persistent data structures have different performance characteristics. The former is going fast if you move incrementally between states, the latter enables arbitrary access, comparison and efficient in memory caching of multiple views.
It would be interesting to explore and measure the trade offs under certain use cases.
This leaves Clojure as 1/4 the overall speed, which seems about right. However that's based on a hugely unscientific gut feeling, because generally I don't touch Clojure if performance matters and I don't touch C# if it doesn't.
By the way, I've implemented persistent data structures on disk for a problem they were particularly useful for. If stalling for a cache miss feels bad, try waiting for an SSD :)
Hope some performance experts can chime in but this might be related to data structure sharing between caches or allocation contention in the JVM.
https://clojureverse.org/t/parallel-transducing-context-figh...
https://www.reddit.com/r/Clojure/comments/emylbs/any_idea_wh...
https://clojurians.zulipchat.com/#narrow/stream/151168-cloju...
https://github.com/joinr/paralleltest/issues/1
Anything in particular you're looking for?
If you have code you wrote to achieve something and hit a wall with scaling, I'm happy to take a look.