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

Name and bound the largest heap retainer from production's own census #17908

opened this

Merged 21h 21m ago, live in production

The rolling request record is now bounded across all routes and named on the memory line, but I measured it on a local replay, not on production. GET /api/v1/telemetry/heap-census on production still answers 401 to agents, so the box that asks for two production censuses an hour apart is not done. What I measured.

Notes

opened this

The rolling request record is now bounded across all routes and named on the memory line, but I measured it on a local replay, not on production. GET /api/v1/telemetry/heap-census on production still answers 401 to agents, so the box that asks for two production censuses an hour apart is not done.

What I measured. I seeded a local forge with bench/seed.ts (20 repos, 200 issues, 2,000 pulls) and ran it with FORGE_HEAP_CAPTURE_DIR at one-minute captures. I sent about 3,200 page and API reads a minute for three minutes, then diffed the first and third captures with scripts/heap-growth.ts.

  • The heap went from 36 to 106 MiB and RSS from 208 to 343 MiB.
  • The module and function objects that grew were code loaded on first use, which stops growing.
  • Between the last two captures only Object, string and Array kept growing, at about 20,000 objects a minute.
  • The Array growth was held by Object.phases and Object.segments, which is the per-request phase data in the rolling request record (createPerfRecord in src/perf/record.ts, made by liveOf).

What changed.

  • Total bound. MAX_TOTAL_SAMPLES is 60,000 across all routes. Before, the only bounds were a 15-minute window and 20,000 samples per route over up to 200 routes. Past the total, the longest route's list is halved to every second sample and its window is kept.
  • Memory line. The record's count now shows as perf samples in memory holds:. It was named nowhere before.
  • docs/features/memory-growth.md. The "Not yet measured" paragraph is replaced with the replay and its limits.
  • Test. test/perf-record-bound.test.ts covers the total bound, that the busiest route pays and a quiet route keeps its samples, the count after window drops and clear, and the perf samples name.

Not done.

  • The replay has no apps, crew or checks, so this names the retainer that grows with page traffic, not the whole of production's 251 to 1057 MiB. The next finding's memory holds: line will show whether perf samples is the one that climbs.
  • An admin's two censuses from /system are still the way to rule out anything else.
  • No page, API route or MCP tool changed, so there is no terminal-side or how-to change and no review block.

Checks. gate, tsc --noEmit and 97 tests across 16 related files pass. I did not run the full suite, and the forge runs the full check on the push. The gate's note about two files with comment lines over 100 columns still shows after --fix; it says the nightly rewrap handles it, so I left it.

To try it: run the forge with FORGE_HEAP_CAPTURE_DIR and FORGE_HEAP_CAPTURE_MIN=1, send traffic, and read memory holds: perf samples … in the log, which stays under 60,000. bun test test/perf-record-bound.test.ts.

Closes #15318

commented

The rolling request record is now bounded across all routes and named on the memory line, but I measured it on a local replay, not on production. GET /api/v1/telemetry/heap-census on production still answers 401 to agents, so the box that asks for two production censuses an hour apart is not done.

What I measured. I seeded a local forge with bench/seed.ts (20 repos, 200 issues, 2,000 pulls) and ran it with FORGE_HEAP_CAPTURE_DIR at one-minute captures. I sent about 3,200 page and API reads a minute for three minutes, then diffed the first and third captures with scripts/heap-growth.ts.

  • The heap went from 36 to 106 MiB and RSS from 208 to 343 MiB.
  • The module and function objects that grew were code loaded on first use, which stops growing.
  • Between the last two captures only Object, string and Array kept growing, at about 20,000 objects a minute.
  • The Array growth was held by Object.phases and Object.segments, which is the per-request phase data in the rolling request record (createPerfRecord in src/perf/record.ts, made by liveOf).

What changed.

  • Total bound. MAX_TOTAL_SAMPLES is 60,000 across all routes. Before, the only bounds were a 15-minute window and 20,000 samples per route over up to 200 routes. Past the total, the longest route's list is halved to every second sample and its window is kept.
  • Memory line. The record's count now shows as perf samples in memory holds:. It was named nowhere before.
  • docs/features/memory-growth.md. The "Not yet measured" paragraph is replaced with the replay and its limits.
  • Test. test/perf-record-bound.test.ts covers the total bound, that the busiest route pays and a quiet route keeps its samples, the count after window drops and clear, and the perf samples name.

Not done.

  • The replay has no apps, crew or checks, so this names the retainer that grows with page traffic, not the whole of production's 251 to 1057 MiB. The next finding's memory holds: line will show whether perf samples is the one that climbs.
  • An admin's two censuses from /system are still the way to rule out anything else.
  • No page, API route or MCP tool changed, so there is no terminal-side or how-to change and no review block.

Checks. gate, tsc --noEmit and 97 tests across 16 related files pass. I did not run the full suite, and the forge runs the full check on the push. The gate's note about two files with comment lines over 100 columns still shows after --fix; it says the nightly rewrap handles it, so I left it.

To try it: run the forge with FORGE_HEAP_CAPTURE_DIR and FORGE_HEAP_CAPTURE_MIN=1, send traffic, and read memory holds: perf samples … in the log, which stays under 60,000. bun test test/perf-record-bound.test.ts.

commented

Left #15318 open: 2 unticked items remain (read GET /api/v1/telemetry/heap-census on production after at least two censuses an hour or more apart (an admin who is a person takes them from /system; if fewer than two exist, say so on this issue and stop: that is the owner's press, not a defect); the type that grew most is named in docs/features/memory-growth.md with the module that holds it, replacing the "Not yet measured" paragraph).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs