Skip to main content

Module bench

Module bench 

Source
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 check on 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§

Options
Options for run.

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_CONTEXTS contexts, 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 bench to print when record breaches the budget; None when 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, like edit_source, it moves the diagnostics so the client can see its own round. The signature edit edit_source makes is the pessimistic one for a cache.
edit_source
The one-line edit the benchmarks make: valid toggles 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). contexts independent contexts, each with groups groups of a refined type, a record, an agent with two handlers and an http service. Every file checks clean.
generate_project_shaped
generate_project for a given Shape.
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), p in 0..=100.
reading
One-line reading of a record, for the keystroke_latency probe: 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 bench when record reaches the scheduler trigger on either shape; None otherwise.