RFR: 8249: Add support for the new allocation profiler in rules
Carter Kozak
duke at openjdk.org
Fri Aug 30 19:19:53 UTC 2024
## Allocation Rules may use ObjectAllocationSample
The allocation profiling rules (`AllocationByClassRule`, `AllocationByThreadRule`, `AutoBoxingRule`) were developed prior to the introduction of the newer and less invasive ObjectAllocationSample event. I've updated these rules to prefer the more precise events, but when those are unavailable, use the new ObjectAllocationSample events instead. This proved a bit tricky because the rules are scored based on number of events sampled, where the new events may not be emitted for every tlab based on a rate limit, so we must take into account the sample weight and estimate the number of samples as best we can.
The `IRule#getRequiredEvents` API doesn't provide a way to declare _either_ dependencies, so I opted to remove the dependencies in favor of a similar check in the `getResult` implementation.
## JfrGenerator Utility
The idea is to provide java sources with code that violates rules. We compile and execute the input sources while capturing a JFR, and execute rules against the results to verify they work as expected.
I like having the input sources available in the test rather than only a JFR recording, because it's not clear whether most JDKs will still create the given recording, or with what configuration. However, the trade-off is that we're only testing against the JVM used to run tests, which represents a subset of all supported versions.
This type of test must also compile and execute small Java programs, which is more expensive than executing against an existing recording, and may be more likely to flake if we're not careful.
Anyhow, I thought I would share the idea before moving forward, as always, feedback is appreciated :-)
-------------
Commit messages:
- revert changes to JdkAttributes.TOTAL_ALLOCATION_SIZE
- style
- tests opt out of ObjectAllocationSample throttling
- reset baseline
- coverage for autoboxing
- style
- scale by min weight
- docs and style
- Attempt to use allocaiton sample events in allocation rules
- spotless
- ... and 1 more: https://git.openjdk.org/jmc/compare/719b7142...9f2e7c02
Changes: https://git.openjdk.org/jmc/pull/579/files
Webrev: https://webrevs.openjdk.org/?repo=jmc&pr=579&range=00
Issue: https://bugs.openjdk.org/browse/JMC-8249
Stats: 449 lines in 6 files changed: 418 ins; 15 del; 16 mod
Patch: https://git.openjdk.org/jmc/pull/579.diff
Fetch: git fetch https://git.openjdk.org/jmc.git pull/579/head:pull/579
PR: https://git.openjdk.org/jmc/pull/579
More information about the jmc-dev
mailing list