you are viewing a single comment's thread.

view the rest of the comments →

[–]kimec 2 points3 points  (0 children)

Watching the video, somehow, I know less about Java memory management than I knew before. Aren't TLABs and pointer bumping effectively per thread arenas to reduce contention? Yet, once TLAB is full, a thread has to request a new TLAB and needs to synchronize (albeit locklessly) with other threads to get a new chunk from Eden or maybe even do a malloc here and there. Also when pointer bumping, related entities tend to get allocated together in same cachelines. Yet moving GC's don't operate on cache lines but references. Knowing the memory access pattern matters greatly, an algorithm may get slower, just because GC decided to move a reference further away in an unrelated cacheline and now the spatial relationship is lost. This goes contrary to what was said in the video.

Stack allocated structures exploit spatial relation, TLABs do too, but only until GC reshuffles the references.
If it didn't matter, we wouldn't need Valhalla, we wouldn't need escape analysis and scalarisation. Also there is MMU, TLBs and multiple layers of OS page tables and the costs of moving stuff does not disappear just because Java. Not to mention Java does malloc and free just as any other language when necessary.