4 ms·
Just as an aside, sometimes slicing up your arrays-of-structs into structs-of-arrays brings big locality improvements. Anyway, you can usefully control some as
by twoodfin 12y ago
Just as an aside, sometimes slicing up your arrays-of-structs into structs-of-arrays brings big locality improvements.
Anyway, you can usefully control some aspects of how Java lays out your data, including primitive fields:
http://psy-lob-saw.blogspot.com/2013/05/know-thy-java-object-memory-layout.html http://psy-lob-saw.blogspot.com/2013/05/know-thy-java-object...
- TheLoneWolfling 12y agoAnd sometimes it brings big locality hits. Layout within objects is not what I'm talking about here. What I'm talking about is layout of objects within an array. There's no way to do an array of <whatever>. It's an array of <primitive> or an array of <pointer to whatever>. So much pointer-chasing! In (e.g.) C, I can do either array-of-structs or structs-of-arrays. In Java... I don't know any way to have an array-of-structs in Java (portably, that is).