RFR: 8221724: Enable archiving of Strings with hash 0

Claes Redestad claes.redestad at oracle.com
Tue Apr 2 07:55:35 UTC 2019


Hi Ioi,

On 2019-04-02 02:18, Ioi Lam wrote:
> Hi Claes,
> 
> The changes look good.

thanks!

> 
> On 4/1/19 6:12 AM, Claes Redestad wrote:
>> Hi,
>>
>> the current implementation of String archiving explicitly excludes
>> Strings with hashcode 0, including "". The reason for this is not
>> explicitly stated, but is likely to be due the fact that
>> String::hashCode currently stores the calculated 0 to String.hash every
>> time, which doesn't play well with read-only memory.
>>
> Actually, archived strings are not stored in read-only memory. Instead, 
> the pages are mmap'ed copy-on-write. So for a non-empty archive string S 
> with zero hashcode, if you call S.hashCode, with your patch on top of 
> the current JDK code, we will end up writing a zero to S.hash (which was 
> zero to begin with). The net effect is no changes in memory content, but 
> the page does get dirtied, and will no longer be sharable with other 
> processes that map the same CDS archive.
> 
> When your other patch JDK-8221723 is applied with this patch (8221724), 
> then we will no longer have any dirty pages when you call S.hashCode for 
> any archived string S.

Thanks for elaborating. I guess using real read-only memory instead of
COW is still not feasible since archived objects could be used as
locks, in which case we'd write to the object header.

/Claes


More information about the hotspot-runtime-dev mailing list