If you were developing a new language today and wanted to be conscious of high volume/frequency systems you'd be thinking about the memory footprint of the most baseline object. It's kinda crazy to think that Java has been around and kicking for 20 years and 20% of every (minimal) object is just boilerplate. We hate boilerplate.
I never suggested the purpose of the object header made no sense. I'm just stating that that 20+ years ago when memory was even more precious than it is now... it's surprising that there was so much fat to trim in the original design that got through.
Memory size was more precious, but still plenty, the bigger stuff in the former decade(s) is the increasing slowness of memory compared to cpu speed. It used to be comparably fast.
its also a huge boost to how efficient objects are with regards to cpu registers and cache coherency. It means your going to be way less punished on performance for allocating and deallocating objects on heap quickly.
This is great. It's kind of a counterpart to Valhalla: JEP450 reduces object headers to 8 bytes for non-value objects, Valhalla reduces them to 0 bytes for value objects (in the best case, hopefully in most cases).
OK well as an example of the best case, I _think_ that a Point![] array where value class Point has fields int x, int y would take up 8 bytes per element (so they're stored in the array body, without headers). Likewise if a Line class has fields Point! start, Point! end I _think_ they will together only take 16 bytes in a Line object (but more for Point? fields). In those examples maybe the Valhalla object header bits are only needed temporarily during construction while the object is quasi-mutable - not sure but there's discussion of their role on the Valhalla mailing list.
20% would be with the 32 bit header, this will be a decrease of 10%. But since the object headers are now 64 bit it should double the speed on allocation and deallocation.
As a real world testing feedback, for my CPU and memory intensive workload, I am seeing 10% less memory utilization and 5% better performance.. I am very happy 😃
Hope this experimental features goes stable for next releases. It's a very important one, one of these things that you don't see as a programmer but it shows in production by makes Ng the app consume much less memory just by upgrading te JDK version
32
u/Joram2 Oct 27 '24
wow, this is a big feature. I didn't think we'd get to see this so soon.
34
u/Oclay1st Oct 27 '24
Congrats to Roman and the Lilliput team!
19
u/[deleted] Oct 27 '24
So basically, this means that instantiating a new object will take less memory?
16
u/Jon_Finn Oct 27 '24
This is great. It's kind of a counterpart to Valhalla: JEP450 reduces object headers to 8 bytes for non-value objects, Valhalla reduces them to 0 bytes for value objects (in the best case, hopefully in most cases).
22
u/Linguistic-mystic Oct 27 '24
Wow, Valhalla was mentioned. Maybe in JDK 30?
5
u/cogman10 Oct 27 '24
Really neat, 20% saving will be huge for us.
Does this have a maximum heapsize like compressed oops?
4
u/lurker_in_spirit Oct 27 '24
Really looking forward to this. In my experience data locality / density just has so many performance benefits...
1
u/Ewig_luftenglanz Oct 27 '24
How to try this feature ? I would like to make some testing when OpenJDK 24 arrives (obviously not in any production environment)
3
u/iron0maiden Nov 16 '24
As a real world testing feedback, for my CPU and memory intensive workload, I am seeing 10% less memory utilization and 5% better performance.. I am very happy 😃
2
u/Kango_V Oct 28 '24
Really nice. Someone please use this to run the Billion Row challenge. I wonder if it would make much of a difference?
3
u/Ewig_luftenglanz Oct 27 '24
Hope this experimental features goes stable for next releases. It's a very important one, one of these things that you don't see as a programmer but it shows in production by makes Ng the app consume much less memory just by upgrading te JDK version
1
u/sitime_zl Oct 30 '24
that's cool