On Wed, 3 Aug 2022 06:24:16 GMT, Peter Levart <plev...@openjdk.org> wrote:
>> This is a continuation of effort from >> https://github.com/openjdk/jdk/pull/9533 to fix the ObjectStreamClassCaching >> test which is failing with various GCs != G1. The test class contains 2 test >> methods: >> - test2CacheReleaseUnderMemoryPressure - this one was not logically changed >> at all - just one method was inlined >> - test1CacheEffectiveness - this one now uses a different strategy which >> doesn't involve calling System.gc() in order to trigger reference processing >> in GC which is, as test failures reveal, sometimes to aggressive and >> triggers processing not only WeakReference(s) but also SoftReference(s). >> Instead, the test now gradually builds up memory pressure while checking >> what's happening to two WeakReference(s): ref1 - wrapping a cached >> ObjectStreamClass instance; and: ref2 - wrapping a new Object() instance. >> The "effectiveness" of caching is confirmed by verifying that weakly >> reachable new Object() referent of ref2 is GC-ed earlier than softly >> reachable ObjectStreamClass referent of ref1. >> The test now contains several @run(s) with explicitly selected set of GC >> algorithms: G1, Parallel, ZGC, Shenandoah. > > Peter Levart has updated the pull request incrementally with one additional > commit since the last revision: > > Add SerialGC variant Looks good with minor nits. I tested with 100 repeats, and it passes: $ CONF=linux-x86_64-server-fastdebug make run-test TEST=java/io/ObjectStreamClass/ObjectStreamClassCaching.java JTREG="REPEAT_COUNT=100" test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java line 2: > 1: /* > 2: * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. This update is incorrect, should be: Suggestion: * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java line 34: > 32: > 33: /* > 34: * @test id=with_G1GC The test identifiers can be just "G1", "Parallel", "Serial", etc. test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java line 72: > 70: /** > 71: * Test methods execute in same VM and are ordered by name. > 72: * We test effectiveness 1st which is sensitive to previous > allocations when ZGC is used. Comment mentions ZGC? test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java line 103: > 101: assertFalse( > 102: ref1.refersTo(null), > 103: "Cache lost entry together with WeakReference being cleared > although memory was not under pressure" Style: Suggestion: assertFalse(ref1.refersTo(null), "Cache lost entry together with WeakReference being cleared although memory was not under pressure" ------------- PR: https://git.openjdk.org/jdk/pull/9684