RFR: 8298341: Ensure heap growth in TestNativeMemoryUsageEvents.java

Stefan Johansson sjohanss at openjdk.org
Thu Dec 8 09:34:06 UTC 2022


On Thu, 8 Dec 2022 08:12:36 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:

>> Please review this test fix.
>> 
>> **Summary**
>> The new test TestNativeMemoryUsageEvents.java sometimes fail. The reason is that the _NativeMemoryUsage_ and _NativeMemoryUsageTotal_ events want to share a single `NMTUsage` snapshot. To achieve this there is an `AgeThreshold` set to 50ms that is considered when sending the events. If the usage snapshot is new enough we don't refresh it, but reuse it. In the test this becomes problematic if the recording is shorter than 50ms, then both the beginChunk event and the endChunk event will use the same NMT data. 
>> 
>> This could be solved by using the feature currently reviewed in #11541 and this is the plan, see: [JDK-8298276](https://bugs.openjdk.org/browse/JDK-8298276). But since this is not yet done, I propose to fix the test for now by just adding a short sleep during the recording to ensure the endChunk event is delayed enough to cause a new NMT snapshot to be taken.
>> 
>> **Testing**
>> * Local testing with a larger `AgeThreshold` to see that a sleep really helps the problem.
>> * Mach5 testing to verify the fix is good there as well, this is currently running.
>
> Marked as reviewed by egahlin (Reviewer).

Thanks @egahlin and @tstuefe for the quick reviews.

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

PR: https://git.openjdk.org/jdk/pull/11579


More information about the hotspot-jfr-dev mailing list