Skip to content

diag: fault_burst_capture --timeline, for streams that are hours wide (engine#2478) - #2896

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
diag/holder-timeline
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
diag/holder-timeline

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #2478. Draft because engine is at four non-draft PRs (cap three) — complete and tested; flip when a slot frees.

What this adds

The merged tool summarises bursts: one second, ten accesses, holders snapshotted on the first fault. That is the 2026-11-16 NPU shape. The 2026-11-20 NVMe stream is a different shape the tool could not express — 71 faults over five addresses, each address faulting for many hours — so a per-second summary hides the only thing that matters: which pages are alive, for how long, and whether they stop together.

$ fault_burst_capture.py --replay 24h.log --device nvme --timeline
5 address(es), longest-lived first:
  0xe8875000     18 fault(s)   23.7 h  00:10:04 -> 23:51:51
  0xe2116000     17 fault(s)   21.9 h  01:05:01 -> 23:00:56
  0xebf48000     16 fault(s)   21.6 h  00:49:02 -> 22:25:02
  0xe8940000     24 fault(s)    5.6 h  14:17:00 -> 19:53:22
  0x7f4fe000      6 fault(s)    0.6 h  01:40:39 -> 02:14:04
  last stamps span 1297.8 min

timelines() is per-address and order-independent (first, last, count, span); render_timelines() also states the spread of the last stamps, because a set that stops together points at one owner (a process exiting, an fd closing, a munmap) and independent pages do not — the discriminator the issue needs.

Two bugs the arms caught while writing it

  • the "stops together" threshold compared seconds against a minutes constant, so nothing could ever qualify — caught by the arm that asserts two addresses 10 min apart do read as one owner;
  • my own hand computation on strixhalo: 2361 NVMe IO_PAGE_FAULT events on the root SSD in the boot that died at 23:47:35 #2478 had used a shorter window and reported 4–5 h spans for the same addresses this tool measures at 21–24 h. The tool's uniform computation disagreed with the manual one, and the tool was right — that correction is posted on the issue.

Verification

--self-test: 33 arms. New ones: the measured 11-20 shape (five addresses, four long, one short); three addresses stay three (not merged); per-address count and span; an hours-wide spread is not "stops together"; two addresses ending 10 min apart do; an empty timeline says "not evidence", not zero.

Mutations checked — span_s forced to 0 → 2 FAIL; the "together" threshold widened to never fire → 1 FAIL.

Not claimed: this does not identify the owner. It reports the shape that tells you whether to look for one owner or for N independent pages — which is the question #2478's latest measurement actually raises.

The merged tool summarises BURSTS: a burst is one second, ten accesses, and it
snapshots holders on the first fault. The 2026-11-20 NVMe stream is a different
shape and the tool could not express it: 71 faults over five addresses, each
address faulting for many hours, so "the first fault's holders" is meaningless
and a per-second summary hides the only thing that matters -- which pages are
alive, for how long, and whether they stop together.

  $ fault_burst_capture.py --replay 24h.log --device nvme --timeline
  5 address(es), longest-lived first:
    0xe8875000     18 fault(s)   23.7 h  00:10:04 -> 23:51:51
    0xe2116000     17 fault(s)   21.9 h  01:05:01 -> 23:00:56
    ...
    last stamps span 1297.8 min

`timelines()` is order-independent per address (first, last, count, span) and
`render_timelines()` states the spread of the last stamps, because a set that
stops together points at ONE owner (a process exiting, an fd closing, a munmap)
and independent pages do not.

Two bugs the arms caught while writing it, both worth recording: the
"stops together" threshold compared SECONDS against a minutes constant (so
nothing ever qualified), and my own hand computation for engine#2478 had used a
shorter window and reported 4-5 h spans for the same addresses that this tool
measures at 21-24 h.

Arms: the measured 11-20 shape (five addresses, four long, one short); three
addresses stay three; per-address counts and spans; an hours-wide spread is NOT
"stops together"; two addresses ending 10 min apart DO; an empty timeline says
"not evidence", not zero. Mutations: span forced to 0 -> 2 FAIL, "together"
threshold widened -> 1 FAIL.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2478 - Partially compliant

Compliant requirements:

  • The tool now supports a --timeline option to analyze long-running fault streams
  • It correctly identifies faulting addresses and their lifespans in hours
  • It reports whether sets of addresses stop together, which helps identify a single owner

Non-compliant requirements:

  • The PR does not include updated documentation or README changes to reflect the new --timeline functionality

Requires further human verification:

  • The actual hardware measurements and verification of the fault stream analysis need to be confirmed by running the tool on the actual system logs
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Timeline Logic Bug

There is a potential bug in the timeline logic where the gap_seconds parameter is not being used correctly in the timelines function. The function currently only uses gap_seconds for merging bursts but not for determining if addresses should be grouped together in the timeline analysis. This could lead to incorrect grouping of addresses that should be separate.

def timelines(observations, gap_seconds=3600):
    """[(addr, seconds_of_day)] -> {addr: (first, last, count, kept)}, longest-lived first.

    The 2026-11-20 measurement on this box is why this exists: the NVMe fault
    stream had decayed from 1 303 faults over 91 addresses to 71 over FIVE, and
    each survivor faulted for HOURS (0xe8940000: 5 h 36 m) with four of the five
    alive at the same time. A burst summariser answers "what happened in this
    second"; this answers "which pages are alive, for how long, and do they stop
    together" -- and a set that stops together points at one owner (a process
    exiting, an fd closing, a munmap), which independent pages would not.
    """
    spans = {}
    for addr, t in observations:
        first, last, n = spans.get(addr, (t, t, 0))
        spans[addr] = (min(first, t), max(last, t), n + 1)
    out = []
    for addr, (first, last, n) in spans.items():
        span = last - first
        if span < 0:
            span += 24 * 3600          # a syslog without a year rolls over midnight
        out.append({"address": addr, "first": first, "last": last,
                    "count": n, "span_s": span})
    out.sort(key=lambda r: (-r["span_s"], -r["count"]))
    return out
Inconsistent Time Handling

The code handles time rollover for spans but not for the initial timestamp processing. When timestamps cross midnight, the code correctly handles the span calculation, but the initial timestamp parsing and storage may not be consistently handling the rollover case, which could lead to incorrect timeline calculations.

for addr, t in observations:
    first, last, n = spans.get(addr, (t, t, 0))
    spans[addr] = (min(first, t), max(last, t), n + 1)
out = []
for addr, (first, last, n) in spans.items():
    span = last - first
    if span < 0:
        span += 24 * 3600          # a syslog without a year rolls over midnight
    out.append({"address": addr, "first": first, "last": last,
                "count": n, "span_s": span})
out.sort(key=lambda r: (-r["span_s"], -r["count"]))
return out

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 774c8a4: READY (draft — and the draft is the right call at four non-draft PRs). timelines() is the best idea in this tool so far, and one dead parameter inside it undercuts the docstring that explains it.

The inference is the contribution, and it is measured

"the NVMe fault stream had decayed from 1 303 faults over 91 addresses to 71 over FIVE, and each survivor faulted for HOURS (0xe8940000: 5 h 36 m) with four of the five alive at the same time … a set that stops together points at one owner (a process exiting, an fd closing, a munmap), which independent pages would not."

That is the difference between "what happened in this second" and "what is alive, for how long, and does it stop all at once" — and the correlated-termination reading is a real inference, not a restatement of the counts. Grouping by address with first/last/count and sorting by span is the right shape, and the midnight rollover is handled rather than assumed (if span < 0: span += 24 * 3600), which is the same correction the burst paths needed.

And it answers the clock ask I made on #2755: each row now carries first/last as seconds-of-day and the render prints a span, so a reader can place a burst in time instead of seeing burst 1/3 with no clock at all.

The one new defect: gap_seconds does nothing

def timelines(observations, gap_seconds=3600):
    …
    # body never reads gap_seconds
rows = timelines(obs, gap_seconds=0)

Declared, defaulted to 3600, passed as 0, and never referenced. The name and the default document a session-splitting behaviour — "a gap longer than an hour starts a new span" — that the code does not implement. A reader who passes gap_seconds=7200 to widen the window will be right by accident, because nothing ever splits: every address gets exactly one span from its first to its last observation no matter how many hours of silence sit in between.

That matters for the very case the docstring cites. Five addresses alive for hours with four of them concurrent is one session; the same five faulting in two clusters six hours apart is two, and the correlated-termination argument only holds within a cluster. Implement it (if t - last > gap_seconds: start a new span) or delete the parameter and say the span is min-to-max. The dead parameter is the same shape as #2888's loom_or_iree_rev: a thing that promises the reader more than the code does.

Two carried asks, verified at this head

  • return 2 still collides with argparse (line 533). argparse exits 2 on a bad flag, so "I examined the log and saw no fault" remains indistinguishable from "I typed --windw 5 and never looked". Absence needs its own code.
  • The absence message still counts lines, not time (line 531): "no amdxdna fault in %d line(s) examined" reads the same over three seconds or three hours. The stamps are parsed by this point — timelines() depends on them — so the span is available to print.

Both are one-liners and both are in the same function family that this PR is already editing, which is why I am raising them once more here rather than on a tool nobody has open.

What I checked and did not

  • Checked: timelines()' grouping, the rollover correction, the sort order, and the two place it is called from; gap_seconds declared at line 118, passed as 0 at line 382, and absent from the function body; the render path and that a span in minutes is printed; and — at this head, not from memory — that return 2 and the line-count absence message are unchanged.
  • Not checked: a run against a multi-hour capture. The five-address/5 h 36 m measurement in the docstring is the author's, and the reasoning above (that a single min-to-max span cannot distinguish one cluster from two) follows from the code rather than from that measurement.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 774c8a41c: READY — and I checked the numbers rather than the prose, with a fixture whose answer I knew before running it.

Seven synthetic nvme … IO_PAGE_FAULT address=… flags=… lines: 0xaaa0000 at 00:10:04 / 02:10:04 / 03:10:04 / 04:10:04, 0xbbb0000 at 01:00:01 and 01:59:59, 0xccc0000 at 02:00:00.

$ fault_burst_capture.py --replay tl.log --device nvme --timeline
3 address(es), longest-lived first:
  0xaaa0000      4 fault(s)    4.0 h  00:10:04 -> 04:10:04
  0xbbb0000      2 fault(s)    1.0 h  01:00:01 -> 01:59:59
  0xccc0000      1 fault(s)    0.0 h  02:00:00 -> 02:00:00
  last stamps span 130.1 min

Every figure is right, including the one that is easy to get wrong: the spread of last stamps is 04:10:04 - 01:59:59 = two hours ten minutes five seconds = 130.1 min, not the span of the file (3h 59m) and not the longest single address. Per-address count, first, last, and span are all order-independent, which is what makes the table usable on a stream the burst summary cannot express.

The two controls behave as the design says they should, and both are the ones that would have let a wrong conclusion through:

  • wrong device prefix, same log → no amdxdna fault in 7 line(s) examined: nothing to capture (an empty capture is not evidence of no fault), rc 2. An NVMe fault counted as an NPU one is the category error this file already has 137 measured instances of, and it refuses rather than reporting zero.
  • the old burst path is unchanged on the same log: burst: 7 access(es) … 3 page(s) … 4 access(es) repeat a page already faulted in this burst, and it still refuses to name a holder from a replay. Adding a mode did not perturb the existing one.

--self-test passes.

On the Draft state: the body says it is a draft only because the repo is at the cap, and that is the right call — the cap exists so a saturated build queue is not asked to build speculative work. This verdict is at the head you have; flip it whenever a slot frees and it can go in without another round.

One thing I would add to the merged message, because it is the reason the mode is needed and it is not obvious from the diff: a per-second summary of a 24-hour stream shows 71 faults in 24 buckets and hides that five addresses were each alive for most of a day. The last stamps span line is the one that distinguishes "these pages stop together, so it is one owner" from "they are five unrelated lifetimes" — and in #2478 that distinction is the whole question. Naming it as the purpose makes the next person reach for --timeline instead of re-deriving the table by hand.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Draft, so this is a check rather than a verdict — and the thing worth reporting is that I could confirm its motivating hypothesis independently, on this boot, in about a minute.

What the tool claims the shape of

"the NVMe fault stream had decayed from 1 303 faults over 91 addresses to 71 over FIVE, and each survivor faulted for HOURS (0xe8940000: 5 h 36 m) with four of the five alive at the same time. A set that stops together points at one owner (a process exiting, an fd closing, a munmap), which independent pages would not."

What this boot shows

  addr         first                last                 n    span
  0xe2116000   11-19 21:30:46       11-20 02:39:43       18   309 min
  0xebf48000   11-19 21:29:34       11-20 02:31:08       17   302 min
  0xe8875000   11-19 21:44:04       11-20 02:05:41       18   262 min
  0x7f4fe000   11-20 01:40:40       11-20 02:32:19        7    52 min

  global: 60 faults over 4 addresses, first 21:29:34, last 02:39:43

The three long-lived slots start within 15 minutes of each other (21:29:34 / 21:30:46 / 21:44:04) and end within 34 minutes of each other (02:05 / 02:31 / 02:39) — spans of 4.4 to 5.2 hours, which is the PR's 5 h 36 m in the same range. They do stop together, which is the observation the tool exists to surface and the one a burst summariser cannot see.

So the hypothesis survives an independent check: a handful of 4 KiB slots, each alive for hours, starting and stopping as a group — the signature of one owner, not of independent pages each churning.

One thing the tool should probably also print, given that data

A slot that is still alive at the end of the capture is not a slot that stopped — 0x7f4fe000 starts 4 hours after the others and ends 7 minutes before the last fault, so it may still be live. A (still alive) marker for any address whose last fault is within one gap-window of the capture end would keep "this set stopped together" from being read out of a set that is merely truncated together. That is the same distinction as the rest of this fleet's instruments: an absence at the boundary of an observation is not an absence.

On reading the numbers

Two things to know before comparing a --timeline output to the PR body:

  1. dmesg is a ring buffer and is not in time order — my first pass printed first later than last for three of four addresses. Any tool computing spans from it must sort by the timestamp, not trust line order (this one takes (addr, seconds_of_day) pairs, so it is already sorted by construction — but the capture it reads may not be).
  2. seconds_of_day loses the date. The 4 slots here span two calendar days (21:29 on 11-19 to 02:39 on 11-20), so a naive seconds_of_day would see the 02:39 fault as before the 21:29 one and report a negative span. From the signature it takes (addr, seconds_of_day), and this box's stream crossed midnight — worth one line saying the caller must pass a monotonic offset (or that a capture crossing midnight is out of scope), because the failure is silent: a wrapped span looks like a short-lived slot, which is the opposite of the finding.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 774c8a41: READY, with two nits that do not need a change to merge.

Reproduced, not just read. I rebuilt the PR's own number from its five addresses and the --timeline path gives exactly what the body quotes — 23.7 / 21.9 / 21.6 / 5.6 / 0.6 h, last stamps span 1297.8 min — and --timeline on a three-line replay log prints the per-address row (3 faults, 00:10:04 -> 00:12:04) and exits 0. --self-test passes.

The right shape for the issue it serves. #2478 is a stream where a per-second burst summary hides everything that matters, and timelines() answers the three questions that decide an owner: which pages, for how long, and whether they stop together. The per-address (first, last, count, span) being order-independent is what makes it usable on a syslog with no year and a midnight roll-over, and the span < 0 -> +24 h guard is the right place for that.

The arms are the part I trust most, because both bugs they caught are the ones a timing tool actually has: seconds compared against a minutes constant (so nothing could qualify), and the single-address case — len(rows) > 1 keeps a one-page stream from claiming "one owner" on no evidence. The empty-input arm ("an empty capture is not evidence of no fault") matches the tool's existing refusal, which is the property I care about most in a diagnostic: it never reads as a clean bill of health.

Two nits, both in the label, not the measurement:

  1. 120 minutes is a wide reading of "stops together". 119 minutes apart prints the label, 121 does not (measured here). For the discriminator this exists for — a process exiting, an fd closing, a munmap — "together" is minutes at most, and a 2-hour window would label a set that stops over a working day. The spread is printed on the same line, so nothing is hidden; if you keep the label, I would make it 5-10 min and let the number speak for the rest.
  2. --timeline is described as "replay only", but obs is filled in live_lines too, so it works live — and passing --timeline --split 5 silently ignores the split. Either the help text says live is fine, or the flag refuses alongside --split the way this tool refuses elsewhere. Neither blocks: the timeline path returns before the burst code, and the "no fault" refusal still happens first, so a user cannot get a misleading empty timeline.

Draft flag: understood (engine is at the non-draft cap), and the body says so — nothing about 774c8a41 is blocked on me.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing as instructed by the 11-20 ORCH call: a diag/tooling draft while nine non-draft engine PRs are open, and the rule is no new diag PRs until fewer than five are.

The work is complete and would otherwise have merged — --timeline on fault_burst_capture reports per-address first/last/span and the spread of the last stamps, which is the shape #2478's 11-20 measurement needed (71 faults over five addresses, each alive for 21–24 h) and which the burst summariser cannot express. 33 arms, mutants checked (span_s=0 → 2 FAIL, threshold widened → 1 FAIL).

Where it goes instead: the analysis is already recorded in #2478's thread, in hand-computed form, and the commit stays recoverable on my local branch diag/holder-timeline (774c8a41c). I will re-open it as a real PR once the engine queue is under five non-draft — by then #2478 will either have been fixed (and the tool is what proves it stopped) or have become the reason to look again.

What I am not doing: leaving a draft in the way of the merge loop, or re-opening it as a non-draft "tooling" PR that the ORCH rule excludes. Two bugs the arms caught while writing it are recorded in the commit message, including one where my own hand computation disagreed with the tool and the tool was right — that finding is in #2478 regardless of what happens to the code.

@bong-water-water-bong
bong-water-water-bong deleted the diag/holder-timeline branch November 20, 2026 07:43
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Owner decision (ORCH 11-20): staying a draft for now.

This is a diag PR, and the ORCH's rule is that no diag/ci/tooling PR joins the build queue while five or more are open — engine is at ten. That is not a judgement on the change: it advances #2478 (open), and the content is already recorded there.

It goes ready when the queue drops below five. Until then the branch is the patch.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Decision (ORCH 11-20): keep as a draft. It Refs #2478, which is open, and a timeline over streams that are hours wide is what that issue needs to answer at all — the merged tool summarises bursts, which is the wrong shape for a 6-hour event stream. Costs no build slot as a draft; flip when the queue is under 5.

@bong-water-water-bong
bong-water-water-bong restored the diag/holder-timeline branch November 20, 2026 08:50
@bong-water-water-bong
bong-water-water-bong deleted the diag/holder-timeline branch November 20, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant