GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docs: correct the published parser performance numbers · jdx/usage@83fddf0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • PLAN.md
  • docs/rust
    • performance.md
  • tasks
    • perf-shadow.sh
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎PLAN.md‎

Copy file name to clipboardExpand all lines: PLAN.md
+39-20Lines changed: 39 additions & 20 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -931,19 +931,37 @@ checked-in `mise.usage.kdl` for both parsers.
931931
between parsers rather than between two transcriptions. Both shadows drop the
932932
same properties. Three release binaries — one per parser, one that does
933933
everything except parse — measured by `tak`, which gates the counts in CI.
934-
- [x] **Perf report** — at mise's full scale, a cold parse costs **50.9k instructions
935-
against clap's 5.96M: 117× fewer**, and **2.1µs against 490µs of wall clock**.
936-
_Re-measured later, and it moved:_ **60.4k against 5.90M — 97×**. clap is flat;
937-
our parse grew about 19% as the derive gained vocabulary, so the headroom under
938-
the <100k target went from 2× to 1.65×. Still passing, and nothing watches it:
939-
the shadow comparison is reported and never gated, on the grounds that the
940-
fixture grows on purpose. That reasoning holds for the absolute number and not
941-
for the _ratio_, which is a property of the two parsers. Worth a gate before the
942-
margin erodes further.
934+
- [x] **Perf report** — at mise's full scale, a cold parse costs **7,377 instructions
935+
against clap's 6.31M: 855× fewer**, and **0.69µs against 544µs of wall clock**.
943936
Measured by differencing two runs of the _same_ binary over how many parses it
944-
does, so nothing but the parse varies. clap's 490µs is 305µs building its command
945-
tree, ~160µs validating it, and ~24µs actually parsing — so even against clap's
946-
parse alone, with the tree already built and paid for, this is 12× faster.
937+
does, so nothing but the parse varies. clap's 544µs is ~343µs building its command
938+
tree, ~178µs validating it, and ~23µs actually parsing — so even against clap's
939+
parse alone, with the tree already built and paid for, this is 34× faster.
940+
**The count went 50.9k → 63.8k → 7,377, and the middle number is the instructive
941+
one.** The rise read as the price of vocabulary and was nothing of the kind. Two
942+
costs scaled with the size of the whole CLI rather than with what was typed.
943+
`Partial` is the entire CLI's accumulator — every command's fields inlined,
944+
recursively, 11KB at mise's scale — and `read_argv`, `read` and `parse_from` each
945+
returned one _by value_, so a parse copied it four times and spent ~87% of itself
946+
copying; `read_into`/`read_argv_into` take `&mut` (#980), 63.8k → 18.5k. Then
947+
`Subcommands::Partial` was a struct with a field per variant, so constructing it
948+
materialised all 211 commands' accumulators when 210 were unreachable by
949+
construction; it is an enum now (#981), 18.5k → 4.2k, the type 11,000 → 824 bytes
950+
and data refs 116,742 → 1,889. Because the accumulator was copied four times per
951+
parse, every property the derive learned widened a struct already being copied, so
952+
ordinary growth arrived multiplied. Removing the copies removed the multiplier:
953+
**metadata a parse does not read now costs a parse nothing**, which is the property
954+
the design claimed all along and only now actually has.
955+
The rest of the movement is the fixture, not the parser, and one parser against
956+
both fixtures separates them: **4,907 against the pre-refresh spec, 7,377 against
957+
the current one**, which #1142 refreshed from mise's real typed tree with more
958+
positionals and per-command metadata. clap moves ~7% across the same swap. usage
959+
moves more in proportion only because its own cost is now small enough that the
960+
fixture's shape dominates it — which is the permanent condition from here, and the
961+
reason the absolute number is worth less than the ratio.
962+
The ratio _is_ watched now: `CLAP_RATIO_FLOOR=80` in `tasks/perf-shadow.sh` warns
963+
when it slides (af2495da), so the earlier "nothing watches it" is answered. At
964+
855× the margin over that floor is about 10×.
947965
- [x] **Differential fuzzing** — proptest over argv on the mise spec, against
948966
usage-lib **and clap**. The three-way comparison distinguishes intentional usage
949967
defaults from regressions: unknown flags and scalar repeats are permissive unless a
@@ -956,18 +974,18 @@ checked-in `mise.usage.kdl` for both parsers.
956974
usage-lib resolves `mount run="mise tasks --usage"` by _running_ it, so the first
957975
draft spawned real `mise` processes that loaded config, fetched vfox metadata and
958976
shelled out to `apt-cache`. See `benches/gate/tests/differential.rs`.
959-
- [x] **Published performance report.** The Rust guide now records the original
960-
launch measurements, the later 19% instruction increase and reduced ratio,
961-
the absolute gates, the measurement method, and what the comparison does
977+
- [x] **Published performance report.** The Rust guide records the current
978+
measurements, the whole path the instruction count took and why it moved both
979+
ways, the absolute gates, the measurement method, and what the comparison does
962980
not include. It links the checked-in benchmark sources rather than
963981
presenting the numbers without a reproducible path.
964982

965983
Runtime targets, which gate:
966984

967985
| measurement | clap, measured | target | result |
968986
| ---------------------------------- | -------------- | ------ | ----------------- |
969-
| instructions, route + parse | 5.96M | < 100k | 50.9k, 117× |
970-
| wall time, argv to parsed struct | 490µs | < 50µs | 2.1µs, 238× |
987+
| instructions, route + parse | 6.31M | < 100k | 7,377, 855× |
988+
| wall time, argv to parsed struct | 544µs | < 50µs | 0.69µs, 788× |
971989
| heap allocations, successful parse | 6,560 | 0 | 0 bare, 3–4 bound |
972990

973991
All three gating targets are met, and not narrowly. Allocations were the last one owed:
@@ -977,9 +995,10 @@ costs three or four allocations, one per value. clap's tree costs **6,560** ever
977995
so this is about 2,000× fewer.
978996

979997
Getting there needed one fix and one correction. Defaults were being applied in `start`,
980-
which builds the partial for _every_ command in the CLI rather than the selected one, so a
981-
bare `mise` was allocating 60 times for defaults it would never read; they now run in
982-
`check`, guarded on whether the flag was given. And the counter itself was wrong — armed
998+
which at the time built the partial for _every_ command in the CLI rather than the selected
999+
one, so a bare `mise` was allocating 60 times for defaults it would never read; they now run
1000+
in `check`, guarded on whether the flag was given. (`start` no longer works that way either
1001+
— #981 made `Subcommands::Partial` an enum, for the instruction cost described above.) And the counter itself was wrong — armed
9831002
per thread but counting into a global — so parallel tests were counting each other and a
9841003
4-allocation parse read as 24, intermittently. usage-argv's own counter had the same
9851004
latent flaw and now counts per thread too.
Collapse file

‎docs/rust/performance.md‎

Copy file name to clipboardExpand all lines: docs/rust/performance.md
+45-15Lines changed: 45 additions & 15 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,54 @@ same binary.
1414

1515
| Measurement | usage | clap | Result |
1616
| -------------------------------------------- | ----: | ----: | --------------------: |
17-
| Retired instructions, route and parse | 50.9k | 5.96M | 117x fewer |
18-
| Wall time, argv to parsed value | 2.1us | 490us | 238x faster |
17+
| Retired instructions, route and parse | 7,377 | 6.31M | 855x fewer |
18+
| Wall time, argv to parsed value | 0.7us | 544us | 788x faster |
1919
| Heap allocations, no values bound | 0 | 6,560 | no parser allocations |
2020
| Heap allocations, three or four values bound | 3-4 | 6,560 | one per owned value |
2121

2222
The original launch targets were fewer than 100k retired instructions, less
23-
than 50us, and zero allocations when no value is bound. All three passed.
23+
than 50us, and zero allocations when no value is bound. All three pass.
2424

25-
A later measurement moved usage to 60.4k instructions while clap remained
26-
approximately flat at 5.90M, reducing the ratio from 117x to 97x. The parser is
27-
still comfortably under the absolute gate, but the change is reported because
28-
the ratio is useful evidence that vocabulary growth is not free.
25+
### How the instruction count moved
26+
27+
The number above is not monotone, and the shape of the curve is the useful part.
28+
It was 50.9k at launch, rose to 63.8k, and is now 7,377.
29+
30+
The rise looked like the price of vocabulary, and was not. Two costs scaled with
31+
the size of the whole CLI rather than with what the user typed:
32+
33+
- `Partial` is the entire CLI's accumulator, every command's fields inlined
34+
recursively, which is 11KB at mise's scale. `read_argv`, `read` and
35+
`parse_from` each returned one by value, so a parse performed four copies of
36+
it and spent about 87% of its instructions copying. `read_argv_into` and
37+
`read_into` take `&mut` instead: 63.8k to 18.5k.
38+
- `Subcommands::Partial` was a struct with a field per variant, so constructing
39+
it materialized all 211 commands' accumulators when 210 of them were
40+
unreachable by construction. It is an enum now, either `Unselected` or the one
41+
variant being filled: 18.5k to 4.2k, with the type itself falling from 11,000
42+
to 824 bytes and data references from 116,742 to 1,889.
43+
44+
Because `Partial` was copied four times per parse, every property the derive
45+
learned to express widened a struct that was already being copied, so ordinary
46+
vocabulary growth arrived multiplied. Removing the copies removed the
47+
multiplier: metadata a parse does not read now costs a parse nothing.
48+
49+
The remainder of the movement is the fixture rather than the parser. Measuring
50+
one parser against both fixtures separates them: the current parser scores 4,907
51+
against the pre-refresh spec and 7,377 against the current one, which now comes
52+
from mise's real typed command tree and carries more positional arguments and
53+
per-command metadata. clap grows about 7% across the same change. usage grows
54+
more in proportion only because its own cost is now small enough for the
55+
fixture's shape to dominate it.
2956

3057
## What clap's number includes
3158

32-
For this generated command tree, clap's approximately 490us consists of about
33-
305us constructing the tree, 160us validating it, and 24us parsing. usage's
34-
tables are compiled, so its 2.1us path has no equivalent construction or
35-
validation phase. Even compared only with clap's already-built parse phase,
36-
usage was about 12x faster in this measurement.
59+
For this generated command tree, clap's approximately 544us consists of about
60+
343us constructing the tree, 178us validating it, and 23us parsing. usage's
61+
tables are compiled, so its 0.7us path has no equivalent construction or
62+
validation phase. Even compared only with clap's already-built parse phase, with
63+
the tree constructed and paid for, usage is about 34x faster in this
64+
measurement.
3765

3866
## Method and limits
3967

@@ -45,9 +73,11 @@ usage was about 12x faster in this measurement.
4573
unsupported properties.
4674
- This measures routing and parsing, not process startup, configuration loading,
4775
command execution, help rendering, or completion generation.
48-
- The mise fixture grows over time. CI protects the absolute instruction target;
49-
this report also records the parser-to-parser ratio so regressions remain
50-
visible when the fixture changes.
76+
- The mise fixture changes over time, both by growing and by being refreshed
77+
from mise's current command tree, so one commit's count is not directly
78+
comparable with another's. CI protects the absolute instruction target, and
79+
`tasks/perf-shadow.sh` warns when the parser-to-parser ratio falls below 80x,
80+
which is the measure that belongs to the parsers rather than to the fixture.
5181

5282
The benchmark sources live in `benches/gate`, with generated shadows under
5383
`benches/shadows`.
Collapse file

‎tasks/perf-shadow.sh‎

Copy file name to clipboardExpand all lines: tasks/perf-shadow.sh
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ verify() {
7070
#
7171
# Not a gate — the workflow runs this with `|| true`, and a shared runner is no place to fail a
7272
# build on an instruction count. It is an annotation, because the alternative turned out to be
73-
# nobody noticing: the number went from 117x to 97x across a run of feature work, unremarked,
73+
# nobody noticing: the number slid from 117x to 81x across a run of feature work, unremarked,
7474
# because the only place it appeared was one line of a report nobody diffs. clap is flat, so the
7575
# movement was ours.
7676
#
77-
# 80 rather than 117: the point is to catch a slide, not to pin the current figure. A parse that
77+
# Worth knowing what that slide actually was, since it was read as the price of vocabulary and
78+
# was not: `Partial` is the whole CLI's accumulator and was returned by value, so a parse copied
79+
# 11KB four times, and `Subcommands::Partial` was a struct with a field per variant, so building
80+
# it materialised 211 commands' worth to use one. Fixing both took the ratio to 855x. Features
81+
# were never the cost — a struct sized by the whole CLI, copied per parse, was multiplying them.
82+
# So a future slide here is worth looking at structurally before it is blamed on vocabulary.
83+
#
84+
# 80 rather than 855: the point is to catch a slide, not to pin the current figure. A parse that
7885
# is only 80x cheaper than clap's has stopped being the thing this project claims, and that is
7986
# worth a sentence in the log before it is worth an argument about the target.
8087
CLAP_RATIO_FLOOR=80

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.