RFR: 8307458: Add periodic heap usage JFR events

Axel Boldt-Christmas aboldtch at openjdk.org
Mon May 8 15:47:23 UTC 2023


On Mon, 8 May 2023 14:08:58 GMT, Erik Helin <ehelin at openjdk.org> wrote:

> Hi all,
> 
> please review this patch that adds two new JFR events:
> 
> - `GCHeapMemoryUsage`
> - `GCHeapMemoryPoolUsage`
> 
> The two new events are periodic (period configurable as usual) and should contain the same information as a call to [`MemoryMXBean.getHeapMemoryUsage`](https://docs.oracle.com/en/java/javase/20/docs/api/java.management/java/lang/management/MemoryMXBean.html#getHeapMemoryUsage()) and/or [`MemoryPoolMXBean.getUsage`](https://docs.oracle.com/en/java/javase/20/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getUsage()). Having this data accessible via JFR (in addition to MXBeans) is useful for tools working primarily with JFR recordings, for example [JMC](https://openjdk.org/projects/jmc/).
> 
> ### Testing
> - [x] Tier 1 - 3 on Linux x64, Linux aarch64, Windows x64, macOS aarch64
> - [x] Added two new JTReg tests for the new events
> - [x] Local testing on macOS aarch64
> 
> Thanks,
> Erik

looks good. Just one comment to use `UNTIMED`. Not sure if it matters.
Cannot comment on the default control groups, as I am unsure of their purpose.
But nice to be able to have this information in the JFR recordings.

src/hotspot/share/jfr/periodic/jfrPeriodic.cpp line 532:

> 530: TRACE_REQUEST_FUNC(GCHeapMemoryUsage) {
> 531:   MemoryUsage usage = Universe::heap()->memory_usage();
> 532:   EventGCHeapMemoryUsage event;

-EventGCHeapMemoryUsage event;
+EventGCHeapMemoryUsage event(UNTIMED);

Is probably better as you set the start time manually bellow.
(I even thought it was required, but I guess you are allowed to overwrite the start and end time)

src/hotspot/share/jfr/periodic/jfrPeriodic.cpp line 548:

> 546:     if (pool->is_heap()) {
> 547:       MemoryUsage usage = pool->get_memory_usage();
> 548:       EventGCHeapMemoryPoolUsage event;

-EventGCHeapMemoryPoolUsage event;
+EventGCHeapMemoryPoolUsage event(UNTIMED);

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

PR Review: https://git.openjdk.org/jdk/pull/13867#pullrequestreview-1417044211
PR Review Comment: https://git.openjdk.org/jdk/pull/13867#discussion_r1187595895
PR Review Comment: https://git.openjdk.org/jdk/pull/13867#discussion_r1187596182


More information about the hotspot-dev mailing list