Skip to content

fix(boot-profile): place profiler scratch under [cache].dir, not /tmp#86

Merged
jaredLunde merged 1 commit into
mainfrom
fix/boot-profiler-scratch-on-cache-dir
Jun 27, 2026
Merged

fix(boot-profile): place profiler scratch under [cache].dir, not /tmp#86
jaredLunde merged 1 commit into
mainfrom
fix/boot-profiler-scratch-on-cache-dir

Conversation

@jaredLunde

Copy link
Copy Markdown
Contributor

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 /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 (#85).

Fix

Make placement correct by construction:

  • Add BootProfileOptions.scratch_dir: Option<PathBuf>.
  • Thread the daemon's configured [cache].dir through profile_basecapture_once, which creates its TempDir there (TempDir::new_in).
  • None preserves the old std::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, to cache_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 ublk and cargo check -p glidefs both clean.

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>
@jaredLunde jaredLunde merged commit d5ff270 into main Jun 27, 2026
36 of 39 checks passed
@jaredLunde jaredLunde deleted the fix/boot-profiler-scratch-on-cache-dir branch June 27, 2026 19:28
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.

1 participant