4 ms·
There should be a book about Java perf / hacks derived from this challenge. I'd buy it fore sure.
by seinecle 2y ago
There should be a book about Java perf / hacks derived from this challenge. I'd buy it fore sure.
- abhi9u 2y agoI think most of the optimizations were pretty low level and had nothing to do with Java itself. You could implement the same techniques in any other (compiled) language and get similar performance results. Things like cache locality, ILP, work stealing, multithreading, SWAR etc. In fact, the top solutions mostly used unsafe to use off-heap memory to avoid GC and copying of data.
- papercrane 2y agoIn this particular instance Unsafe was used to skip boundary checks. The main difference between the fastest safe version and the fastest unsafe version was how the file was read. The safe version used MappedByteBuffer to read the file, which under the hood memory maps the file and enforces boundaries. The unsafe version memory mapped the file and then read the memory directly using Unsafe. The fastest version also used Graal which would've helped with startup time.