GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — perf(derive): fill the partial through &mut instead of returning it by jdx · Pull Request #980 · jdx/usage Conversation
|
|
Caution Review failedAn error occurred during the review process. Please try again later. 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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Instruction counts
No instruction-count regression above 1%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes. Shadow comparisonParsing
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
`Partial` is the whole CLI's worth of accumulator — every command's fields
inlined, recursively — so at mise's scale it is 11KB. `read_argv`, `read` and
`parse_from` each returned one by value, and every hop was a memcpy of all of
it: four moves, and 87% of a parse spent copying a struct of which all but one
command's worth goes untouched.
`read_argv_into` and `read_into` take `&mut Partial` instead, so the entry point
builds the accumulator in the frame that will consume it and nothing moves it.
The by-value `read_argv` and `read` stay as wrappers over them, so no generated
API changes shape.
Measured with cachegrind against the mise shadow (211 commands, 711 flags), one
cold parse of `mise use -g node@20`:
before 63,822 instructions 92x fewer than clap
after 18,490 instructions 319x fewer than clap
One 11KB copy remains, the one that builds the partial: `Subcommands::Partial`
is a struct with a field per variant, so constructing it materialises every
command's accumulator whether or not that command was reached. Making it an
enum is the fix for that, and is a separate change.
Co-Authored-By: Claude Opus 5 <[email protected]>
Measured after `cargo build --release` over the whole workspace, which is what
`mise run perf` does. A `-p gate` build unifies fewer features and reports clap
14% cheaper; usage's own figure is the same either way.
6a3c613 to
4d08769
Compare
Greptile SummaryThis PR refactors generated CLI parsing to initialize
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness or security defects identified. The generated entry points continue to create a fresh accumulator, apply argv events, perform settings and post-binding work in the previous order, and expose no partially mutated state on errors. Important Files Changed
Reviews (1): Last reviewed commit: "perf(derive): fill the partial through &..." | Re-trigger Greptile |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
The report and the plan both still described a regression that was diagnosed and fixed on 2026-08-17, so the published figures understated the shipped parser by roughly 8x. Re-measured at mise's scale with the existing harness: 7,377 instructions against clap's 6.31M (855x) and 0.69us against 544us, so all three original gates still pass and by a wider margin than at launch. The interesting part is why the number moved, because the earlier text read the rise as the price of vocabulary and it was not. Two costs scaled with the whole CLI rather than with what was typed: `Partial` is the entire CLI's accumulator and was returned by value, so a parse copied 11KB four times and spent ~87% of itself copying (#980, 63.8k -> 18.5k), and `Subcommands::Partial` was a struct with a field per variant, so constructing it materialised all 211 commands' accumulators to fill one (#981, 18.5k -> 4.2k). Because the accumulator was copied per parse, every property the derive learned widened a struct already being copied, so ordinary growth arrived multiplied. The rest of the movement is the fixture rather than the parser, separated by measuring one parser against both: 4,907 against the pre-refresh spec and 7,377 against the current one, which #1142 refreshed from mise's real typed tree. Also corrects two stale claims. The plan said the ratio was unwatched and worth a gate, but CLAP_RATIO_FLOOR=80 has warned on a slide since af2495d. And the allocation note described `start` building every command's partial in the present tense, which #981 ended. The floor's own comment kept its history but no longer implies features caused the slide, since that is the wrong thing for the next reader to conclude. Co-Authored-By: Claude Opus 5 <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.