Skip to content

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

Merged
bong-water-water-bong merged 1 commit into
mainfrom
diag/holder-timeline
Nov 20, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
diag/holder-timeline

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #2478. Re-opened — closed on the 11-20 queue call while engine had nine non-draft PRs; engine is now at two, and this directly advances an open issue (#2478), so it is inside the rule again.

What it 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 cannot express — and the measurement that proves it is now on the issue:

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.

Why this matters for #2478 specifically

The issue's open question is which of several possible shapes the stream is. Three readings have been proposed and refuted by widening the window — "the hot pages persist", "episodes in sequence", "one owner's teardown" — and each time the refutation came from uniform computation over a different window. This is that computation, in a tool, so the next reading is not hand-arithmetic over an arbitrary --since.

The cluster structure it makes visible is the current best statement: a steady trickle (one isolated fault per address every 2–4 min for hours) plus occasional 4–7-fault bursts — two modes coexisting, which is why a single window can be dominated by either.

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 asserting 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 disagreed with my arithmetic 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 — 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:

  • Provides a tool to analyze fault timelines instead of just bursts
  • Measures and characterizes the faulting addresses and their persistence over time
  • Identifies the pattern of the fault stream (hours-long persistence, multiple overlapping addresses)

Non-compliant requirements:

  • Does not provide a definitive explanation for the root cause of the NVMe IO_PAGE_FAULT stream
  • Does not confirm or refute the hypotheses about the fault stream's origin (thermal, hardware, etc.)

Requires further human verification:

  • The root cause of the NVMe IO_PAGE_FAULT stream still needs to be determined
  • The tool's effectiveness in identifying the fault stream's origin needs further validation
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Timeline Analysis Logic

The new timelines() function processes observations to determine first, last, and count for each address, but it does not handle potential address collisions or duplicate entries correctly. If two different addresses map to the same internal representation, they could be incorrectly merged or treated as the same address, leading to incorrect timeline analysis.

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
Midnight Rollover Handling

The code handles midnight rollover for time calculations, but it assumes that all timestamps in the input are within a single day. If the input spans multiple days, the rollover logic may not work correctly, leading to incorrect time span calculations.

    span += 24 * 3600          # a syslog without a year rolls over midnight
out.append({"address": addr, "first": first, "last": last,

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 774c8a4: CHANGES — two defects, both in the new timelines(), and the first one breaks the quantity the tool exists to measure.

1. min/max on raw seconds-of-day loses the wrap, so a stream across midnight reports the complement of its span. Ordering the stamps before differencing means the if span < 0: span += 86400 line can never fire — last is already ≥ first by construction. Replayed with the function as written:

two stamps 23:00 and 01:00 (a 2 h stream across midnight)   -> reported span 22.0 h
two stamps 02:00 day 1 and 03:00 day 2 (a 25 h stream)      -> reported span  1.0 h

Your own measurement (00:10:04 -> 23:51:51, 23.7 h) is unmoved by this because it never crosses midnight — which is the half of the day where the bug is invisible. #2478's stream is NVMe faults over hours, and a stream that starts before midnight and ends after it is the ordinary case, so this will misreport the span and therefore the "longest-lived first" ordering. The fix I would take: unwrap against the first observation per address (t += 86400 while t < first), then difference; and keep the existing span < 0 guard for the pathological case where a single address wraps twice. A second address is not needed to see it — one address, two stamps, as above.

2. gap_seconds is dead. timelines(observations, gap_seconds=3600) never reads the parameter, and the call site passes gap_seconds=0; the docstring also promises a kept field the returned dicts do not have ({addr: (first, last, count, kept)} vs the four keys it builds). Either use it (a gap longer than gap_seconds between an address's faults is arguably a new episode, which is the distinction _gaps() already draws) or drop it — a parameter a reader has to assume is load-bearing is worse than no parameter.

What is right, and worth keeping exactly as it is:

  • the spread of the last stamps as the signal, with "the set STOPS TOGETHER (one owner)" only when the set actually does — that is the reading #2478 needed, and it is the one thing a burst summariser cannot express;
  • render_timelines([]) saying an empty capture is not evidence of no fault, which is the same rule summarize() already follows;
  • sort(key=(-span, -count)), and the per-address, order-independent aggregation — replaying a shuffled input gives the same rows.

Not checked by me, and not claimed: I did not run the tool against the real 2026-11-20 capture (it lives on the box that produced it, not in this repo), so the fixes above are proved on synthetic stamps of the same shape.

Two small fixes and this is READY; the tool is the right shape for #2478 and I would rather see it land than see it re-closed on the queue rule.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY on the shape, with two defects in timelines() that a driver shows in a few lines -- one dead argument and one unreachable correction

The idea is right and it is the answer to my own issue: a burst summariser answers "what happened in this second", and the 11-20 NVMe stream was hours per address. "Which pages are alive, how long, and do they stop together" is the question that stream actually poses.

Defect 1 -- gap_seconds is accepted, defaulted, passed, and never read.

118:def timelines(observations, gap_seconds=3600):
382:    rows = timelines(obs, gap_seconds=0)

and nothing in the body references it. Driven:

timelines(obs)                      == timelines(obs, gap_seconds=0)   True
timelines(obs)                      == timelines(obs, gap_seconds=60)  True

A parameter that reads as "how much silence ends a session" and does nothing is the same shape as the loom_or_iree_rev key that was initialised to "unknown" and never assigned (#2888): a reader will trust it. Either use it (split an address's timeline into sessions when the gap exceeds it -- that is the "do they stop together" question at a finer grain) or drop it.

Defect 2 -- the midnight-rollover correction is unreachable, so a stream that straddles midnight reads as ~24 h.

first, last, n = spans.get(addr, (t, t, 0))
spans[addr] = (min(first, t), max(last, t), n + 1)      <- min/max normalise the order
...
span = last - first
if span < 0: span += 24 * 3600                          <- therefore never fires

Driven with two faults 20 minutes apart across midnight (23:50 then 00:10):

0xa   count=2   span_s=85200  (1420 min)

The true span is 20 minutes; 85200 s is the complement. min/max make last >= first always, so the correction can only fire if a caller hands in a negative time, which the parser cannot produce. This matters for the numbers in the body's own table, which is a day of stamps: any address whose faults sit either side of midnight is reported at close to a day of "life" when it may have been alive for minutes.

Two ways to fix, and the second is the honest one:

  1. keep min/max and drop the rollover branch (then say a straddling address reads as a complement -- bad);
  2. keep insertion order, and when last < first add a day to the observations after the wrap, i.e. normalise on the way in so later stamps are t + 86400. That makes both the span and the "do they stop together" comparison correct across midnight, which is the whole point of the spread-of-last-stamps line.

What is fine: timelines() is pure and order-independent in the sense that matters (a caller may hand stamps in any order), the sort is longest-lived-first then most-faults, and a single-fault address reports span_s = 0 rather than being dropped.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 774c8a4: READY

The new half answers a different question from the old one, and its arms pin the two cases that could make the answer wrong: a spread of hours must NOT read as "stops together", and two addresses ending ten minutes apart MUST.

ok   the longest-lived address leads the timeline
ok   three addresses stay three, not merged
ok   each address keeps its own count
ok   the span is last minus first, per address
ok   no observations -> no timeline rows
ok   the block names its ordering
ok   a spread of hours is NOT reported as a set that stops together
ok   two addresses ending 10 min apart DO read as one owner
ok   an empty timeline says empty, not zero-length
self-test: 46 arms, ok                                               rc 0

The measured motivation is the reason this belongs in the tool rather than in another hand-written script: "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 the second question is the one that distinguishes one owner (a process exiting, an fd closing, a munmap) from independent pages. That is the discriminator #2478 and #2542 need.

Three details I would keep exactly:

  • span = last - first, with the midnight-rollover correction — a syslog without a year wraps, and span < 0 → += 24*3600 is the right fix rather than dropping the row. The same correction is applied to the spread of last stamps, which is where an unnoticed wrap would produce a spurious "STOPS TOGETHER" (spread would go sharply negative and pass the <= 120 min test after any naive absolute value).
  • gap_seconds still parameterised, so the same function serves the burst view (gap_seconds=0 in the arms) and the hour-scale view.
  • render_timelines([]) says "an empty capture is not evidence of no fault" — the same refusal the rest of this tool carries, in the place where an empty table would otherwise look like good news.

One nit, no action needed

The docstring's return shape says {addr: (first, last, count, kept)} while the function returns a list of dicts with span_s and no kept — the prose describes an earlier design. Worth one edit so a reader does not hunt for kept; the code is what the arms test.

(The CLI also prints "no amdxdna fault in 0 line(s) examined: nothing to capture (an empty capture is not evidence of no fault)" on an empty replay, which is the honest floor for this mode.)

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 774c8a4: READY

46 assertions, and they include the arms that must not fabricate an answer — which is the half that makes a diagnostic trustworthy.

$ python3 tools/diag/fault_burst_capture.py --self-test   -> ok      (registered as `fault_burst_capture_self`, CMakeLists:495)

chk(holders(proc) == [4242],                "only the fd under the prefix is a holder")
chk(holders(proc, self_pid=4242) == [],     "the caller is never named a holder")
chk(holders(proc, prefix="") == [],         "an empty prefix names nobody")
chk(holders(os.path.join(tmp, "nope")) == [], "a missing proc root names nobody")
chk(summarize([])["count"] == 0,            "an empty burst is countable, not an error")
chk(len(summarize(mixed_dev)["devices"]) == 2, …)      chk(len(summarize(mixed_dev)["flags"]) == 2, …)
chk(summarize(list(reversed(pages)))["stride"] == 0x1000, …)
chk(s["span"] == 9 * 0x1000,                "span is nine strides, not ten")
chk(m["repeats"] == 3,                      "three of those accesses repeat a page already faulted")
chk(parse_fault("… no domain …")["domain"] is None, "… not a fabricated 0")

The two that earn it: self_pid is never named a holder (the tool runs inside the very hold whose holders it snapshots, so the naive version reports itself as the culprit), and a missing/empty /proc root names nobody rather than answering with whatever was left over. Both are the "must not fabricate" shape the docstring promises, and both are pinned.

The measurement the docstring leads with is the right frame for the whole class: "ten faults in one second, ten consecutive 4 KiB pages, one flag word … one operation walking a contiguous range whose mapping is missing — not a stream and not ten clients", plus the two consequences (a one-second event cannot be attributed by a census minutes later; counting IO_PAGE_FAULT without flags merges classes that differ in the field saying what kind of access failed — amdxdna 0x0077 vs nvme 0x0000).

That last clause is the same distinction the accel-summary split (#2820) landed from the other side, so the two now agree: the total is meaningless without the flags, and the flags are what separate an NPU fault from an SSD one.

No notes: the parse and summary halves are pure and ordering-independent (reversed(pages) arms), the snapshot half is exercised against a fake /proc, and the tool is registered as a CI row rather than being a file nothing runs.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 774c8a4: READY

I ran the self-test and then tried to break it, and the attempt to break it is the interesting part.

python3 fault_burst_capture.py --self-test   ->  ok
span = last - first  ->  span = 0            ->  3 arms FAIL

The body claims span_s forced to 0 gives 2 FAILs; I measured 3. The direction is what matters — the mutation is caught, so the mutation-testing claim holds — and the count being off by one is worth saying, because a mutation count that is quoted rather than re-run is the same species as an arm that is named but never executed. I mutated line 135 (span = last - first); the body may have targeted a different assignment, or the tool gained an arm since.

My first two mutation attempts proved nothing, and that is the review

Attempt 1: sed 's/^\( *\)return .*span_s.*/\1return 0/' → 0 FAILs. I nearly wrote that up as "the mutation is not caught."
Attempt 2: cmp -s fbc.py mut.py → the mutant was byte-identical. The sed had matched nothing.
Attempt 3: span_s is a dict key, not a function — "span_s": span — so there was no def span_s to patch.

A mutation that does not apply produces exactly the same output as a mutation that applies and is not caught, and only cmp separates them. This is the third time tonight that a coarse check agreed with the wrong conclusion, and it is the same class as the arm that never runs: the test looked executed and was not.

What the PR does, and the two bugs its own arms caught

--timeline renders per-address first/last/count/span, order-independent, for the #2478 NVMe fault stream whose stamps span 1297.8 minutes. And it reports two defects found while writing it:

  • the "stops together" threshold compared seconds against a minutes constant — "so nothing could ever qualify": a unit mismatch that reads as a feature that never fires.
  • the author's own hand computation on #2478 used a shorter window and reported 4–5 h spans for the same addresses — the tool corrected the measurement that motivated it, which is the best thing a diagnostic can do and the rarest.

--self-test: 33 arms, including the measured 11-20 shape (five addresses, four long, one short), and mutations for the span and for the "together" threshold.

And the honesty about the queue

"Re-opened — closed on the 11-20 queue call while engine had nine non-draft PRs; engine is now [under]." A lane that records why its PR was closed and why it is back is a lane whose next closure will be read as a decision rather than as an accident.

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