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 — Correlate large captures in a streaming columnar pass (#1) · jonoffcpu/jonoffcpu@325188d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • jonoffcpu-agent/tools
    • run-native-agent-interruptions.py
  • jonoffcpu-correlator
    • OFFLINE.md
    • build.gradle.kts
    • src
      • main/java/io/github/lhotari/jonoffcpu/offline
        • AnalysisOutput.java
        • AuditLevel.java
        • AuditPass.java
        • CaptureInput.java
        • CompatibilityJfrWriter.java
        • CorrelationEngine.java
        • CorrelationResult.java
        • Degradation.java
        • JfrDictionaries.java
        • LongIntMap.java
        • OffCpuCorrelator.java
        • OfflineCorrelator.java
        • Outcome.java
        • OutputFiles.java
        • QuantumPlanner.java
        • Reason.java
        • RetentionEstimate.java
        • RetentionLimitExceeded.java
        • SampleColumns.java
        • SourceColumns.java
        • SyntheticJfrSource.java
        • Thinning.java
        • U64.java
      • test/java/io/github/lhotari/jonoffcpu/offline
        • CompatibilityJfrWriterTest.java
        • PartialCorrelatorTest.java
        • PrimitiveStructuresTest.java
        • StreamingCorrelatorTest.java
  • jonoffcpu-native/tools
    • run-agent-signal-pressure.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+34-3Lines changed: 34 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,29 @@ Analysis, written by the correlator into `--output`:
204204
| `jonoffcpu-report.json` | Lifecycle, loss, classification, duration, delivery-delay accounting, and the optional population estimate |
205205
| `jonoffcpu-offcpu-stacks.collapsed` | Java stacks weighted in microseconds of off-CPU time, for flame graphs |
206206
| `jonoffcpu-offcpu-synthetic.jfr` | The same data as duration-quantized `jdk.ExecutionSample` events, for JFR viewers |
207-
| `jonoffcpu-classified-records.jsonl` | Every source row and every JFR sample with its classification, for auditing |
208-
| `jonoffcpu-matches.jsonl` | Every exact-cookie match with its clipped interval and delivery delay |
209-
| `jonoffcpu-complete.json` | Written last, only after all inputs and outputs validate |
207+
| `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** |
208+
| `jonoffcpu-matches.jsonl` | Every exact-cookie match with its clipped interval and delivery delay. Written by the default `--audit matches`, and by `--audit full` |
209+
| `jonoffcpu-complete.json` | Written last, only after all inputs and outputs validate. Never written when the run narrowed its window (see `--on-limit` below) |
210+
211+
`--audit` defaults to `matches`, so `jonoffcpu-classified-records.jsonl` is no
212+
longer written unless `--audit full` is passed — this is a backward-incompatible
213+
change from earlier releases, which always wrote both audit files. Anything that
214+
reads `jonoffcpu-classified-records.jsonl` needs `--audit full` added to its
215+
correlator invocation. The library API (`OffCpuCorrelator.correlate`) is
216+
unaffected and keeps writing both.
217+
218+
When the retained-bytes budget is reached, `--on-limit degrade` (the default)
219+
trades away thinner outputs before it trades away coverage: it coarsens the
220+
synthetic JFR quantum, drops the audit outputs, then thins the source with an
221+
exact inverse-probability reweighting, and only as a last resort narrows the
222+
analysis window. Thinning still analyses the whole requested window — with
223+
ordinary output names, `jonoffcpu-complete.json`, and exit status 0 — because it
224+
is a stated estimator over what was asked for. Narrowing the window instead
225+
analyses a shorter window *completely*, and is labelled as visibly incomplete:
226+
`INCOMPLETE-jonoffcpu-*` names, a `jonoffcpu-narrowed.json` marker instead of
227+
`jonoffcpu-complete.json`, and exit status 2. See
228+
[jonoffcpu-correlator/OFFLINE.md's **Degradation**](jonoffcpu-correlator/OFFLINE.md#degradation)
229+
for the full ladder and the report's `degradation` object.
210230

211231
`--partial true` inspects an interrupted capture and writes a visibly different
212232
set instead: `INCOMPLETE-jonoffcpu-report.json`,
@@ -670,6 +690,17 @@ The agent can also be started programmatically with
670690
| `--format collapsed\|jfr` | Produce only one of the two derived outputs. |
671691
| `--partial-jfr true` | Accept a JFR that another tool has cut. Source rows without a sample in the cut JFR are reported as expected omissions instead of loss. |
672692
| `--partial true` | Inspect an interrupted capture. Writes `INCOMPLETE-jonoffcpu-*` files and a `jonoffcpu-partial.json` marker, exits with status 2, and never writes `jonoffcpu-complete.json` or the synthetic JFR. |
693+
| `--audit full\|matches\|none` | How much per-row audit output to write. Default `matches`: `jonoffcpu-matches.jsonl` but not `jonoffcpu-classified-records.jsonl`. |
694+
| `--on-limit degrade\|fail\|truncate` | What to do when the retained-bytes budget is reached. Default `degrade`: coarsen the synthetic quantum, drop audit outputs, thin and reweight, narrow the window — reporting each step. `fail` refuses immediately, like earlier releases. `truncate` skips thinning and narrows the window directly. |
695+
| `--thinning <q>` | Keep each recorded interval with probability `q` and reweight by `1/q`. Deterministic in the cookie, so the result does not depend on order. Default: chosen automatically, and `1` whenever the input fits. |
696+
| `--thinning-seed <n>` | Changes the deterministic draw `--thinning` uses. |
697+
698+
`--max-rows` and `--max-retained-bytes` bound admission; the default
699+
`--max-retained-bytes` is sixty percent of the JVM's `-Xmx`, never below 256 MiB.
700+
Plan a capture's memory against roughly 80 bytes of correlator retention per
701+
recorded interval, plus one retained copy of each distinct Java stack — retention
702+
tracks distinct stacks, not capture length, so a long capture with few distinct
703+
call paths costs little more than a short one.
673704

674705
By default the correlator refuses a JFR whose size or SHA-256 differs from the
675706
one recorded in the stream's footer. The full output, integrity, and weighting
Collapse file

‎jonoffcpu-agent/tools/run-native-agent-interruptions.py‎

Copy file name to clipboardExpand all lines: jonoffcpu-agent/tools/run-native-agent-interruptions.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def verify_ap_first(module, jdk, case, expected_reason):
133133
case / "jonoffcpu-capture.jfr", case / "event-counts.json"], case / "category-check.log")
134134
run([jdk / "bin/java", "-cp", classpath, "io.github.lhotari.jonoffcpu.offline.OffCpuCorrelator",
135135
"--source", case / "jonoffcpu-capture.pb", "--jfr", case / "jonoffcpu-capture.jfr",
136-
"--output", case / "analysis"], case / "analysis.log")
136+
"--output", case / "analysis", "--audit", "full"], case / "analysis.log")
137137

138138
report = json.loads((case / "analysis/jonoffcpu-report.json").read_text())
139139
source_total = report["matched"] + report["unmatchedSource"] + report["invalidSource"]
Collapse file

‎jonoffcpu-correlator/OFFLINE.md‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/OFFLINE.md
+129-13Lines changed: 129 additions & 13 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,35 @@ recognisable wherever the directory ends up. A successful run writes:
5959

6060
| File | Contents | Written when |
6161
| --- | --- | --- |
62-
| `jonoffcpu-report.json` | Capture counters, classifications, handler-delay percentiles, interpretation notes and the opt-in population estimate | always |
63-
| `jonoffcpu-classified-records.jsonl` | Source and resolved JFR rows, including rejected and unmatched observations, with their classification | always |
64-
| `jonoffcpu-matches.jsonl` | Cookies, clipped intervals, delivery delays and whether the target-to-JFR thread mapping could be verified | always |
65-
| `jonoffcpu-offcpu-stacks.collapsed` | Root-first signal-delivery stacks weighted in integer microseconds instead of sample counts; exact nanosecond durations remain in the report; no inverse-probability scaling | `--format both` (default) or `collapsed` |
62+
| `jonoffcpu-report.json` | Capture counters, classifications, handler-delay percentiles, interpretation notes, the degradation ladder and the opt-in population estimate | always |
63+
| `jonoffcpu-classified-records.jsonl` | Source and resolved JFR rows, including rejected and unmatched observations, with their classification | `--audit full` |
64+
| `jonoffcpu-matches.jsonl` | Cookies, clipped intervals, delivery delays and whether the target-to-JFR thread mapping could be verified | `--audit matches` (default) or `full` |
65+
| `jonoffcpu-offcpu-stacks.collapsed` | Root-first signal-delivery stacks weighted in integer microseconds instead of sample counts; exact nanosecond durations remain in the report; no inverse-probability scaling unless thinning applied (see **Degradation**) | `--format both` (default) or `collapsed` |
6666
| `jonoffcpu-offcpu-synthetic.jfr` | An explicitly synthetic CPU-compatible view, using duration-quantized `jdk.ExecutionSample` events | `--format both` (default) or `jfr` |
67-
| `jonoffcpu-complete.json` | Completion marker | last; a directory without it is not a complete analysis |
67+
| `jonoffcpu-complete.json` | Completion marker | last; a directory without it is not a complete analysis, and it is never written for a narrowed run (see **Degradation**) |
6868

6969
The original combined JFR is never rewritten. CPU, allocation, lock, wall and JVM
7070
events in it remain available to other tools. Both derived formats are produced by default. Use `--format collapsed` or
71-
`--format jfr` to select one. Reports and classified records are always retained.
71+
`--format jfr` to select one.
72+
73+
`--audit full|matches|none` controls how much per-row audit output is written.
74+
The CLI defaults to `matches`: `jonoffcpu-matches.jsonl` is written but
75+
`jonoffcpu-classified-records.jsonl` is **not**, which is a backward-incompatible
76+
change from earlier releases that always wrote both. Anything that reads
77+
`jonoffcpu-classified-records.jsonl` — including
78+
[`jonoffcpu-agent/tools/run-native-agent-interruptions.py`](../jonoffcpu-agent/tools/run-native-agent-interruptions.py)
79+
and
80+
[`jonoffcpu-native/tools/run-agent-signal-pressure.py`](../jonoffcpu-native/tools/run-agent-signal-pressure.py)
81+
— must now pass `--audit full` explicitly. `--audit none` writes neither audit
82+
file. The *library* API (`OffCpuCorrelator.correlate`, and `OfflineCorrelator`'s
83+
`OutputOptions.defaults()`) keeps the old `full` default, so embedding the
84+
correlator as a dependency is unaffected.
85+
86+
The audit outputs are produced by a second read of the same two files, so they
87+
describe the rows the correlation actually kept, not every row in the inputs. Under
88+
thinning or a narrowed window the re-read applies the same kept-row predicate the
89+
streaming pass did: `--audit full` then documents the kept subsample, row for row
90+
against the counters in the report, which is what an audit of a degraded run means.
7291

7392
Reading, selecting, and cutting existing events uses the public JDK
7493
`RecordingFile` API. The synthetic compatibility view has a different requirement:
@@ -122,6 +141,72 @@ missing Java stacks. Under `proportional`, a rare short interval that was admitt
122141
carries a weight of up to the full reference duration, so per-stack estimates for
123142
rare stacks are noisy even when the total is unbiased.
124143

144+
## Degradation
145+
146+
A profile is not an audit log. When a capture does not fit the retained-bytes budget,
147+
`--on-limit degrade` (the default) walks a ladder rather than refusing, and records
148+
every step in the report's `degradation` object:
149+
150+
1. **Coarsen the synthetic quantum.** The event count for a quantum is the sum of
151+
per-stack floors and is known before the first event is written, so the quantum is
152+
raised until it fits. A synthetic JFR renders totals the report states exactly, so
153+
this costs granularity, not time. `requestedQuantumNanos` and
154+
`quantumRaisedForEventLimit` appear in the report's `syntheticJfr` block.
155+
2. **Drop the audit outputs.** `--audit matches`, then `--audit none`. They cost the
156+
most and contribute nothing to the flame graph.
157+
3. **Thin the source and reweight.** Each recorded interval is kept with probability
158+
`q`, decided by hashing its cookie, and the duration it contributes is scaled by the
159+
exact reciprocal of the realised probability. The result is an unbiased estimate of
160+
the same per-stack totals over the whole requested window. Because the cookie is the
161+
join key, an observation and its JFR sample are dropped together, so every count in
162+
the report describes one coherent subsample. `--thinning <q>` pins it and
163+
`--thinning-seed` changes the draw; `q = 1` is the default whenever the input fits.
164+
4. **Narrow the window.** Analyse `[from, effectiveTo)` completely rather than the whole
165+
window approximately. Because both inputs are ordered on the delivery clock, a prefix
166+
is a complete analysis of a shorter window.
167+
5. **Fail**, naming the limit, the steps already tried and the flag that would allow the
168+
next one.
169+
170+
`--on-limit fail` restores the old behaviour. `--on-limit truncate` skips thinning and
171+
goes straight to narrowing.
172+
173+
The two degradations are labelled differently because they differ:
174+
175+
- **Thinning keeps the ordinary output names**, writes `jonoffcpu-complete.json`, and
176+
exits 0. The capture is already a sample of the intervals by design; a second sampling
177+
stage with a stated estimator covers the window that was asked for. The report carries
178+
`sourceThinning` with `q`, the seed, the exact realised probability and the estimator,
179+
and every collapsed line carries a `[thinned q=…; inverse-probability estimate]` root
180+
label so a rendered flame graph cannot be quoted without its caveat.
181+
- **Narrowing takes the `INCOMPLETE-jonoffcpu-*` names**, exits 2, writes
182+
`jonoffcpu-narrowed.json` instead of `jonoffcpu-complete.json`, and labels its
183+
collapsed lines with the effective window, because the result no longer answers the
184+
question that was asked. A reader that only checks the exit status and the presence of
185+
`jonoffcpu-complete.json` can already tell a statistically valid whole-window estimate
186+
(thinning, exit 0) apart from a result describing less than the window it asked for
187+
(narrowing, exit 2, `jonoffcpu-narrowed.json`).
188+
189+
Under thinning the collapsed weights are estimates rather than observed durations, so
190+
`--estimate-population`, which is an inverse-probability estimator over the kernel's own
191+
admission thresholds, is rejected together with an explicit `--thinning`, and is marked
192+
`unavailable` with `correlation-time-thinned-source` when the ladder applies thinning by
193+
itself. That asymmetry is deliberate. Asking for both on the command line is asking for
194+
two things that cannot both be honoured, and the CLI says so up front rather than
195+
handing back an estimate that is not the one requested. A ladder-chosen thinning is not
196+
a request: the run was asked to fit a budget, it thinned to fit, and the population
197+
estimate that is no longer computable is reported as `unavailable` with that reason
198+
instead of failing an analysis that otherwise succeeded.
199+
200+
The report's top-level `degradation` object is always present, even when nothing needed
201+
to degrade, so a consumer can see that degradation was considered and declined. It
202+
carries `policy`, `requestedAudit`, `audit`, `retainedBytesLimit`,
203+
`estimatedRetainedBytes` (from `RetentionEstimate`, computed from the input file sizes
204+
before decoding), `peakRetainedBytes` (what the run actually held at its high-water
205+
mark), `attempts`, the top-level `narrowedToNanos` (`null` unless the window was
206+
narrowed, mirroring `peakRetainedBytes` so a consumer that reads only the top-level
207+
object need not scan `stepsApplied` for the `narrow-window` entries), and `stepsApplied`:
208+
one object per ladder step actually taken, each with a `step` name and the reason.
209+
125210
## Interpretation
126211

127212
The cookie provides exact event association, **not simultaneous stack capture**.
@@ -148,13 +233,44 @@ not silently converted into matches.
148233
**source monotonic clock**, after joining the complete capture. These are not
149234
relative seconds or epoch timestamps. Either bound can be omitted. A matching
150235
handler event outside the interval still identifies an overlapping source interval.
151-
152-
Default admission limits are one million total source/JFR records, 1 MiB per
153-
source record, 4,096 frames per stack record and per JFR sample, and 256 MiB of
154-
conservative decoded-object accounting.
155-
Use `--max-rows` or `--max-retained-bytes` to change the corresponding limits.
156-
These are admission budgets, not a hard JVM heap limit. Failures reject the
157-
analysis rather than return a truncated successful result.
236+
`--from-ns`, `--to-ns` and `--max-handler-delay-ns` are held as signed `long`
237+
nanoseconds in the engine's columns, so each is rejected with `Time boundary
238+
outside signed 64-bit nanoseconds` when it is negative or at or above `2^63`;
239+
values in `[2^63, 2^64)` that an earlier release accepted now fail fast instead of
240+
wrapping.
241+
242+
Default admission limits are a hundred million total source/JFR records, 1 MiB per
243+
source record, 4,096 frames per stack record and per JFR sample, and a retained-bytes
244+
budget of sixty percent of `Runtime.maxMemory()`, never below 256 MiB. Use `--max-rows`
245+
or `--max-retained-bytes` to change them.
246+
247+
`--max-retained-bytes` charges what the correlator actually holds: the primitive
248+
columns, the cookie index, the interned JFR stacks and the few retained control
249+
objects. Retention is proportional to the number of *distinct stacks*, not to the
250+
number of recorded intervals — a capture of 1.12 million samples carrying 10,631
251+
distinct stacks holds one copy of each — so the guard is a usable steering signal
252+
rather than a proxy for input size. Roughly 80 bytes of retention per recorded
253+
interval, plus the interned stacks, is the figure to plan a capture against — it is
254+
the load-bearing number here. The scale fixture
255+
(`StreamingCorrelatorTest.scale`, 2,000,000 observations and a matching 2,000,000
256+
JFR samples) asserts a bound of 400 MiB on peak retained bytes and has measured
257+
comfortably inside it; the exact figure moves with the engine's structures and is
258+
not a number to plan against.
259+
260+
A real Pulsar broker capture (1,121,421 source rows, 890,086 matched, 10,631
261+
distinct Java stacks) measured 203 MiB (212,831,820 bytes) of peak retained
262+
bytes at `--audit full`, `--audit matches` and no `--audit` alike — about 190
263+
bytes per recorded interval, roughly 2.4x the 80-byte column-only figure above.
264+
Real JVM stacks are far deeper than the synthetic scale fixture's, so interned
265+
stacks account for the difference; treat 80 bytes/interval as a lower bound for
266+
the column storage alone, not the full per-interval budget, when planning
267+
against real captures.
268+
269+
Integrity failures still reject the analysis: a JFR whose size or digest differs from
270+
the footer, an observation referencing an unannounced stack, an async-profiler counter
271+
inconsistency, a duplicate cookie, a JFR/source target mismatch. These mean the two
272+
files do not describe the same capture, so no weight computed from them means
273+
anything. Volume limits behave differently; see **Degradation**.
158274

159275
## Library API
160276

Collapse file

‎jonoffcpu-correlator/build.gradle.kts‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/build.gradle.kts
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ val verifyRuntimeJar = tasks.register("verifyRuntimeJar") {
256256
val fixtureMains = mapOf(
257257
"SignalJfrExporter" to "io.github.lhotari.jonoffcpu.jfr.SignalJfrExporterTest",
258258
"OfflineCorrelator" to "io.github.lhotari.jonoffcpu.offline.OfflineCorrelatorTest",
259-
"PartialCorrelator" to "io.github.lhotari.jonoffcpu.offline.PartialCorrelatorTest"
259+
"PartialCorrelator" to "io.github.lhotari.jonoffcpu.offline.PartialCorrelatorTest",
260+
"PrimitiveStructures" to "io.github.lhotari.jonoffcpu.offline.PrimitiveStructuresTest",
261+
"StreamingCorrelator" to "io.github.lhotari.jonoffcpu.offline.StreamingCorrelatorTest"
260262
)
261263
val fixtureTasks = fixtureMains.map { (taskName, className) ->
262264
tasks.register<JavaExec>("test$taskName") {
@@ -269,6 +271,12 @@ val fixtureTasks = fixtureMains.map { (taskName, className) ->
269271
}
270272
}
271273

274+
// Spec acceptance 4: the scale fixture's assertion is the heap cap itself, so it must run under
275+
// exactly the bound it proves, not whatever heap the other fixtures happen to get.
276+
tasks.named<JavaExec>("testStreamingCorrelator") {
277+
jvmArgs("-ea", "-Xmx1g")
278+
}
279+
272280
val testCorrelatorPublicApi = tasks.register<JavaExec>("testCorrelatorPublicApi") {
273281
group = "verification"
274282
description = "Checks the published correlator JAR's dependency-free public API."

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.