feat: extend gcprofile with --by=class and --fold (allocation hotspot views)#156
Merged
feat: extend gcprofile with --by=class and --fold (allocation hotspot views)#156
Conversation
Adds two new views to the existing 'argus gcprofile' command instead of
introducing a redundant 'argus alloc' that would duplicate 80% of its
behavior. Covers the gaps versus async-profiler -e alloc / JDK MC:
- --by=site (default, unchanged) vs --by=class to aggregate JFR
allocation events by the *allocated type* instead of stack frame.
Answers "which classes are burning bytes" directly.
- --fold=FILE writes folded stacks in Brendan Gregg's flamegraph.pl
format (root-first, leaf-last, merged by total bytes). Renders to
SVG with flamegraph.pl --colors=mem FILE > alloc.svg.
AllocationProfiler gains:
- analyzeByClass(Path) β AllocationByClass (new AllocatedType record)
- analyzeFoldedStacks(Path) β Map<String, Long> of folded -> bytes
- readAllocationSize helper shared across both paths
Help and bash completion reflect the new flags. Existing output for
'argus gcprofile <pid>' with no extra flags is unchanged β no breaking
changes for current users.
Unit tests mirror both aggregation paths in test-local helpers
(JFR files can't be built from unit tests) and cover: sort order,
rate calculation, class-coalescing, empty input, stack reordering,
stack merging, and zero/empty-stack skipping.
Closes #152.
Signed-off-by: rlaope <piyrw9754@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #152.
Summary
Extends
argus gcprofilewith two new views instead of introducing a redundantargus alloccommand. During implementation it became clear thatgcprofilealready does 80% of what the originalallocproposal described β same JFR event types (jdk.ObjectAllocationInNewTLAB/OutsideTLAB), same--duration/--top, same top-N table, same JSON. A second command would just split the mental model.What
gcprofilewas actually missing (vs async-profiler-e alloc/ JDK Mission Control):This PR closes both gaps with two surgical flags.
Changes
--by=site|class(defaultsiteβ unchanged)siteβ current stack-frame aggregation.classβ aggregates by the allocated object's type (event.getClass(\"objectClass\")). Answers "which classes are burning bytes".--fold=FILEβ writes folded stacks in Brendan Gregg'sflamegraph.plformat (root-first, leaf-last, merged by total bytes). Render withflamegraph.pl --colors=mem FILE > alloc.svg.AllocationProfiler:analyzeByClass(Path) β AllocationByClassanalyzeFoldedStacks(Path) β Map<String, Long>Non-goals in this PR
argus gcprofileremains the single entry point for allocation profiling.--fold=FILEproduces folded text; SVG is oneflamegraph.plcall away. A bundled renderer can be added in a follow-up if needed.--duration, same as today.Backwards compatibility
argus gcprofile <pid>(no extra flags) emits the exact same output as before. No existing caller is affected.Developer experience
References
-e allocmodejdk.ObjectAllocationInNewTLAB,jdk.ObjectAllocationOutsideTLABTest plan
./gradlew :argus-cli:compileJavaβ BUILD SUCCESSFUL./gradlew :argus-cli:testβ full suite passesargus gcprofilebehavior unchanged (default--by=sitepath still the first branch)