build: optimize dependencies in dev builds#244
Merged
Conversation
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.
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.
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 thevt100shadow parser — lives largely in dependency code, and atopt-level = 0those 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
package."*"applies only to dependencies, not workspace members — so our own crates keep compiling atopt-level = 0(fast incremental rebuilds, full debuggability), while the dependency hot loops (vt100, parsers) get optimized. Release is untouched.Measurement (multi_session_latency, debug)
Now matches release behavior.
CI impact
CI caches
target/viaSwatinem/rust-cache, so the one-time cost of recompiling deps atopt-level = 3is amortized across runs; the debug test phase itself runs faster afterward.