When rewriting a file using the RecordingFile::write method it's possible to see which constants that are never referenced by an event and effectively wasted file space.
The test TestWaste.java checks if more than 10% of a recording file is waste. To simplify debugging of waste issues, it would be helpful if the types that contributes to the waste are logged.
To get a summary per chunk, a user can after the enhancement been checked in do:
$ jfr scrub -J-Xlog:jfr+system+parser=debug recording-with-waste.jfr
...
[0.414s][debug][jfr,system,parser] Total chunk waste by jdk.types.Bytecode: 2585 bytes.
[0.414s][debug][jfr,system,parser] Total chunk waste by jdk.types.CompilerPhaseType: 1723 bytes.
[0.414s][debug][jfr,system,parser] Total chunk waste by jdk.types.VMOperationType: 1602 bytes.
...
To see every individual constant that is not used:
$ jfr scrub -Xlog:fr+system+parser=trace recording-with-waste.jfr
...
[0.128s][trace][jfr,system,parser] Unreferenced constant ID 7 of type jdk.types.G1YCType using 7 bytes
[0.128s][trace][jfr,system,parser] Unreferenced constant ID 0 of type jdk.types.G1HeapRegionType using 7 bytes
...
The test TestWaste.java checks if more than 10% of a recording file is waste. To simplify debugging of waste issues, it would be helpful if the types that contributes to the waste are logged.
To get a summary per chunk, a user can after the enhancement been checked in do:
$ jfr scrub -J-Xlog:jfr+system+parser=debug recording-with-waste.jfr
...
[0.414s][debug][jfr,system,parser] Total chunk waste by jdk.types.Bytecode: 2585 bytes.
[0.414s][debug][jfr,system,parser] Total chunk waste by jdk.types.CompilerPhaseType: 1723 bytes.
[0.414s][debug][jfr,system,parser] Total chunk waste by jdk.types.VMOperationType: 1602 bytes.
...
To see every individual constant that is not used:
$ jfr scrub -Xlog:fr+system+parser=trace recording-with-waste.jfr
...
[0.128s][trace][jfr,system,parser] Unreferenced constant ID 7 of type jdk.types.G1YCType using 7 bytes
[0.128s][trace][jfr,system,parser] Unreferenced constant ID 0 of type jdk.types.G1HeapRegionType using 7 bytes
...