RFR: 8309688: Data race on java.io.ClassCache$CacheRef.strongReferent [v4]

Man Cao manc at openjdk.org
Thu Jun 15 00:10:57 UTC 2023


On Thu, 15 Jun 2023 00:05:32 GMT, Man Cao <manc at openjdk.org> wrote:

>> Hi all,
>> 
>> Could anyone review this small fix for a data race in java.io.ClassCache$CacheRef? This fix makes the code safer by making the code data-race-free.
>
> Man Cao has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Removed volatile and comment about the benign race

Thanks for the benchmarking. I was unaware of the microbenchmark `java.io.ObjectStreamClasses`.
The performance penalty is likely related to aarch64 being slower on volatile load. I see no observable difference on x86-64:

Benchmark                       Mode  Cnt    Score    Error  Units
# Before
ObjectStreamClasses.testLookup  avgt    8  230.255 ± 10.540  ns/op

# After
ObjectStreamClasses.testLookup  avgt    8  230.291 ± 19.369  ns/op


Anyway, this race does look benign and I'm OK with just documenting this benign race, and suppress it in TSAN. Updated this PR to a comment-only change.

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

PR Comment: https://git.openjdk.org/jdk/pull/14386#issuecomment-1592147495


More information about the core-libs-dev mailing list