[master] Withdrawn: Parallel: modify to-space object in array chunking

Stefan Karlsson stefank at openjdk.org
Tue Apr 23 11:48:47 UTC 2024


On Fri, 19 Apr 2024 13:59:21 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> The ParallelGC chunks arrays so that it can somewhat parallelize the array processing. This is done by rewriting the length field of the from-space object. This causes a problem for Lilliput when one thread copies an object, forwards it, and then rewrites the length of the from-space copy, while another thread tries to figure out if it should copy the object and tries to read the size of the object.
> 
> The second thread tries to stay away from calling `oopDesc::klass()` on the from-space object, because the header might have been overwritten by another thread. So, it only reads the mark word, tries to figure out the object has been forwarded, and then calls `size_given_klass` to figure out the size.
> 
> The `size_given_klass` has some asserts that checks that the different ways to calculate array sizes are consistent, but since other threads could be updating the length field, there is an escape-hatch that makes that assert less strict. This is the assert:
> 
> assert(s == klass->oop_size(this) || size_might_change(), "wrong array object size");
> 
> 
> The problem for Lilliput is that `size_might_change()` rereads the object's klass pointer, which will fail because the header is overwritten with a forwarding pointer.
> 
> This can be fixed by passing in the klass or maybe by following the forwarding pointer to find the to-space object and find the klass from there, but I wonder if this all wouldn't be safer if we left the from-space object unmodified and instead changed the length field of the to-space object. In fact, this is exactly what G1 does since many years (which also indicates that the `size_might_change()` really shouldn't be checking for UseG1GC).
> 
> The above is a proposal of what this would look like. I'm publishing this here for Lilliput because it fixes a real bug here, but if this is the right way to go forward, then this should likely be upstreamed as well.
> 
> I've run this through tier1-3 with both UseParallelGC and UseCompactObjectHeaders enabled, and I'm currently running this through higher Oracle tiers.

This pull request has been closed without being integrated.

-------------

PR: https://git.openjdk.org/lilliput/pull/149


More information about the lilliput-dev mailing list