perf(cli): avoid color analysis for plain help - #1401
Conversation
Entire-Checkpoint: 01M1X60TB5A3BA1BC9G5SKS9Q7
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe changes centralize unexpected-flag diagnostics, avoid building help styling metadata for plain output, and add process-rendered help benchmarks for plain and colored styles. ChangesDiagnostics and Help Rendering
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Plain help rendering avoids unnecessary styling analysis while colored rendering and unexpected-flag diagnostics retain their existing behavior. Reported validation and coverage indicate no current merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Plain help currently builds the headings and spellings used to recognize colored spans, then discards them. Skip that work when color is disabled, and share the duplicated invalid-flag diagnostic formatting. Extend the timing tool to cover the process renderer in both plain and colored modes.
Paired local mise measurements: plain process help 42.15 → 34.68 µs (-18%), recursive help 4.88 → 3.36 ms (-31%). Colored help remains roughly unchanged. These are wall-clock measurements, not instruction counts.
Machine code shrinks by 2,896 B across the oxc binaries, but Mach-O alignment leaves only 32 B of combined on-disk savings. With the preceding size changes:
Same arm64 macOS / Rust 1.98.1 release configuration and strip/sign procedure as #1400, including the optional-feature/embedded-spec configuration from #1399.
Validation: the 733,411-byte help dump and 56 oxc process comparisons (plain and forced color) match exactly. Full Clippy, Rust 1.91, reduced-feature tests, formatting and spelling of added text pass. Full workspace tests: 2,725 passed; only the previously reproduced local zsh completion timeout failed.
Implemented with AI assistance.
Note
Low Risk
Output-preserving performance refactor in help and error formatting; behavior is validated by byte-identical help dumps and diagnostic tests.
Overview
Plain
--helpno longer builds the heading/flag/argument spellings used only to paint colored spans. Styled rendering still runshelp_structurewhenstyle.colouredis true; otherwise it passes an emptyHelpStructureso recursive and process help avoid that work without changing bytes on the wire.Invalid long-flag diagnostics are deduplicated into a shared
unexpected_flaghelper used for bothUnknownFlagand dash-prefixedUnexpectedArg, keeping the same clap-style message and Jaro-based tips.The help timing bench now measures process
render_styledin plain and colored modes alongside the existing paths.Reviewed by Cursor Bugbot for commit 1998067. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Bug Fixes
Performance
Tests