Replies: 4 comments 1 reply
This comment was marked as off-topic.
This comment was marked as off-topic.
-
A caveat when considering to add JVM optimizations to .NET is that JVM and .NET are very different runtimes. JVM does not have structs, spans, pointers and byrefs, which forces applications to to create a lot more garbage, with fewer avenues to reduce them. That's why JVM has stuff that .NET hasn't yet, like escape analysis and fancy pauseless garbage collectors; it needs them more to band-aid its inherent design limitations. I'm not saying that we should not innovate and add these features, but their urgency and value they would bring is different than in JVM and we should independently evaluate them and the tradeoffs they would bring. And I can see quite the tradeoffs with compressing the object header; for one they would make virtual methods slower. |
Beta Was this translation helpful? Give feedback.
-
Also, it would make garbage collection to take longer and |
Beta Was this translation helpful? Give feedback.
-
As I understand it, on a 64-bit system, an object consists of:
What I've been wondering: is all the padding necessary? I get that the method table pointer has to be 8-byte aligned, but that could still be achieved without having the 4 bytes of padding at the start of every object, no? As an example, consider allocating two objects, each with a single
Couldn't it look like this instead, saving 4 bytes?
Though I can imagine that this would make heap compaction somewhat harder and potentially less efficient. Alternatively, maybe the object header could be moved to offset 8, which would mean that the 4 bytes of padding would be available for the object layout algorithm instead? |
Beta Was this translation helpful? Give feedback.
-
As far as I know, in .NET objects of classes have 12 byte header, similarly to JVM.
Now, the OpenJDK started a project Lilliput aiming to reduce the header size to 8 or 4 bytes.
Was maybe an analogous feature considered for .NET?
Beta Was this translation helpful? Give feedback.
All reactions