5 ms·
I think this statement has been true since about 2014. Structs are nice, as they allow for control over locality, to a degree that is simply not possible in Ja
by geophile 5y ago
I think this statement has been true since about 2014.
Structs are nice, as they allow for control over locality, to a degree that is simply not possible in Java currently. But there is a second effect, which is possibly more important: If I can move gigabytes of my data into arrays of structs, then 1) I greatly reduce memory requirements (far fewer pointers), and 2) I greatly reduce the amount of work that GC has to do.
This is such an important thing to add to Java, and it seems to be perpetually off the stove, not even on the back burner.
- hyperpape 5y agoI haven't been following it incredibly closely, but I have checked in from time to time. It's a hard problem, but there's a lot of real progress (https://github.com/openjdk/valhalla-docs/blob/main/site/design-notes/state-of-valhalla/03-vm-model.md https://github.com/openjdk/valhalla-docs/blob/main/site/desi...). I'd wager that it will ship by the next LTS, in 2024.
- vips7L 5y ago2023 (hopefully)! They're proposing moving LTS to 2 years instead of 3.
- zokier 5y ago> This is such an important thing to add to Java, and it seems to be perpetually off the stove, not even on the back burner. Valhalla is being actively worked on, I'm not sure what you are implying here.
- pjmlp 5y agoBecause they don't want to do a Python move, and those compiled JARs from 2000 should keep working as much as possible on a Valhala aware JVM.
- vips7L 5y agoSome features take a long time when you have millions of users and billions of loc. Goetz recently did a State of Valhalla interview here: https://www.youtube.com/watch?v=x1_DBqJrykM https://www.youtube.com/watch?v=x1_DBqJrykM
- stickfigure 5y agoAlternatively: This is such a (potentially) big change, it's important to get right. I'd be disappointed if an inadequately-baked solution gets rushed in. Another way of looking at it: This is fundamentally just a performance optimization. Java performance is already exceptional for most of Java's popular use cases (business processing). While valuable, I don't think this one feature is quite as important as you consider it.
- deepsun 5y agoThat makes sense, given the fact that they made "new Foo()" pretty lightweight anyway (for CPU, not for RAM).
- nlitened 5y ago> If I can move gigabytes of my data into arrays of structs, then 1) I greatly reduce memory requirements (far fewer pointers), and 2) I greatly reduce the amount of work that GC has to do. As an aside, and not to say that Valhalla is not needed (I am looking forward to it very much, along with Loom), I’ve recently learned that for many use cases (not all) when you want gigabytes of struct arrays, a bunch of equal-sized primitive arrays, one per struct field, might work even better from memory requirement and cache locality perspective.
- samus 5y agoThe semantics of primitive types should make it possible for the JVM to apply this optimization automatically. Maybe controlled via an annotation. But no clue whether it's on the roadmap.
- native_samples 5y agoIt's mostly implemented in a branch. You can download a version of Java that can do this today. There's more work to do before it can be merged though, and will probably ship in incremental pieces.