logoalt Hacker News

marginalia_nu • today at 10:35 AM • 2 replies • view on HN

(Author). So I've gotten pretty far in the index translation, at least as far as the postings lists go. Out of the box for a direct translation there really hasn't been much performance improvement going from Java to C++ in benchmarks.

The Java code was already stupidly optimized and basically allocation free in the hot paths apart from stuff that stays in TLAB or gets trivially elided. And while Java in general is unwieldy as hell for systems programming, it's often surprisingly competitive since the C2 JIT basically gives your system free PGO everywhere on real world data.

The performance impact I've seen has mostly been the design improvements I've found along the way . Paring the index down to now ~2000 lines of C++ has let me find several design refinements that improve buffer pool performance by using more lock free algorithms, improving the index layout to reduce unnecessary block fetches and allowing more accurate prefetching, etc.


Replies

xmcqdpt2 • today at 12:22 PM

That’s been my experience too.

At $work we’ve often gotten performance improvements from rewriting C++ code into Java. Every time it’s because rewriting code from Java to C++ requires deeply thinking about the code, which unlocks algorithmic improvements that could be ported back to the C++ version (usually we make those rewrites for other reasons than performance so we don’t actually do that.)

➕ show 1 reply
derinbay • today at 12:21 PM

[flagged]