RFR: 8330027: Identity hashes of archived objects must be based on a reproducible random seed [v3]
Thomas Stuefe
stuefe at openjdk.org
Tue May 7 04:58:21 UTC 2024
On Wed, 1 May 2024 17:46:57 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>>> > I think it's better to just not compute the identity hash inside the VM thread. Here's what I tried
>>> > [iklam at ad95e2e](https://github.com/iklam/jdk/commit/ad95e2e8b00cb151617463af41648cdece2dfc7b)
>>> > We thought that forcing the identity hash computation would increase sharing across processes, as it would mean fewer updates of the object headers during run time. However, most of the heap objects in the CDS archive are not accessible by the application (they are part of the archived module graph, etc). Also the archive contains a large number of Strings, which are unlikely to need the identity hash (String has its own hashcode() method).
>>> > Since the reason is rather dubious, I think it's better to remove it and simplify the system.
>>>
>>> I like that, that is simpler. Okay, then we will only call ihash from a single thread, so a global constant seed should be fine. I should be able to assert that, right?
>>
>> AI think an assert can be added, since we don't allow any Java threads to be launched. So even test cases that run arbitrary Java code during -Xshare:dump (using Java agents of -XX:ArchiveHeapTestClass) will not be able to run any Java code outside of the main Java thread.
>
>> @iklam Sorry, had to force push because I messed up the PR branch somehow.
>
> I think it's possible to just discard your local branch, and check out a new version from the PR, then make changes on top of it. That way you can avoid forced pushes.
>
>> The new version contains the change proposed by you - getting rid of explicit ihash generation when dumping - as well as a simplified version of my original patch. We now are back at generating the ihash seed in Thread::Thread(), with a constant if CDS dumps, and on ihash generation we check that we ever only call it with a single thread.
>
> This version looks good. I am running our tiers 1-4 just to be sure.
>
> Thanks
@iklam I decided to remove the assert. I briefly thought about adding a condition to time (don't assert after dump finished) but decided against more complexity.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18735#issuecomment-2097444330
More information about the hotspot-runtime-dev
mailing list