Skip to content

fix(build): cut continuum target/ from 42 GB to ~7 GB + shared cache across worktrees - #1556

Closed
joelteply wants to merge 1 commit into
canaryfrom
fix/cargo-target-bloat
Closed

joelteply wants to merge 1 commit into
canaryfrom
fix/cargo-target-bloat

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

42 GiB → 6.9 GiB for a single continuum-core debug build with metal+accelerate. One repo should not eat 40 GB.

Root cause

  • profile.dev default debug = 2 emits full DWARF for every dependency (llama.cpp, whisper.cpp, candle, bevy). We don't lldb-debug these; we debug via probes / RUST_LOG.
  • Every continuum worktree had its own target/ with identical compiled deps. 14 worktrees × duplicate deps = 99% disk on Joel's 466 GB machine.

What changed

  1. profile.dev now has:

    • debug = "line-tables-only" — panics still resolve to file:line, lldb variable inspection lost (we don't use it).
    • split-debuginfo = "unpacked" — .dSYM out of .o files so cleanup is one rm.
  2. start-server.sh exports CARGO_TARGET_DIR=$HOME/.continuum/cache/cargo-target before invoking cargo. Every continuum build across every worktree shares one cache. Cargo's [env] config doesn't expand ~ (issue #14149), so the script handles $HOME expansion. Operators can override per-shell for one-shot isolated builds.

Validation

cargo check -p continuum-core --features metal,accelerate from a clean shared-target succeeds in 9m 25s, ends at 6.9 GiB.

Test plan

  • Clean cache build measured: 6.9 GiB.
  • Binary builds with same features.
  • Re-run npm start to confirm the runtime still boots.

…across worktrees

ONE repo should not eat 40 GB. Today a single `cargo build` of
continuum-core with metal+accelerate features produced ~42 GB of
target/ artifacts, and N continuum worktrees each compiled their
own copy of identical deps (llama.cpp, whisper.cpp, candle, bevy).
14 worktrees × duplicate deps = 99% disk on Joel's 466 GB
machine, twice. Operator-time delete loops that he should never
have had to run.

Two structural changes, both measured:

1. `profile.dev` now has `debug = "line-tables-only"` +
   `split-debuginfo = "unpacked"`. Default `debug = 2` emits
   full DWARF (variable names, function args, line numbers) for
   EVERY dependency. We never actually rustc-debug llama.cpp via
   lldb; we debug via probes / RUST_LOG. Panics still resolve to
   the right file:line — only lldb variable inspection is lost.
   `unpacked` keeps .dSYM directories separate so they're easy
   to nuke. Empirical effect on continuum-core debug + metal +
   accelerate: 42 GiB → 6.9 GiB (83% reduction).

2. `start-server.sh` exports `CARGO_TARGET_DIR=$HOME/.continuum/
   cache/cargo-target` before invoking cargo. Every continuum
   build across every worktree drains into ONE cache instead of
   N copies. The existing `.cargo/config.toml` documents the
   shared-target pattern with `force = false` semantics; this
   commit moves it from documented-but-commented to live-by-
   default via the wrapper script, where shell `$HOME`
   expansion runs (cargo's [env] doesn't expand ~). Operators
   can override per-shell for one-shot isolated builds.

Validation: `cargo check -p continuum-core --features metal,
accelerate` from a clean shared-target succeeds in 9m 25s,
ends at 6.9 GiB.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
joelteply added a commit that referenced this pull request Jun 8, 2026
…bomb

Per Joel 2026-06-08: "When we have repeated things, like incrementally
improving it, we need to make sure we auto clean like this thing does
now and we reduced the extra gb. It was nearly full."

JsonlProbeFileSink was the next disk bomb waiting. `OpenOptions::append`
on a single file, no rotation, no cap — turn it on for a measurement
session, forget to turn it off, recreate the 3 GB blob problem that
PR #1547 fixed for the fmt-layer.

This applies the same doctrine to the probe sink:

- New constructor `JsonlProbeFileSink::new_rolling(dir, classes, max_log_files)`
  builds a `tracing_appender::rolling::Builder` with daily rotation +
  `max_log_files(N)`. Files land at `<dir>/continuum-probes.YYYY-MM-DD`.
  Disk usage bounded by design, not by operator discipline.
- New env var `CONTINUUM_PROBE_DIR` → rolling mode. Production default.
- Legacy `CONTINUUM_PROBE_FILE` still works but logs a one-line
  `tracing::warn!` pointing operators at the new var. Kept because
  some forensic captures genuinely want one continuous file across days.
- `from_env()` prefers `CONTINUUM_PROBE_DIR` (rolling) and falls back to
  `CONTINUUM_PROBE_FILE` (single-file + deprecation warn).
- `DEFAULT_MAX_LOG_FILES = 7` — same retention as the fmt-layer rolling
  so operators learn one number.
- `path()` deprecated in favor of `target()` — same field, clearer name
  since "target" can be a file or directory depending on mode.
- Storage swapped to `Mutex<Box<dyn Write + Send>>` so the hot-path
  write code is identical regardless of mode.

One focused integration test (`new_rolling_writes_to_dated_file_in_target_dir`)
walks the full lifecycle in a single test per Joel's "less tests with
more coverage" principle — construct, install as tracing layer, fire
probe, observe `continuum-probes.*` file on disk with the right
content. Regression here = the auto-clean doctrine silently falls back
to unbounded growth.

Doctrine memory: [[auto-clean-is-structural-not-operational]].
Structural fix pattern, not opt-in operational discipline. Same shape
the fmt-layer rolling and cargo target shrink (PR #1556) follow.

Same pattern next applies to: ~/.continuum/genome/ (4.2 GB unbounded),
persona recorder fixture output, sentinel checkpoint dirs. Each one is
a follow-up slice.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@joelteply

Copy link
Copy Markdown
Contributor Author

Closing: stale against the src/workers/ → core/continuum-core/ restructure — this is rework, not rebase, in migrated code. Branch preserved (not deleted); re-file/rework when picked up. Graveyard cleanup 2026-06-15 per Joel + M5 triage.

@joelteply joelteply closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant