Skip to content

Abbreviate or drop Java package names when rendering stacks - #4

Merged
lhotari merged 1 commit into
mainfrom
stacks-package-names
Sep 23, 2026
Merged

lhotari merged 1 commit into
mainfrom
stacks-package-names

Conversation

@lhotari

@lhotari lhotari commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Why

Java frames in a flame graph are dominated by their package names. io.netty.channel.epoll.Native.epollWait0 is mostly io.netty.channel.epoll., which leaves little room in a frame's box for the class and method that say what it is.

What changes

jonoffcpu-correlator.jar stacks gains --package-names full|abbreviate|drop:

Mode io.netty.channel.epoll.Native.epollWait0 becomes
full (default) io.netty.channel.epoll.Native.epollWait0
abbreviate i.n.c.e.Native.epollWait0
drop Native.epollWait0
  • Only package-qualified Class.method frames are changed. Nested and hidden classes keep their names (a.Outer$Inner.<init>, j.l.i.LambdaForm$MH/0x….invoke). Anything else — native frames such as epoll_wait or libc.so.6, [stack unavailable], and frames without a package — is left as it is.
  • Only the display changes:
    • --include/--exclude still match the full names, so existing patterns keep working.
    • Stacks that become identical (for example app.one.Worker.park and app.two.Worker.park under drop) merge into one line, and their time is summed.
    • --summary records the mode as packageNames.
  • full is the default, so a default rendering still reproduces jonoffcpu-offcpu-stacks.collapsed byte for byte.
  • The option works with every other stacks option, including --time.
  • Documented in README §5 and OFFLINE.md.

Verification

  • ./gradlew spotlessCheck :jonoffcpu-correlator:check passes. A new StackProfileTest case covers:
    • the frame rule on qualified, nested, hidden-class, unqualified and native names;
    • a rendered profile in each mode, including two stacks merging under drop;
    • filters matching full names under drop;
    • the summary field;
    • an invalid mode.
  • On the Pulsar broker profile (10,631 lines):
    • full reproduces the collapsed file byte for byte;
    • abbreviate shrinks the file from 14.0 MB to 10.6 MB and drop to 9.1 MB, with the same total time.

stacks --package-names full|abbreviate|drop changes how Java frames are shown: abbreviate cuts each package segment to its first letter (io.netty.channel.epoll.Native.epollWait0 becomes i.n.c.e.Native.epollWait0) and drop keeps Class.method. Frames that are not package-qualified Class.method names are left unchanged. Only the display changes: filters still match the full names, lines that become identical are summed, and the summary records the mode. full is the default, so the default rendering still reproduces the collapsed file byte for byte.
@lhotari
lhotari merged commit 8dcd889 into main Sep 23, 2026
5 checks passed
@lhotari
lhotari deleted the stacks-package-names branch September 24, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant