Public: anyone can read this; the crew can change it.

Sentinel: memory-growth was degraded 12 minutes today: The forge's own memory is 4183 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… #16828

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A memory-growth finding now keeps its trip reading after memory drops back, and names the background jobs that grew the main heap up to the trip. This doesn't fix the spike itself. It means the next filing can name what caused it, and this one couldn't.

Notes

opened this

A memory-growth finding now keeps its trip reading after memory drops back, and names the background jobs that grew the main heap up to the trip. This doesn't fix the spike itself. It means the next filing can name what caused it, and this one couldn't.

Why the evidence was empty. RSS hit twice its first hour at about 14:23 and the issue was filed at 14:28:55. By then RSS was back to 1751 MiB and the main heap to 503 MiB. The watch threw away its trip snapshot the minute RSS fell under 1.25× the first hour, so every row read trip none. The only reading that saw the 3077 MiB heap was gone before the sentinel quoted it. That will keep happening with any short spike.

What changed

  • src/perf/memory_watch.ts: the last trip stays after the spike passes. Only a new spike that reaches twice the first hour replaces it; one that never gets there leaves it alone. The trip also stores the jobs that grew the main heap from the start of the spike (the first minute past 1.25×) to the trip, summed by name. At most 64 names are kept and the top 5 are printed. The evidence gets one more line: memory allocated by jobs from the run's start to the trip: …. If it says none counted, the heap grew in a request or after an await, not in a job, which also narrows the search.
  • src/boards/memory.ts: the minute sampler reads allocationsOf(app) once and passes it both to the watch and to the existing memory allocated by jobs log line. That read empties the tally, so reading it twice would lose data. I reused that existing tally rather than adding a new counter.
  • docs/features/memory-growth.md and the module header describe the kept trip and the new line.

Not done

  • No root cause yet. The spike's log lines and the heap census can't be reached from here: /api/v1/telemetry/heap-census answers 404 to this token. The next filing should name the job, or rule jobs out.
  • The mimalloc committed line is left as it is. It reads 484861 MiB next to a 1751 MiB RSS, so it's clearly not a real figure, but working out what it measures is a separate question.

Checks

  • Three new tests in test/sentinel-memory-evidence.test.ts: a spike that fell back still shows its trip figures and the jobs summed only up to the trip; a new spike replaces the old trip, one that never trips does not; a watch that never tripped names no jobs. The first two fail on the old code.
  • bun x tsc --noEmit is clean, and the 10 memory, sentinel, vitals and module-state test files pass (130 tests).
  • scripts/gate.ts --explain passes all 32 rules. The commit says No door: because only the sentinel's evidence lines changed.
  • scripts/fast.ts named 3718 test files, so I didn't wait on a full run; the forge's check covers that.

Try it: bun test test/sentinel-memory-evidence.test.ts. On the next memory-growth filing, the trip figures and the memory allocated by jobs line should be filled in even after RSS has fallen back.

🤖 Generated with Claude Code

Closes #16801

commented

A memory-growth finding now keeps its trip reading after memory drops back, and names the background jobs that grew the main heap up to the trip. This doesn't fix the spike itself. It means the next filing can name what caused it, and this one couldn't.

Why the evidence was empty. RSS hit twice its first hour at about 14:23 and the issue was filed at 14:28:55. By then RSS was back to 1751 MiB and the main heap to 503 MiB. The watch threw away its trip snapshot the minute RSS fell under 1.25× the first hour, so every row read trip none. The only reading that saw the 3077 MiB heap was gone before the sentinel quoted it. That will keep happening with any short spike.

What changed

  • src/perf/memory_watch.ts: the last trip stays after the spike passes. Only a new spike that reaches twice the first hour replaces it; one that never gets there leaves it alone. The trip also stores the jobs that grew the main heap from the start of the spike (the first minute past 1.25×) to the trip, summed by name. At most 64 names are kept and the top 5 are printed. The evidence gets one more line: memory allocated by jobs from the run's start to the trip: …. If it says none counted, the heap grew in a request or after an await, not in a job, which also narrows the search.
  • src/boards/memory.ts: the minute sampler reads allocationsOf(app) once and passes it both to the watch and to the existing memory allocated by jobs log line. That read empties the tally, so reading it twice would lose data. I reused that existing tally rather than adding a new counter.
  • docs/features/memory-growth.md and the module header describe the kept trip and the new line.

Not done

  • No root cause yet. The spike's log lines and the heap census can't be reached from here: /api/v1/telemetry/heap-census answers 404 to this token. The next filing should name the job, or rule jobs out.
  • The mimalloc committed line is left as it is. It reads 484861 MiB next to a 1751 MiB RSS, so it's clearly not a real figure, but working out what it measures is a separate question.

Checks

  • Three new tests in test/sentinel-memory-evidence.test.ts: a spike that fell back still shows its trip figures and the jobs summed only up to the trip; a new spike replaces the old trip, one that never trips does not; a watch that never tripped names no jobs. The first two fail on the old code.
  • bun x tsc --noEmit is clean, and the 10 memory, sentinel, vitals and module-state test files pass (130 tests).
  • scripts/gate.ts --explain passes all 32 rules. The commit says No door: because only the sentinel's evidence lines changed.
  • scripts/fast.ts named 3718 test files, so I didn't wait on a full run; the forge's check covers that.

Try it: bun test test/sentinel-memory-evidence.test.ts. On the next memory-growth filing, the trip figures and the memory allocated by jobs line should be filled in even after RSS has fallen back.

🤖 Generated with Claude Code

commented

A memory-growth finding now keeps its trip after RSS falls back to normal. It also names the background jobs that grew main's heap from the start of the run to the trip, and it no longer says jobs are ruled out when some of their memory measurements were skipped.

  • The first commit (65b28ff0e): the trip is the minute RSS first reached twice its first-hour average. It now outlives its run, and only a new run that trips replaces it. That matters because a twelve-minute spike has passed by the time the sentinel files it, and the trip is the only reading that saw it. The finding adds memory allocated by jobs from the run's start to the trip, the jobs that grew main's heap from the first minute past 1.25x up to the trip, largest first.
  • Review fix, item 1 (936d3bfe7): the jobs tally skips measuring some slices when reading the heap would take too long, and allocationsOf reports how many as skipped. src/boards/memory.ts now passes that count to the memory watch, which adds it up over the run and stores it with the trip. The finding line then ends (sampled: N slices not counted), the same wording the minute log line uses.
    • "none counted (a request, or work after an await, is not a job)" now appears only when no slice was skipped.
    • When slices were skipped and no job was measured, the line reads none measured (sampled: N slices not counted), so a job is not ruled out.
  • Review fix, item 2: docs/features/memory-growth.md now says the timestamp on the memory rss line is when the trip happened, not when the finding was filed, so a finding filed hours later can quote an old spike. It also explains the sampled suffix.
  • New tests in test/sentinel-memory-evidence.test.ts:
    • A run with no jobs and skipped slices both before and after the trip: the line counts only the slices up to the trip and does not claim jobs are ruled out.
    • A run with a counted job and skipped slices: the line names the job and the skipped count.

The 15 test files that cover the memory watch, the memory board and the jobs tally pass (145 tests), and bun x tsc --noEmit is clean. scripts/fast.ts named 3,718 test files for this change, over its time budget, so I picked those 15 myself. The gate passes; its only note is about an existing over-long comment line in src/boards/memory.ts.

The preview can't show this: the evidence is only built when a real memory spike trips. Opening /system shows the memory section unchanged, and the test file above produces the new lines.

[{"go":"/system","look":"the memory section","expect":"answers as before; the evidence lines appear only on a real trip, which test/sentinel-memory-evidence.test.ts drives"}]

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs