@@ -59,16 +59,35 @@ recognisable wherever the directory ends up. A successful run writes: |
59 | 59 |
|
60 | 60 | | File | Contents | Written when | |
61 | 61 | | --- | --- | --- | |
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` | |
66 | 66 | | `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**) | |
68 | 68 |
|
69 | 69 | The original combined JFR is never rewritten. CPU, allocation, lock, wall and JVM |
70 | 70 | 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. |
72 | 91 |
|
73 | 92 | Reading, selecting, and cutting existing events uses the public JDK |
74 | 93 | `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 |
122 | 141 | carries a weight of up to the full reference duration, so per-stack estimates for |
123 | 142 | rare stacks are noisy even when the total is unbiased. |
124 | 143 |
|
| 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 | + |
125 | 210 | ## Interpretation |
126 | 211 |
|
127 | 212 | The cookie provides exact event association, **not simultaneous stack capture**. |
@@ -148,13 +233,44 @@ not silently converted into matches. |
148 | 233 | **source monotonic clock**, after joining the complete capture. These are not |
149 | 234 | relative seconds or epoch timestamps. Either bound can be omitted. A matching |
150 | 235 | 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**. |
158 | 274 |
|
159 | 275 | ## Library API |
160 | 276 |
|
|