Skip to content

build: optimize dependencies in dev builds#244

Merged
edwin-zvs merged 1 commit into
mainfrom
perf/optimize-dev-deps
May 25, 2026
Merged

build: optimize dependencies in dev builds#244
edwin-zvs merged 1 commit into
mainfrom
perf/optimize-dev-deps

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

Why

Investigating the multi-session TUI latency work (#241), the debug binary was dramatically slower than release — debug saturated the e2e benchmark (focused typing never settled within 30s under background floods) while release stayed at 2–7ms.

Root cause: the TUI's per-byte hot path — the PTY OSC/ANSI state machine (pty_render::feed_pty) plus the vt100 shadow parser — lives largely in dependency code, and at opt-level = 0 those un-inlined per-byte loops are ~10x slower. On a single-threaded feed+render loop racing the input rate, that constant factor is the difference between keeping up and backing up. The gap is widened further because [profile.release] here is tuned up (lto = "thin", codegen-units = 1).

Change

[profile.dev.package."*"]
opt-level = 3

package."*" applies only to dependencies, not workspace members — so our own crates keep compiling at opt-level = 0 (fast incremental rebuilds, full debuggability), while the dependency hot loops (vt100, parsers) get optimized. Release is untouched.

Measurement (multi_session_latency, debug)

under 4 flooding bg sessions
before SATURATED (>30s)
after ~4.7ms (~1.0x baseline)

Now matches release behavior.

CI impact

CI caches target/ via Swatinem/rust-cache, so the one-time cost of recompiling deps at opt-level = 3 is amortized across runs; the debug test phase itself runs faster afterward.

The TUI's per-byte hot path (PTY OSC/ANSI state machine + the vt100
shadow parser) lives largely in dependency code. At opt-level 0 those
un-inlined per-byte loops are ~10x slower — enough that a debug build
saturates the single-threaded feed+render loop under multi-session
load while release stays snappy.

Set opt-level = 3 for dependencies only (package."*" excludes
workspace members), so our own crates keep compiling unoptimized for
fast incremental rebuilds and full debuggability.

Measured (multi_session_latency, debug): focused typing under 4
flooding background sessions goes from SATURATED (>30s) to ~4.7ms
(~1.0x baseline), matching release. CI caches target/ via
Swatinem/rust-cache, so the one-time dep recompile is amortized.
@edwin-zvs
edwin-zvs merged commit 40152eb into main May 25, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the perf/optimize-dev-deps branch May 25, 2026 23:39
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