How do you improve the performance of the software you write? Consolidating data into contiguous regions of address space is a generally useful approa

4K Aliasing | Richard Startin’s Blog

submited by
Style Pass
2021-06-16 08:00:06

How do you improve the performance of the software you write? Consolidating data into contiguous regions of address space is a generally useful approach because most programs are bottlenecked on memory access. The consolidation has a positive impact on performance because processors fetch data in cache lines, for two reasons.

The benefits are kind of obvious, but it takes some work to profit from this when using the JVM because of the layout of the heap. One way to think about Java objects laid out throughout the heap is to think of a sausage; amidst the innards and the breadcrumbs there is a bit of meat. Java objects have headers of implementation defined size, usually 12 or 16 bytes, and are aligned, by default, on 8 byte boundaries. This means if you have an array of objects which wrap a long:

Even assuming compressed references, you end up with the composition of a typical sausage: 12 bytes for the header, eight bytes for the word, four bytes of alignment shadow. That’s 33% meat.

Leave a Comment