Skip to content

fix(cockpit-server): evict OSM slab from page cache after checksum hashing - #136

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/q2-osm-slab-fadvise-evict
Aug 16, 2026
Merged

fix(cockpit-server): evict OSM slab from page cache after checksum hashing#136
AdaWorldAPI merged 1 commit into
mainfrom
claude/q2-osm-slab-fadvise-evict

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

  • Second, separate finding from the same RAM investigation that produced osm lance: evict the slab mapping on warm reopen too, not just rebuild #135 (merged). osm_slab_hydrate.rs::ensure_slab_local re-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_file streams 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, before ensure_lance_local's own warm-check even starts — likely the larger of the two contributors to the observed Railway RAM pattern.
  • Fixed with posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED) after the streaming hash completes — the file-descriptor-read equivalent of MADV_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 by crates/quarto-mcp-launcher/src/delegate.rs.
  • libc was already locked transitively at 0.2.185, so declaring it as a direct dependency adds no new dependency tree — same move arc-swap made in osm lance: evict the slab mapping on warm reopen too, not just rebuild #135.

Test plan

  • TDD: wrote the test first, verified it fails without the fix (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.
  • RSS/cgroup memory accounting can't see page-cache eviction (same lesson as osm lance: evict the slab mapping on warm reopen too, not just rebuild #135/proc/self/statm can'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.
  • Full crate suite: cargo test -p cockpit-server --bin q2-cockpit — 162/162 passed (was 161; one new test), 0 regressions.
  • rustfmt --edition 2024 --check on 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).
  • Clippy comparison via 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.
  • Plan doc updated: 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 in q2).


Generated by Claude Code

…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
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 24f3448f-7991-43b4-b28a-8e1fca9a69aa


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review August 16, 2026 01:45
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@AdaWorldAPI
AdaWorldAPI merged commit 7490e70 into main Aug 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants