News for hackers. Stuff that matters.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by jcdavis on Saturday August 05, 2017 @08:38PM (#14938956)
The author presented a talk about this at the JVM Language Summit last year: https://www.youtube.com/watch?v=pUXeNAeyY34&list=PLX8CzqL3Ar...

Github repo for those interested: https://github.com/usethesource/capsule/

Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by agumonkey on Sunday August 06, 2017 @05:36AM (#14940610)
Interesting talk in a way but god the amount of wasted neurons from java-like OOP.. all this to xi..xn,yi...yn instead of xi,yi...,xn,yn ..
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by VHRanger on Saturday August 05, 2017 @09:36PM (#14939191)
What is the real world use case for a HAMT data structure? Tree based associative arrays (like c++'s std::map) tend to have poor real world performance
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by chongli on Saturday August 05, 2017 @09:40PM (#14939200)
They are used to implement Clojure's immutable map and set structures. They are absolutely critical to the philosophy of the language.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by gshayban on Sunday August 06, 2017 @12:31AM (#14939672)
std::map and red-black trees are associative & sorted (by key); HAMTs are just plain associative. HAMTs have generally excellent performance: the typical implementations use 32-way branching, which allows for the top levels to be likely in cache.

The best thing about HAMTs is passing immutable ones around, which have free update costs and multi-thread safe. Clojure uses these to represent information that flows through a program. (By free update costs I mean: they are free enough to never rise to the programmer's attention. Obviously ops have costs.)

Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by masklinn on Sunday August 06, 2017 @04:30AM (#14940409)
More efficient (in both CPU and memory) immutable/persistent collections, which have the advantage that they're intrinsically thread-safe. They can also be used to implement lock-free concurrent maps (Ctrie)

> Tree based associative arrays (like c++'s std::map) tend to have poor real world performance

That's something HAMT significantly improve upon. You're not going to get linear performances out of them but basic operations are generally O(ln N) where N is usually 32.

Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by dmichulke on Sunday August 06, 2017 @08:34AM (#14941042)
I think it's for an array of size N:

- O(1) - standard array (regardless of N)

- O(log_b(N)) - HAMT (b is 32 in clojure)

Since b is big, log_b(N) is quite small even for big numbers, e.g. log_32(2^20) = 4

Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by mrkgnao on Sunday August 06, 2017 @05:02AM (#14940520)
Um, isn't that "constant-time in practice"? (Something like log-star.) Am I missing some matter of convention here?
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by wfunction on Sunday August 06, 2017 @04:33AM (#14940421)
Is there any research on the tradeoff between this kind of thread safety and the penalties incurred on the memory management side (specifically the fact that now you have far more heap allocations with immutable data and they have to synchronize too)?
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by joe-user on Monday August 07, 2017 @06:12AM (#14946418)
I don't know of any formal research, but in Clojure, where HAMTs are a fundamental part of the language, the philosophy is more oriented towards paying for things (such as thread safety) with memory and CPU first, benchmarking to find bottlenecks second, and if there are any bottlenecks, optimizing accordingly. It was written with this in mind, which is why it requires world-class VMs like the JVM, CLR, and V8/JSC/SpiderMonkey/etc. that can deal with the GC and (in many cases) make runtime optimizations.

Also, I'm fairly certain synchronizing isn't an issue because there's nothing to synchronize on since the data structures are immutable. Am I understanding you correctly?

Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by wfunction on Monday August 07, 2017 @06:17AM (#14946435)
> Also, I'm fairly certain synchronizing isn't an issue because there's nothing to synchronize on since the data structures are immutable. Am I understanding you correctly?

No -- I'm referring to synchronization on the heap itself (think new()/delete()). Multiple threads allocating memory need to synchronize in order to avoid trampling on each other. You can't just get rid of synchronization entirely.

Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by jcdavis on Saturday August 05, 2017 @10:19PM (#14939300)
Immutable maps that have efficient update semantics
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by FreakLegion on Saturday August 05, 2017 @10:17PM (#14939296)
Depending on the use case, of course. Sometimes you need a structure that's both associative and ordered, for example, in which case std::map is handy.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by masklinn on Sunday August 06, 2017 @04:34AM (#14940425)
HAMT are not intrinsically ordered or sorted.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by FreakLegion on Sunday August 06, 2017 @03:31PM (#14943011)
The comment obviously refers to std::map, which it mentions explicitly and which guarantees ordering.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by masklinn on Monday August 07, 2017 @03:35AM (#14945893)
But the entire discussion is about HAMT not std::map, the parent comment only talks about std::map as an example of performance issues in tree-based maps in asking how that relates to HAMT, it doesn't actually care a whit about std::map.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by zokier on Sunday August 06, 2017 @05:50AM (#14940646)
So would this be a good structure to store the recently discussed password hash dump, basically a fixed set of 300 million SHA1-sums where the only interesting operation is checking if the sum is or is not contained in the set?
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by lord_jim on Sunday August 06, 2017 @03:47PM (#14943078)
It would probably be better to use a trie directly, maybe a radix trie or a b-trie.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by didibus on Sunday August 06, 2017 @03:57AM (#14940294)
Does this add something that the Clojure implementation doesn't?
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by maxpert on Saturday August 05, 2017 @07:42PM (#14938688)
I wish the paper carried a GitHub link to the repo of reference implementation.
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by prospero on Saturday August 05, 2017 @11:14PM (#14939478)
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by tixzdk on Saturday August 05, 2017 @08:24PM (#14938900)
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by e12e on Saturday August 05, 2017 @08:30PM (#14938929)
Indeed, wasn't easy to track down:

https://github.com/msteindorfer/oopsla15-artifact

Still trying to find out if there's a video of the OOPSLA15 presentation.

Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by e12e on Saturday August 05, 2017 @08:46PM (#14939001)
Some commentary on a blog, that I encountered along the way: https://blog.acolyer.org/2015/11/27/hamt/
Re:Optimizing Hash-Array Mapped Tries for Fast Immutable JVM... by e12e on Saturday August 05, 2017 @09:45PM (#14939216)
Looks like the "production" version lives at:

https://github.com/usethesource/capsule