GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add frame-level stack transforms to stacks (#10) · jonoffcpu/jonoffcpu@8fa9237

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • jonoffcpu-correlator
    • OFFLINE.md
    • build.gradle.kts
    • src
      • main
        • java/io/github/lhotari/jonoffcpu/offline
          • Cli.java
          • CollapsedStacks.java
          • OffCpuCorrelator.java
          • Presets.java
          • StackProfileRenderer.java
          • StackTransforms.java
        • resources/io/github/lhotari/jonoffcpu/presets
          • jvm-idle.txt
          • jvm-infra.txt
          • jvm-wait-machinery.txt
      • test
        • java/io/github/lhotari/jonoffcpu/offline
          • CommandLineTest.java
          • FixtureAcceptanceTest.java
          • StackTransformsTest.java
        • resources/help
          • jonoffcpu-correlator.txt
          • stacks.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+31Lines changed: 31 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,16 @@ java -jar jonoffcpu-correlator.jar stacks \
650650
java -jar jonoffcpu-correlator.jar stacks \
651651
--profile /tmp/jonoffcpu-analysis/jonoffcpu-offcpu-profile.pb \
652652
--package-names abbreviate --output short.collapsed
653+
654+
# Busy waits only, each stack from your first frame to the lock or monitor it waited on
655+
java -jar jonoffcpu-correlator.jar stacks \
656+
--profile /tmp/jonoffcpu-analysis/jonoffcpu-offcpu-profile.pb \
657+
--exclude-from preset:jvm-idle --root-at '^com\.example\.' \
658+
--collapse-leaf-from preset:jvm-wait-machinery --output busy-app.collapsed
659+
660+
# The same transforms on any collapsed file, such as the recording's CPU view
661+
java -jar jonoffcpu-correlator.jar stacks --collapsed-input cpu.collapsed \
662+
--trim-root-from preset:jvm-infra --output cpu-trimmed.collapsed
653663
```
654664

655665
`--reason` takes `all` (the default) or a comma-separated list of `blocked`,
@@ -704,6 +714,27 @@ Blank lines and lines starting with `#` are skipped (write `\#` for a pattern
704714
that starts with `#`), and every other line is taken verbatim, spaces included.
705715
A file with no patterns, or with an invalid one, is refused, naming the line.
706716

717+
Filters keep or drop whole intervals; transforms change the frames of the
718+
intervals kept, and never a total. `--trim-root` strips the longest root-side
719+
run of matching frames (thread, executor and event-loop entry points),
720+
`--root-at` starts each stack at its root-most matching frame and puts stacks
721+
without one under `[no application frame]`, `--leaf-at` cuts below the
722+
leaf-most match, `--collapse-leaf` replaces the lock, park and monitor
723+
internals under a wait with the frame that entered them (or a category such as
724+
`[lock]` with `--collapse-leaf-label category`), `--hide` removes matching
725+
frames anywhere, `--canonical-names` removes generated-class addresses so two
726+
runs compare, and `--thread-frame name|pool` starts each line with the thread
727+
or its pool. Each has a `-from FILE` form, and every `-from` option, the
728+
filters' included, also takes a bundled `preset:jvm-infra`,
729+
`preset:jvm-wait-machinery` or `preset:jvm-idle` (`stacks --list-presets`).
730+
Filters always see the untransformed stack. On an Apache Pulsar broker's busy
731+
waits, `--root-at` with `--collapse-leaf` turns 164 lines at a mean depth of 23
732+
frames into 78 lines of about 4. `--collapsed-input FILE` applies the same
733+
filters and transforms to any collapsed file, such as the converter's CPU or
734+
allocation view, whose `_[j]`-style markers and `/`-separated class names it
735+
normalizes; the order and every rule are in
736+
[OFFLINE.md](jonoffcpu-correlator/OFFLINE.md#transforms).
737+
707738
Profiles merge and export as well:
708739

709740
```sh
Collapse file

‎jonoffcpu-correlator/OFFLINE.md‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/OFFLINE.md
+59Lines changed: 59 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ java -jar jonoffcpu-correlator.jar stacks --profile P --output F
273273
[--summary S]
274274
[--include REGEX]... [--exclude REGEX]...
275275
[--include-from FILE]... [--exclude-from FILE]...
276+
[--canonical-names] [--hide REGEX]... [--trim-root REGEX]...
277+
[--root-at REGEX]... [--root-at-unmatched bucket|keep] [--leaf-at REGEX]...
278+
[--collapse-leaf REGEX]... [--collapse-leaf-label frame|category]
279+
[--thread-frame none|name|pool] (each REGEX option also has a -from FILE form)
280+
java -jar jonoffcpu-correlator.jar stacks --collapsed-input C --output F [filters and transforms]
281+
java -jar jonoffcpu-correlator.jar stacks --list-presets
276282
java -jar jonoffcpu-correlator.jar merge --profiles A,B,... --output M
277283
java -jar jonoffcpu-correlator.jar export --profile P --format csv|jsonl --output E
278284
```
@@ -291,6 +297,59 @@ reason only when it contributes to the selected part. The `--summary` file names
291297
the `time` part and carries `unsplitNanos`, the kept entries' unsplit time, which
292298
a `sleeping` or `runqueue` slice leaves out.
293299

300+
### Transforms
301+
302+
Filters decide which entries a slice keeps; transforms change what a kept
303+
entry's Java stack looks like. They run per entry after the filters, which
304+
therefore always match the full, untransformed stacks, in this order:
305+
306+
1. `--canonical-names` removes generated-class addresses (`$$Lambda.0x…`,
307+
`$$Lambda$14/0x…`, `LambdaForm$MH/0x…`, `LambdaForm$DMH/0x…`), so runs compare.
308+
2. `--hide` removes every matching frame anywhere; a stack of nothing else
309+
keeps its leaf.
310+
3. `--trim-root` removes the longest root-side run of matching frames; the
311+
run stops at the first frame that does not match, so deeper matches stay,
312+
and a stack that matches throughout keeps its leaf.
313+
4. `--root-at` starts the stack at its root-most matching frame. A stack
314+
without one becomes the single frame `[no application frame]`, or stays as
315+
it is with `--root-at-unmatched keep`.
316+
5. `--leaf-at` cuts the callees of the leaf-most matching frame and keeps the
317+
match; a stack without one is unchanged.
318+
6. `--collapse-leaf` replaces the longest leaf-side run of matching frames by
319+
the run's root-most frame, or with `--collapse-leaf-label category` by the
320+
category of that frame: `[kernel]`, `[monitor]`, `[park]`, `[wait]`,
321+
`[sleep]`, `[lock]` or `[native]`, and the frame itself when none applies.
322+
323+
`--package-names` and `--thread-frame` (the thread's name, or its pool with
324+
every digit run replaced by `#`, as a frame after any reason frame) are then
325+
applied as display. With `--stack java+kernel` or `java+user+kernel` the native
326+
stacks are appended unchanged after the transformed Java stack. Lines that read
327+
the same after transforming merge, adding their intervals and nanoseconds, so
328+
no transform changes a total. Each `REGEX` option repeats, and has a
329+
`-from FILE` form that reads patterns as `--exclude-from` does. Every `-from`
330+
option, the filters' included, also accepts `preset:NAME`, a list bundled with
331+
the correlator: `jvm-infra` (thread, executor and Netty entry points, for
332+
`--trim-root` or `--hide`), `jvm-wait-machinery` (lock, park and monitor
333+
internals down to libc and the kernel, for `--collapse-leaf`) and `jvm-idle`
334+
(waits for work, for `--exclude-from`); `stacks --list-presets` prints them with
335+
their caveats. When any transform is in effect the `--summary` file gains a
336+
`transforms` object: each option with its patterns and their source (`inline`, a
337+
file, or `preset:NAME`), `linesBefore`/`linesAfter`, the weight-averaged depth
338+
`framesBefore`/`framesAfter`, and for `--root-at` the `noApplicationFrame`
339+
weight and share.
340+
341+
`--collapsed-input FILE` takes any collapsed file instead of a profile — a CPU,
342+
wall, allocation or lock view the converter wrote, or a jonoffcpu collapsed
343+
file — through the same filters, transforms and `--package-names`. The
344+
converter's Java frames lose their compilation marker (`_[j]`, `_[i]`, `_[0]`,
345+
`_[1]`) and the `/` of their class names; every other frame is kept verbatim.
346+
In a file with such markers every unmarked frame is native; in one without them
347+
a frame is native when its name contains `::`, `.so.` or a space, starts with
348+
`/` or `[`, or ends with `_[k]`. Weights keep the file's unit, integer or
349+
decimal, and the summary says `input: collapsed`. `--reason`, `--stack`,
350+
`--weights`, `--time`, `--reason-frame` and `--thread-frame` need a profile and
351+
are refused.
352+
294353
`--package-names abbreviate` cuts each package segment of a Java frame to its
295354
first letter (`io.netty.channel.epoll.Native.epollWait0` becomes
296355
`i.n.c.e.Native.epollWait0`), and `drop` shows `Class.method`; a hidden class's
Collapse file

‎jonoffcpu-correlator/build.gradle.kts‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/build.gradle.kts
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ val fixtureMains = mapOf(
294294
"PrimitiveStructures" to "io.github.lhotari.jonoffcpu.offline.PrimitiveStructuresTest",
295295
"StreamingCorrelator" to "io.github.lhotari.jonoffcpu.offline.StreamingCorrelatorTest",
296296
"StackProfile" to "io.github.lhotari.jonoffcpu.offline.StackProfileTest",
297-
"CommandLine" to "io.github.lhotari.jonoffcpu.offline.CommandLineTest"
297+
"CommandLine" to "io.github.lhotari.jonoffcpu.offline.CommandLineTest",
298+
"StackTransforms" to "io.github.lhotari.jonoffcpu.offline.StackTransformsTest",
299+
"FixtureAcceptance" to "io.github.lhotari.jonoffcpu.offline.FixtureAcceptanceTest"
298300
)
299301
val fixtureTasks = fixtureMains.map { (taskName, className) ->
300302
tasks.register<JavaExec>("test$taskName") {
@@ -315,6 +317,13 @@ tasks.named<JavaExec>("testCommandLine") {
315317
systemProperty("jonoffcpu.readme", rootProject.file("README.md").absolutePath)
316318
}
317319

320+
// The specs' reference numbers, on recordings kept outside the repository: -PjonoffcpuFixtures=DIR runs them.
321+
tasks.named<JavaExec>("testFixtureAcceptance") {
322+
val fixtures = providers.gradleProperty("jonoffcpuFixtures").orElse("")
323+
inputs.property("fixtures", fixtures)
324+
systemProperty("jonoffcpu.fixtures", fixtures.get())
325+
}
326+
318327
tasks.named<JavaExec>("testStreamingCorrelator") {
319328
jvmArgs("-ea", "-Xmx1g")
320329
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.