fix(boot-profile): place profiler scratch under [cache].dir, not /tmp#86
Merged
Merged
Conversation
Follow-up to #85. The boot-set profiler's per-run scratch (write cache + foyer clean cache) was created via `tempfile::TempDir::new()`, i.e. in `std::env::temp_dir()` (`/tmp`). On hosts where `/tmp` is a tmpfs that runs the profiler's disk cache in RAM, and it makes correct placement depend on `$TMPDIR` being exported in the unit — the same operational fragility that caused the original incident. Make placement correct by construction: add `BootProfileOptions.scratch_dir` and thread the daemon's configured `[cache].dir` through `profile_base` into `capture_once`, which now creates its `TempDir` there. `None` preserves the old `std::env::temp_dir()` behavior for short-lived CLI callers (`glidefs profile` / `bless` / the bench bin), whose scratch is reclaimed on process exit anyway. Only the long-lived daemon (`router::start_profile`) sets it, to its `cache_dir`. This complements the #85 fd-close fix (which stops the leak); together the profiler scratch is both bounded and on disk, independent of `$TMPDIR`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #85.
Problem
The boot-set profiler's per-run scratch (write cache + foyer clean cache) was created with
tempfile::TempDir::new()→std::env::temp_dir()(/tmp). On hosts where/tmpis a tmpfs, that runs the profiler's disk cache in RAM, and it makes correct placement depend on$TMPDIRbeing exported in the unit — the same operational fragility that caused the original incident (#85).Fix
Make placement correct by construction:
BootProfileOptions.scratch_dir: Option<PathBuf>.[cache].dirthroughprofile_base→capture_once, which creates itsTempDirthere (TempDir::new_in).Nonepreserves the oldstd::env::temp_dir()behavior for short-lived CLI callers (glidefs profile,bless, the bench bin) — their scratch is reclaimed on process exit. Only the long-lived daemon (router::start_profile) sets it, tocache_dir.Complements #85's fd-close fix: together the profiler scratch is both bounded (closed before the dir is removed) and on disk (not tmpfs), independent of
$TMPDIR.Test
cargo check -p glidefs --features ublkandcargo check -p glidefsboth clean.