RFR: 8239508 JFR: @RemoveFields

Erik Gahlin egahlin at openjdk.org
Sun Oct 29 17:59:06 UTC 2023


This enhancement introduces an annotation that controls the presence of implicit fields for an event.

For native events, the metadata.xml file controls the existence of the fields "eventThread" "duration” and "stackTrace”. For Java events, there is nothing similar. This outage has been known since the inception of the jdk.jfr API. At that time, we decided to ignore it and write 0 for “eventThread”, “stackTrace”, and ”duration”. The gain was a simplified programming model with one annotation, i.e. StackTrace, instead of two, i.e. StackTrace and HasStackTrace, to determine if a value should be recorded.

With the removal of event handlers ([JDK-8282420](https://bugs.openjdk.org/browse/JDK-8282420) ) and use of the new Class-File API ([JDK-8318124](https://bugs.openjdk.org/browse/JDK-8318124) this capability can be added to Java events at a lower implementation cost. Also, we are considering adding other fields, such as allocation, cpuTime, or socketRead/Write, that can occur between a call to Event::begin() and Event::end().

There is still uncertainty about the design of the annotation, so it is currently only accessible to JDK events. Instead of a separate annotation per field, i.e. HasStackTrace, HasEventThread, and HasDuration, there is one annotation, RemoveFields, that provides a list of fields that should be dropped. This allows for a corresponding annotation, AddFields, to be included in the future, for example, to add the field cpuTime.

The benefits of the change are:

- a more compact recording file 
- less overhead 
- no mismatch between contents of .jfc files and what the API provides
- consistency with native events 
- less noise when events are visualized

Testing: test/jdk/jdk/jfr/  tier1 + tier2

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

Commit messages:
 - Initial

Changes: https://git.openjdk.org/jdk/pull/16411/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16411&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8239508
  Stats: 611 lines in 43 files changed: 392 ins; 120 del; 99 mod
  Patch: https://git.openjdk.org/jdk/pull/16411.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16411/head:pull/16411

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


More information about the hotspot-jfr-dev mailing list