Skip to content

build: trim dev-profile debuginfo to shrink target/ bloat#260

Open
mukeshblackhat wants to merge 1 commit intocoast-guard:mainfrom
mukeshblackhat:investigate/target-bloat-257
Open

build: trim dev-profile debuginfo to shrink target/ bloat#260
mukeshblackhat wants to merge 1 commit intocoast-guard:mainfrom
mukeshblackhat:investigate/target-bloat-257

Conversation

@mukeshblackhat
Copy link
Copy Markdown
Contributor

Summary

First step toward addressing #257 (target/ bloat). Trims dev-profile debuginfo workspace-wide:

  • [profile.dev] debug = "line-tables-only" — keep stack traces + panic line numbers, drop DWARF type/variable tables
  • [profile.dev.package."*"] debug = false — dependencies shed all debuginfo (we never debug into them)

Release profile is untouched on purpose — CI / release builds produce identical artifacts.

Measured impact

Reproducible on a fresh cargo clean, full workspace, on main vs this branch:

Stage Command BEFORE AFTER Saved %
1 cargo build --workspace 3.7 G 2.4 G 1.3 G −35%
2 + cargo test --workspace --no-run 6.4 G 4.3 G 2.1 G −33%
3 + cargo build --workspace --release 8.0 G 6.0 G 2.0 G −25%

Release portion is 1.6 G in both runs — the savings come entirely from target/debug/, exactly as intended.

Build times: roughly identical (within noise; debug-info emission is a small share of total compile time).

Why this doesn't break anything

debug = "line-tables-only" controls what debuginfo the compiler emits, not codegen. Same machine code, same symbols, same linking. Stack traces still pinpoint our source lines; panic messages still print the right file/line. The only thing lost is the ability to inspect local variables of a dependency in a debugger — which nobody does for tokio / axum / rust-embed etc.

Test plan

Anyone can reproduce the comparison locally:

# === BEFORE (on main) ===
git checkout main && git pull
cargo clean
cargo build --workspace                   ; du -sh target  # ~3.7 G
cargo test --workspace --no-run           ; du -sh target  # ~6.4 G
cargo build --workspace --release         ; du -sh target  # ~8.0 G

# === AFTER (this branch) ===
git checkout investigate/target-bloat-257
cargo clean
cargo build --workspace                   ; du -sh target  # ~2.4 G  ✅
cargo test --workspace --no-run           ; du -sh target  # ~4.3 G  ✅
cargo build --workspace --release         ; du -sh target  # ~6.0 G  ✅

# correctness
make lint   # ✅ zero warnings
make test   # ✅ all green
  • make lint — zero warnings
  • make test — all green
  • cargo build --workspace --release — succeeds, output unchanged (release profile not touched)
  • Disk usage measured BEFORE and AFTER on a clean target/ — numbers above

Out of scope (follow-up PRs, tracked in #257)

  • B. Narrow make watch from cargo build --workspace to cargo build -p coast-daemon
  • C. Extend make prune to also remove coast-service-dev-{cargo,target,docker} Docker volumes
  • D. CONTRIBUTING.md note on disk hygiene
  • E. Remove stale /target-cov entry in .gitignore (no code writes there)

Closes — none yet; refs #257, parent issue stays open until B–E land.


Reviewer note: per CONTRIBUTING.md, a Loom walkthrough of the change is required — I'll attach one once the PR is reviewed for correctness, since this is a config-only change with measured numbers above.

Set [profile.dev] debug = "line-tables-only" workspace-wide and
debug = false for all dependency packages. Stack traces + panic
locations are preserved for our crates; dependencies shed all
DWARF tables.

Measured impact (clean build of full workspace):
- workspace debug:        3.7G -> 2.4G (-35%)
- + test --no-run:        6.4G -> 4.3G (-33%)
- + release build:        8.0G -> 6.0G (-25%, release unchanged)

make lint and make test stay green.

Refs coast-guard#257
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