Repository navigation
3.x.x: return a landing's freed heap to the kernel with malloc_trim after each block landing (#600) - #627
Conversation
…fter each block landing (#600) #600: every 400k-window block landing rebuilds the payout window and audit, about 1.4 GB of short-lived allocations, and glibc keeps what they free in its arenas. The landing frontend's resident set climbed with each landing to a 3.2-3.3 GB plateau while its live heap returned to about 250 MiB. - The frontend that landed calls malloc_trim(0) once the landing has released its rebuilt window, on the blocking thread that released it (OffRuntime gains a follow-up that runs after the drop): never on a runtime worker, never under a lock or a database transaction. glibc builds only; elsewhere it is a no-op that records nothing. - PRISM_LANDING_MALLOC_TRIM_ENABLED (default 1) turns it off; run, check-config and `candidates recover` read it, compose and .env.example pass it. - Metrics: qbit_prism_landing_malloc_trim_seconds (histogram), qbit_prism_landing_malloc_trim_released_bytes_total (resident set before minus after each trim) and qbit_prism_landing_malloc_trim_resident_bytes (the resident set after the latest trim). The resident set is read with the process collector's VmRSS parser, now shared. - Gated test landing_malloc_trim: three landings over a 20k-share production-shaped window through the real offer path; the resident floor after each landing's trim stays within 0.65 of the landings' resident burst. Trim off, the malloc_trim call removed and the follow-up removed each fail it; OffRuntime's test now fails a trim run before the drop. - Measured on the 400k two-frontend soak shape, two 30-minute runs each: landing frontends' cycle floors 0.55-0.69 GB with the trim against 1.35-2.54 GB without, peaks 0.75-1.64 GB against 1.44-3.17 GB; each trim 62-100 ms; no change in landing latency or share ACK tails. - Docs: landing memory per frontend and the memory limit to set (3 GiB at 400k with the trim, 5 GiB without), the capacity-readiness malloc_trim section, PRISM.md. Refs #600 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6fa59e5. Configure here.
Review ledgerCI is green on 6fa59e5: 23 checks passed, 11 skipped. Bugbot reviewed that commit and found no issues; no other review bot runs on this repo. Before the PR, the change went through a local review battery: New gated test in CI.
Also filed: #630, the |
Handover@kiwidream now owns this PR. State at 6fa59e5: CI is green, and the review ledger is posted above with no open items. Left to do: owner review and merge. The jemalloc follow-up is tracked separately in #628. |
…families Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ixed #600 (#714) The weekly 5.5 h soak at c95febb (run 37403129136), which includes #627's post-landing malloc_trim, passed every resident-memory row. load-fe-0 peaked at 1,026.9 MiB against a warm-up peak of 880.3 MiB (1.17x, window-peak slope +8.65 MiB/h), and load-fe-1 at 1,292.7 against 1,141.3 MiB (1.13x, -15.75 MiB/h). Every other gate passed too. The job failed only on the expected-failure marker, which reported that #600 looks fixed. So soak-weekly's rss_expected_failure goes back to null. The test in tests/soak_plan.rs now checks every preset with a soak block and every soak-gates file, at least four configurations, so an expected resident-memory failure can't come back in any of them unnoticed. docs/prism-soak.md now describes the marker generically and records #600's history with the first weekly run's margins. This changes only the harness preset, the test and the docs, with no server code. Refs #600. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rade's sidecar and FETCH_COUNT steps, and migrate-before-start From the review of the rc.2 notes: - Known issues now list what opened since rc.1 and isn't fixed here: #716 (a valid share can lose its credit on "commit gate closed" at a tip change; seen on the pair at rc.1), #711 (the order lock across about nine round trips), #712 (85-minute evidence export), #713 (verify-ca checks the host name) and #704 (a drill flake). - Upgrading from 2.0.x adds running the sidecar tool before import-audits and exporting the evidence with FETCH_COUNT. Upgrading from rc.1 says to run migrate first, because an rc.2 frontend refuses a database without 025. - #708's bullet says #710 also changes the evidence summarizer, which must be this candidate's on both sides of a cutover, and puts #710 next to the fix, not the refusal. - #600's fix (#627) was already in rc.1. The carried-over soak passed every gate, and its job failed only on the tripwire #714 removed. faults-long-real-node is not re-run here. - docs/prism-e2e-load-ci.md's example tag reads v3.0.0-rc.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rade's sidecar and FETCH_COUNT steps, and migrate-before-start From the review of the rc.2 notes: - Known issues now list what opened since rc.1 and isn't fixed here: #716 (a valid share can lose its credit on "commit gate closed" at a tip change; seen on the pair at rc.1), #711 (the order lock across about nine round trips), #712 (85-minute evidence export), #713 (verify-ca checks the host name) and #704 (a drill flake). - Upgrading from 2.0.x adds running the sidecar tool before import-audits and exporting the evidence with FETCH_COUNT. Upgrading from rc.1 says to run migrate first, because an rc.2 frontend refuses a database without 025. - #708's bullet says #710 also changes the evidence summarizer, which must be this candidate's on both sides of a cutover, and puts #710 next to the fix, not the refusal. - #600's fix (#627) was already in rc.1. The carried-over soak passed every gate, and its job failed only on the tripwire #714 removed. faults-long-real-node is not re-run here. - docs/prism-e2e-load-ci.md's example tag reads v3.0.0-rc.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #600
#600's investigation found that a 400k-window frontend's resident set ratchets up because glibc keeps memory, not because live data grows. Each block landing rebuilds the payout window and audit, about 1.4 GB of short-lived small allocations. glibc keeps what they free in its arenas. The landing frontend climbs to a 3.2–3.3 GB plateau while its live heap returns to about 250 MiB. This PR takes the investigation's zero-dependency fix,
malloc_trim(0)after each landing. jemalloc, the better long-term option, is filed as a follow-up (#628).What changes
land_offeredalready hands the rebuilt window toOffRuntime, which drops it on a blocking thread.OffRuntimegains a.thenfollow-up that runs on that same thread after the drop, and the landing's follow-up is the trim. So the trim runs:PRISM_LANDING_MALLOC_TRIM_ENABLED, default1.run,check-configandcandidates recoverread it. Compose and.env.examplepass it, and it is in the native settings inventory.qbit_prism_landing_malloc_trim_seconds(histogram): duration of each trim.qbit_prism_landing_malloc_trim_released_bytes_total(counter): resident set before minus after each trim.qbit_prism_landing_malloc_trim_resident_bytes(gauge): resident set right after the latest trim;-1before the first trim.VmRSSparser, now a sharedcollectors::resident_bytes. There is no second procfs parser and nounsafesysconf.prism-storage-sizing.mdgets a "Landing memory per frontend" section: the measurements below and the memory limit to set. That is 3 GiB per frontend at 400k with the trim (RSS warning 2.5 GiB) against 5 GiB without (warning 4 GiB). The capacity-readinessmalloc_trimsection,PRISM.mdand the metrics inventory are updated too.Measurements (400k soak shape, trim off and on)
Same release binary, trim off and on, two 30-minute runs of each, interleaved off/on/off/on. The shape is
soak-weekly's: two frontends, 400 sessions, 400k window, six blocks per run. Each run was pinned to four cores under the shared build lock. The harness was patched locally to pass the setting through, since it clears the frontend environment. Every run passed its gates: 6 of 6 blocks accepted, exact reconciliation.ALERT: offered candidate could not be processed … payout revision changed while observing chain stateappeared 4 times with the trim off and 4 times with it on, as in 3.x.x: a 400k-window frontend's resident set ratchets up with block landings to ~3.3 GB over a 5.5 h soak #600's own calibration run, so it is unrelated to the trim; filed as 3.x.x: a payout-revision race during the post-offer landing raises 'offered candidate could not be processed' about twice per 30 minutes #630.Tests
Gated
landing_malloc_trim(listed intest/prism-gated-tests.txt):Calibration. Debug build, whole test binary, on 2 and 18 cores:
malloc_trimcall, or no follow-up (10 runs): 0.82–1.0.Unit tests.
memory::tests: glibc-only support, default on, disabled records nothing, resident set read around the call.off_runtime_runs_its_follow_up_after_the_drop_on_the_same_blocking_thread: now reads the drop state from inside the follow-up, so a follow-up run before the drop fails deterministically.Mutants, each run against the listed test:
set_enabled(false)malloc_trimcall removed.then(...)follow-up removedOffRuntimeunit testThe trim-before-drop mutant fails the gated test only marginally, because that trim still returns the rest of the landing's garbage, so the unit test carries it.
Also run (after rebasing onto the current 3.x.x):
cargo test -p qbit-prism-server --lib(602 passed;rollups::tests::postgres_sql_cancellation_retains_success_and_rolls_backhit a lock timeout once under full-suite load and passed 3/3 alone), andlanding_metrics,offer_lifecycle,observability,config_cli,self_check_cli,candidate_window_switch,lost_race_pin, all green against a private PostgreSQL 16 withPRISM_TEST_REQUIRE_INTEGRATION=1.cargo fmt --checkandcargo clippy --workspace --all-targets -D warningsare clean, and so aregenerate_prism_metrics.py --check,check_prism_settings.pyand the docs/settings Python tests.Per-PR CI cost. One new test binary in a
prism-native-postgresshard. Its run takes about 15 s pinned to 2 cores (the shard runners are 2-vCPU), well inside the fixture's 45 s timeout, plus one test-binary build and link.Not in this PR
rss_expected_failure: "#600". They judge window peaks and 2x the warm-up peak, and a 400k landing still lifts the landing frontend by about 1 GB for a few seconds with the trim. So the gates cannot tell a returned transient from retention. If a weekly run with the trim passes every resident-memory row anyway, 3.x.x: report the weekly soak's resident-memory failure as expected on #600, and fail once it looks fixed (#600) #611's "3.x.x: a 400k-window frontend's resident set ratchets up with block landings to ~3.3 GB over a 5.5 h soak #600 looks fixed" row fails and says to drop the key. Judging per-cycle floors needs a new gate key and a bound calibrated on a full 5.5 h weekly run with the trim, so it is filed separately: 3.x.x: judge the weekly soak's resident memory on per-cycle floors, not landing-transient peaks (#600 follow-up) #629.🤖 Generated with Claude Code