Expand description
Compile-time and editor-latency benchmarks (#3168).
cargo xtask bench generates a synthetic project of N contexts
(generate_project) and measures, against the release bynk and
bynk-lsp binaries:
cli_check—bynk checkon the project, a fresh process each run, so the compiler’s in-process caches are always cold;cli_recheck— the same after a one-line edit (a fresh process again: it shows whether anything survives between runs; today nothing does);lsp_first_round— open one file and wait for its diagnostics: the server’s first, cold project-wide round;lsp_edit— a one-line edit in an open buffer to the diagnostics for that version arriving: the edit-to-diagnostics time, warm (the content-keyed parse cache is populated by the first round).
The LSP leg runs with [lsp] diagnostics_debounce_ms = 0, so the figure is
the compute time; the shipped default debounce (300 ms) is added on top for
a user, and is not part of the budget question this measures.
Results are written per release to design/benchmarks/v<version>.json
(--record), not gated per PR: shared CI runners are too noisy for a
threshold. latest_record reads the newest one back for the
keystroke_latency probe in design/greenfield-status.md.
Structs§
Enums§
- Shape
- The two project shapes the benchmarks measure.
Constants§
- BUDGET_
CONTEXTS - The project size the budget is stated for.
- BUDGET_
P95_ MS - The accepted editor-latency budget (#3168, accepted by the maintainer):
the language server’s edit-to-diagnostics p95 stays under this many
milliseconds on the
BUDGET_CONTEXTS-context synthetic project. It is checked against each release record, not gated in CI. (The scheduler’s own trigger is separate:TRIGGER_P95_MS.) - EDITED_
FILE - The file the LSP benchmark edits, relative to the project root.
- GROUPS_
PER_ CONTEXT - How many agent/service/type groups each generated context holds.
- LEVELS
- R3.13’s four query levels, in the order the timing line reports them.
- RECORD_
DIR - Where the per-release results live, relative to the repo root.
- TRIGGER_
CONTEXTS - The project size the scheduler trigger is stated for.
- TRIGGER_
P95_ MS - The incremental-scheduler trigger (#1523, #3243): the scheduler decision is
reopened when the language server’s edit-to-diagnostics p95 exceeds this
many milliseconds at
TRIGGER_CONTEXTScontexts, on either project shape, in a release record. It was the trigger the scheduler (S2 of #3243) was first deferred on; the maintainer has since decided to build it, and this stays as the yardstick the slices are measured against.
Functions§
- budget_
warning - A warning for
cargo xtask benchto print whenrecordbreaches the budget;Nonewhen it is met or the size was not measured. - edit_
body - A body-only edit: a comparison inside a handler body becomes ill-typed
and back (
> 0)to> "x")). Nothing outside that body changes, so it is the edit an incremental analysis is meant to make cheap, and, likeedit_source, it moves the diagnostics so the client can see its own round. The signature editedit_sourcemakes is the pessimistic one for a cache. - edit_
source - The one-line edit the benchmarks make:
validtoggles a field’s type between a real one and an unknown name, so each edit changes the diagnostics and the client can tell its own round from a stale one. - generate_
project - The generated project:
(relative path, contents).contextsindependent contexts, each withgroupsgroups of a refined type, a record, an agent with two handlers and an http service. Every file checks clean. - generate_
project_ shaped generate_projectfor a givenShape.- latest_
record - The newest recorded result (highest version) under
root, with its version. - parse_
timing_ line - Parse
bynk-phase-timing file=1.0 unit=2.0 definition=3.0 project=4.0. - percentile
- Nearest-rank percentile of
samples(milliseconds),pin 0..=100. - reading
- One-line reading of a record, for the
keystroke_latencyprobe: the edit-to-diagnostics median at each measured size, smallest first. - record_
path - The path of the record for
version. - run
- Run every size and return the result document (not yet written anywhere).
- trigger_
warning - A warning for
cargo xtask benchwhenrecordreaches the scheduler trigger on either shape;Noneotherwise.