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 top and summarize: ranked tables and an analysis digest (#12) · jonoffcpu/jonoffcpu@dea8da8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • jonoffcpu-agent/tools
    • run-packaged-agent-smoke.py
  • jonoffcpu-correlator
    • OFFLINE.md
    • build.gradle.kts
    • src
      • main/java/io/github/lhotari/jonoffcpu/offline
        • Cli.java
        • Digest.java
        • OffCpuCorrelator.java
        • OutputFiles.java
        • StackProfileRenderer.java
        • Top.java
      • test
        • java/io/github/lhotari/jonoffcpu/offline
          • CommandLineTest.java
          • FixtureAcceptanceTest.java
          • StreamingCorrelatorTest.java
          • TopTest.java
        • resources/help
          • correlate.txt
          • jonoffcpu-correlator.txt
          • summarize.txt
          • top.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+16Lines changed: 16 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ Analysis, written by the correlator into `--output`:
213213
| `jonoffcpu-offcpu-stacks.collapsed` | Java stacks weighted in microseconds of off-CPU time, for flame graphs. Every recorded interval; when the capture mixes switch-out reasons, each line starts with an `[offcpu: <reason>]` frame |
214214
| `jonoffcpu-offcpu-stacks-<reason>.collapsed` | The same, one file per switch-out reason, written only when the capture mixes reasons |
215215
| `jonoffcpu-offcpu-profile.pb` | The stack profile: every distinct Java, kernel and user stack once, with interval counts and observed and estimated durations per stack, reason and thread. Any other collapsed slice is rendered from it without re-correlating; see [5. Slice and filter with the stack profile](#5-slice-and-filter-with-the-stack-profile). Defined by [`docs/schema/jonoffcpu-profile.proto`](docs/schema/jonoffcpu-profile.proto) |
216+
| `jonoffcpu-summary.md`, `jonoffcpu-summary.json` | The analysis digest, for people and AI agents: coverage and losses, where the time went, ranked busy and idle tables, the heaviest transformed stacks, and the command that reproduces each table. The Markdown is rendered from the JSON. `--summary-output false` skips it; a failure to write it is reported in the report and never fails the correlation |
216217
| `jonoffcpu-offcpu-synthetic.jfr` | The same data as duration-quantized `jdk.ExecutionSample` events, for JFR viewers |
217218
| `jonoffcpu-classified-records.jsonl` | Every source row and every JFR sample with its classification, for auditing. Written only with `--audit full`; **not written by default** |
218219
| `jonoffcpu-matches.jsonl` | Every exact-cookie match with its clipped interval and delivery delay. Written by the default `--audit matches`, and by `--audit full` |
@@ -744,6 +745,20 @@ duckdb -c "SELECT reason, java_stack, sum(observed_nanos) / 1e9 AS seconds
744745
FROM read_csv('entries.csv') GROUP BY ALL ORDER BY seconds DESC LIMIT 20"
745746
```
746747

748+
`top` ranks the same profile instead of drawing it: each interval is idle when
749+
a frame matches `--idle`/`--idle-from` (for example `preset:jvm-idle`) and busy
750+
otherwise, and busy time is attributed to the deepest frame of your code
751+
(`--app`) and the lock, monitor or park below it, with idle time in a table of
752+
its own. `summarize` writes the same tables into the digest that correlation
753+
writes by default:
754+
755+
```sh
756+
java -jar jonoffcpu-correlator.jar top --profile runs.pb \
757+
--app '^com\.example\.' --idle-from preset:jvm-idle --format md
758+
java -jar jonoffcpu-correlator.jar top --profile new.pb --baseline old.pb \
759+
--units 5 --baseline-units 5 --app '^com\.example\.' --idle-from preset:jvm-idle
760+
```
761+
747762
A merged profile sums durations across its inputs: it shows what dominates
748763
across the runs, not what fraction of any one run's time it took. Thinned
749764
profiles cannot be merged, because each is rescaled by its own probability.
@@ -930,6 +945,7 @@ The agent can also be started programmatically with
930945
| `--thinning-seed <n>` | Changes the deterministic draw `--thinning` uses. |
931946
| `--collapsed-reason-frame auto\|always\|never` | Whether each line of `jonoffcpu-offcpu-stacks.collapsed` starts with its `[offcpu: <reason>]` frame. Default `auto`: only when the capture mixes reasons. |
932947
| `--profile-output true\|false` | Whether to write `jonoffcpu-offcpu-profile.pb`. Default `true`. |
948+
| `--summary-output true\|false` | Whether to write the digest, `jonoffcpu-summary.md` and `.json`. Default `true`. |
933949
| `--profile-group-by <list>` | Which optional dimensions the profile keeps besides the Java stack and the reason: any of `kernel`, `user`, `thread`, or `none`. Default all three. |
934950
| `--max-profile-entries <n>` | Entry limit for the profile. Past it the thread, then the user stack, then the kernel stack are dropped from the grouping, which merges entries and changes no total; the report names what was dropped. Default 2,000,000. |
935951

Collapse file

‎jonoffcpu-agent/tools/run-packaged-agent-smoke.py‎

Copy file name to clipboardExpand all lines: jonoffcpu-agent/tools/run-packaged-agent-smoke.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ def main():
162162
profile_path = output / "analysis/jonoffcpu-offcpu-profile.pb"
163163
if not profile_path.is_file() or profile_path.stat().st_size == 0:
164164
raise RuntimeError(f"Stack profile is missing or empty: {profile_path}")
165+
# The digest is written by default, and the report names it rather than an error.
166+
digest = report.get("digest") or {}
167+
digest_path = output / "analysis/jonoffcpu-summary.md"
168+
if digest.get("path") != "jonoffcpu-summary.md" or not digest_path.is_file():
169+
raise RuntimeError(f"Analysis digest is missing ({digest}): {digest_path}")
165170
# The profile renders back to the collapsed stacks the correlator wrote.
166171
run(
167172
[
Collapse file

‎jonoffcpu-correlator/OFFLINE.md‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/OFFLINE.md
+78Lines changed: 78 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,84 @@ into its own table and join to the rows on `run`:
423423

424424
Its counters follow the same number rule.
425425

426+
## Ranked tables and the digest
427+
428+
`top` ranks where a profile's (or, with `--collapsed-input`, any collapsed
429+
file's) time went, with the selection, filter and transform options of
430+
`stacks`:
431+
432+
```sh
433+
java -jar jonoffcpu-correlator.jar top (--profile P | --collapsed-input F)
434+
[--by boundary|self|method|class|package|pool] [--app REGEX]... [--app-from FILE]...
435+
[--idle REGEX]... [--idle-from FILE]... [--machinery-from FILE]...
436+
[--weights observed|estimated] [--limit N] [--format md|json|csv] [--output FILE]
437+
[--baseline P2 [--units X --baseline-units Y]]
438+
java -jar jonoffcpu-correlator.jar summarize --profile P [--report R] [--app REGEX]...
439+
[--idle-from FILE]... [--limit N] [--output-dir D]
440+
```
441+
442+
- **Idle or busy.** An entry is idle when any frame of any of its stacks
443+
matches an idle pattern, matched as `--exclude` matches. Idle entries are not
444+
dropped: they get their own table. `--exclude` still removes entries.
445+
- **Attribution** is computed on the Java stack after `--canonical-names` and
446+
`--hide`. `boundary` (the default, which needs `--app`) keys a row by the
447+
deepest application frame and its **blocker**: the entry frame of the longest
448+
leaf-side run below the boundary that matches the wait machinery
449+
(`--machinery-from`, default `preset:jvm-wait-machinery`), or the leaf when
450+
there is none. Busy entries without an application frame go to a table by
451+
thread pool (the name with digit runs as `#`). `self` is the leaf after the
452+
transforms, `method`, `class` and `package` count every distinct one in the
453+
stack once per entry (inclusive), and `pool` is the thread's pool.
454+
- **Columns**: rank, key (and blocker), seconds to three decimals, share of the
455+
busy total (of the idle total in the idle table), intervals, estimated
456+
seconds when the profile's estimate is available, sleeping and run-queue
457+
seconds when it has the split, the dominant reason, and for boundary rows the
458+
heaviest root-most application frame (the caller, after `--trim-root` and
459+
`--root-at`). Rows sort by weight, then key.
460+
- **Totals** add up: busy and idle make the selection, and application rows and
461+
the pool table make the busy total. The over-exclusion check counts idle
462+
entries with a `java.util.concurrent.locks.*.lock*`/`acquire*` or
463+
`complete_monitor_locking` frame, the waits an idle list may hide by mistake.
464+
- **Weights.** `observed` by default; `estimated` needs the profile's
465+
estimate. Under proportional or uniform admission observed time
466+
under-weights short waits, and the output warns.
467+
- **`--baseline`** keys both runs by application boundary and gives each row's
468+
seconds, or seconds per unit of work with `--units`/`--baseline-units`, and
469+
its share of that run's busy application time. Rows present in one run only
470+
have the other side empty; rows sort by the larger value, then by the
471+
absolute delta. It refuses observed weights when both runs have estimates and
472+
either was sampled, warns when neither has estimates, and warns when the runs'
473+
unresolved native frames (`/lib/…` paths) differ by more than 10 points of
474+
busy time, since their time without an application frame is then not
475+
comparable.
476+
- **Formats.** `json` is the source: `schemaVersion` 1, `command` (the
477+
reproduce command), `by`, `unit`, `selection` (every option, with the
478+
patterns and their sources), `totals`, `rows`, `noApplicationFrame`, `idle`
479+
(or `comparison`), and `warnings`. `md` and `csv` (one row per table row,
480+
with a `table` column) are rendered from it.
481+
482+
Correlation writes the **digest**, `jonoffcpu-summary.json` and
483+
`jonoffcpu-summary.md`, next to the report unless `--summary-output false` is
484+
given, with `preset:jvm-idle`, `preset:jvm-wait-machinery`, canonical names and
485+
no application pattern; `summarize` rewrites it with `--app`. The report's
486+
`digest` object names the files, or holds the `error` when the digest could not
487+
be written, which never fails the correlation. The JSON, `schemaVersion` 1:
488+
489+
| Field | Contents |
490+
| --- | --- |
491+
| `profile`, `run`, `estimateAvailable`, `timeSplitAvailable` | What was summarised |
492+
| `capture` | From the report: session, sampling, source rows, matched, rows outside the selected JFR window, orphan and invalid counts, collector loss counters, handler delay p50/p99/max, reasons and kernel switch-outs, the population estimate's status and accounted loss when present, and degradation steps |
493+
| `selection` | As in `top --format json` |
494+
| `whereTheTimeWent` | `top`'s totals: selected, idle, busy, busy with and without an application frame, over-exclusion |
495+
| `busy`, `idle` | `by` (`boundary` with `--app`, else `self` after collapsing the wait machinery), the reproducing `command`, and the `rows` |
496+
| `busyNoApplicationFrameByPool` | The pool table (with `--app`), or busy time by pool (without) |
497+
| `heaviestStacks` | The busy slice with `--root-at` (or `--trim-root-from preset:jvm-infra`) and `--collapse-leaf`, dropped package names: its `lines`, `meanDepth`, the ten heaviest lines, and the `command` |
498+
| `warnings` | As in `top` |
499+
500+
Every table is limited to `--limit` rows (default 20), which keeps the Markdown
501+
of an Apache Pulsar broker's digest under 16 KB. The Markdown is rendered from
502+
the JSON, so the two cannot disagree, and the same inputs give the same bytes.
503+
426504
## Degradation
427505
428506
A profile is not an audit log. When a capture does not fit the retained-bytes budget,
Collapse file

‎jonoffcpu-correlator/build.gradle.kts‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/build.gradle.kts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ val fixtureMains = mapOf(
297297
"CommandLine" to "io.github.lhotari.jonoffcpu.offline.CommandLineTest",
298298
"StackTransforms" to "io.github.lhotari.jonoffcpu.offline.StackTransformsTest",
299299
"Export" to "io.github.lhotari.jonoffcpu.offline.ExportTest",
300+
"Top" to "io.github.lhotari.jonoffcpu.offline.TopTest",
300301
"FixtureAcceptance" to "io.github.lhotari.jonoffcpu.offline.FixtureAcceptanceTest"
301302
)
302303
val fixtureTasks = fixtureMains.map { (taskName, className) ->

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.