5 ms·
JEP 450: Compact Object Headers
- akokanka 4y ago5% latency overhead is huuuge. Throw more memory and focus on throughout. Not sure why memory is a concern here.
- exabrial 4y agoIs this part of the JVM Specification, or is this an implementation detail of OpenJDK itself? If the first, thats sort of surprising. Seems like an implementation detail that'd be best left up to the platform on how to manage objects in memory.
- papercrane 4y agoThis is an implementation detail of the HotSpot JIT compiler in OpenJDK. Other implementations are free to layout their objects as they choose.
- Kwpolska 4y agoThis document is a proposal for the HotSpot JVM, which is the default JVM implementation (the one that ships with OpenJDK), but not the only JVM implementation out there (see https://en.wikipedia.org/wiki/List_of_Java_virtual_machines https://en.wikipedia.org/wiki/List_of_Java_virtual_machines for a full list).
- pdpi 4y agoThe JEP identifies the scope as "implementation" and the component as "hotspot/runtime", so I do assume it's an implementation detail, yes.
- mike_hearn 4y agoNo spec changes needed for this one.
- titzer 4y agoIdentity hashcodes and monitors are perennially tricky to implement with low space overhead and I think in hindsight that putting them at the base of the object model (i.e. every object has them) was a mistake. WebAssembly GC objects do not have identity hash codes nor monitors to strive for the lowest space overhead in the base object model.
- Someone 4y ago> Identity hashcodes and monitors are perennially tricky to implement with low space overhead and I think in hindsight that putting them at the base of the object model (i.e. every object has them) was a mistake. I can understand the hashcode choice, but I never understood why they chose to add the ability to lock on any object. IMO it still is a bad choice now on server machines, and it certainly was in a language designed for embedded devices in the early 1990s. Does anybody know what they were thinking? Were they afraid of having to support parallel class hierarchies with a LockableFoo alongside Foo for every class? If so, why? Or did they think most programs would have very few objects, and mostly use reference types?
- paulddraper 4y ago> Does anybody know what they were thinking? Ergonomics. (Plus an inherent assumption of mutable data.) You can write `synchronized (this)` or `synchronized` class method, etc. and it just works.
- derefr 4y agoIf I were the Java1.0 authors, I probably would have: - made a "monitor slot" its own primitive type; - made two overloads of `synchronized` — synchronized(MonitorSlot), and synchronized(Object); where for synchronized(Object), the compiler expects to find a MonitorSlot-typed field with a special system name (e.g. "__jvmMonitorSlot") on the passed-in Object - taken the presence of `synchronized (this)` in body code of a class to implicitly define such a field on the class, meaning you can "just write" `synchronized (this)`, since it becomes `synchronized (this.__jvmMonitorSlot)` and also triggers the creation of the __jvmMonitorSlot field - explicitly define the __jvmMonitorSlot field on Class and other low-object-count system types The only change from today would be that you can't point at some arbitrary Object you didn't define the class for yourself, and say "synchronize on that." Which... why do you want to be doing that again?
- kernal 4y agoSummary Reduce the size of object headers in the HotSpot JVM from between 96 and 128 bits down to 64 bits on 64-bit architectures. This will reduce heap size, improve deployment density, and increase data locality.
- marginalia_nu 4y agoJava made a bunch of optimistic assumptions about the future of hardware when it was designed. UTF-16 strings, 64 bit pointers, enormous object headers. While great for future-proofing, it's been hard to deny it's had overhead. Glad to see it's slowly getting undone: Compressed Oops, Compact Strings, now this.
- iainmerrick 4y ago64-bit pointers isn't really an optimistic assumption, it's just the normal pointer size on 64-bit systems.
- Bjartr 4y agoIt was optimistic because Java came out long before 64 bit systems were common.
- formerly_proven 4y agoCommon in desktops, yes, but Sun being a UNIX workstation vendor they switched in the 90s.
- oefrha 4y agoWell, the 3 billion devices (r) Java ran on certainly weren’t Sun workstations.
- iainmerrick 4y agoOptimistic to represent object references with native pointers? C and C++ usually do that too.
- prpl 4y agoUltraSPARC says hello
- zactato 4y agoThe DEC Alpha was a 64 bit CPU architecture that came out in 1992. Java support it from Java 1.0 to ~ Java 3 Interestingly, I can't find any information on Google about this, but ChatGPT does support this. Unfortunately all the primary sources it gave me are for docs that no longer exist on the web. The Wayback machine was no help. The old web is dead :(
- maherbeg 4y agoJava has just been on a roll with such substantial changes to fundamental pieces of the runtime! Great work to the teams that keep making improvements in backwards compatible manners.
- capableweb 4y agoThis specific change seems to impact the JVM the runtime, not Java the language. Which is great for people like me, who heavily rely on JVM but couldn't care less about Java.
- pulse7 4y agoPeople may not care about your "carelessness about Java"...
- capableweb 4y agoI'm fairly sure that's fine, people get to care about whatever they want :)
- Scarbutt 4y agoFunny, those languages rely heavily on the Java ecosystem and libraries, and they better hope the Java ecosystem keeps thriving, improving current libraries and producing new libraries else they become impractical. Show me your pure Clojure production grade http servers or database drivers ;)
- koito17 4y ago>Show me your pure Clojure production grade database drivers Depends what you mean by "database driver", but what disqualifies XTDB or Datomic, both of which have use outside of Clojure yet are implemented entirely in Clojure with the exception of the Java wrappers so you can use them naturally within Java or Kotlin? Even then, talking about "pure Clojure" is a non-starter because Clojure is not a self-hosted language (yes, Java is self-hosted if you consider Jikes RVM, a JVM implementation in pure Java). Even if Java ecosystem were to dwindle, people can rely on the JavaScript, .NET, or Dart ecosystems thanks to ClojureScript, ClojureCLR, and ClojureDart existing. I use ClojureScript daily and am not really affected by what happens in Java land. With that said, I always welcome improvements to the JVM, because I actually like the Java ecosystem; it's the only one that doesn't make me split hairs...despite the dreaded module system.
- davnicwil 4y agoAs I (think I) understand the goal of this is to reduce memory footprint of the HotSpot JVM, with the tradeoff of performance degradation being capped to 5%, only in the worst rarest cases.
- aaa_aaa 4y agoJust guessing that Cache throughput increase with the memory reduction may offset most performance issues.
- w10-1 4y agoI'm always impressed with the clarity of Java's design/implementation discussions, which I think is due to Mark Reinhold's leadership since 1997 (a breathtaking tenure in its own right). But this needs to replace stack locking with an alternate lightweight locking scheme, to avoid races. Unfortunately, that is opaque: https://bugs.openjdk.org/browse/JDK-8291555 Does anyone have other pointers for the design or viability of the required alternative?
- zorgmonkey 4y agoTheir is a detailed description of the new stack locking scheme in the PR here https://github.com/openjdk/jdk/pull/10907 https://github.com/openjdk/jdk/pull/10907
- juancn 4y agoI always wanted to have a tag in the object header that signals the GC to "just don't touch this object", so I could manually allocate off-heap objects and arrays (specially arrays). ByteBuffers are low overhead, but native arrays are ~30% faster last I benchmarked, so if I can place an array off-heap, and never move it (granted, it's unsafe), I can use for example, the kernel's paging mechanism to swap data in and out data from disk, with low runtime overhead to access it.