fix(cockpit-server): evict OSM slab from page cache after checksum hashing - #136
Conversation
…m hashing ensure_slab_local's cache-hit path re-verifies the raw slab's SHA-256 on every boot (deliberate — guards against a half-written file from a killed mid-download container). sha256_file streams the read, so it doesn't inflate process RSS, but every byte still passes through the kernel's page cache with nothing evicting it afterward — likely the larger of the two contributors to the observed Railway RAM pattern, since this runs first, unconditionally, before ensure_lance_local's own warm-check. Fixed with posix_fadvise(POSIX_FADV_DONTNEED) after the streaming hash completes — the file-descriptor-read equivalent of MADV_DONTNEED, gated #[cfg(unix)] with a documented no-op elsewhere. libc was already locked transitively at 0.2.185, so this adds no new dependency tree. Same testing lesson as the prior ensure_lance_local fix, applied without re-deriving it: RSS/cgroup accounting can't see page-cache eviction, so this uses a #[cfg(test)]-only reachability counter instead of a memory measurement, verified via the same revert/restore TDD cycle. 162/162 tests (was 161), 0 regressions. Clippy warning content verified byte-identical to the pre-fix tree via git stash comparison (68/0, 64/64 non-summary lines match). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NMeiLmtDKhomJNSo2ecbJw
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_3a1dbbf1-0572-43b5-8ea3-a7731ccb0eba) |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
osm_slab_hydrate.rs::ensure_slab_localre-verifies the raw slab's SHA-256 on every boot with a warm volume (deliberate — guards a half-written file from a killed mid-download container).sha256_filestreams the read, so it doesn't inflate process RSS, but every byte still passes through the kernel's page cache, and nothing evicted it afterward. This runs first, unconditionally, beforeensure_lance_local's own warm-check even starts — likely the larger of the two contributors to the observed Railway RAM pattern.posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED)after the streaming hash completes — the file-descriptor-read equivalent ofMADV_DONTNEED, gated#[cfg(unix)]with a documented no-op fallback elsewhere (.claude/rules/cross-platform.md), following the exact pattern already used in this workspace bycrates/quarto-mcp-launcher/src/delegate.rs.libcwas already locked transitively at0.2.185, so declaring it as a direct dependency adds no new dependency tree — same movearc-swapmade in osm lance: evict the slab mapping on warm reopen too, not just rebuild #135.Test plan
left: 0, right: 1), restored the fix, verified it passes — same revert/restore cycle as osm lance: evict the slab mapping on warm reopen too, not just rebuild #135./proc/self/statmcan't distinguish evicted-vs-dropped,/sys/fs/cgroup/*unavailable in this dev sandbox), so this uses a#[cfg(test)]-only reachability counter (FADVISE_ATTEMPTED) rather than a memory measurement.cargo test -p cockpit-server --bin q2-cockpit— 162/162 passed (was 161; one new test), 0 regressions.rustfmt --edition 2024 --checkon the touched leaf module — new code is clean; remaining diffs are pre-existing, out-of-scope lines this change never touched (crate-wide toolchain-baseline drift already documented in the plan doc).git stash:cargo clippy -p cockpit-server --no-deps --all-targets— 68 warnings / 0 errors on both the pre-fix and post-fix tree, and the actual warning content is byte-identical (64/64 non-summary lines match) — zero new findings.claude-notes/plans/2026-08-15-osm-lance-lifecycle.md§ "Found during the same investigation: a second, earlier eviction gap in the S3 hydrator".Still open (named, not attempted here): this fix stops the warm-check from leaving the slab resident, not from reading it on every boot. The "hot but idle" design (a bake-time sidecar digest a warm boot could check without touching slab bytes at all) remains the real fix for the read cost itself, and is a cross-repo change (bake in
openstreetmap-website-rs+ server inq2).Generated by Claude Code