# Benchmarks

## Results

Measured 2026-12-04 on GitHub Actions ubuntu-latest, linux x64, AMD EPYC 9V74 80-Core Processor (4 threads), Node.js 24.22.3, yaml-language-server 2.0.0; oxyaml release build. Both servers get the same generated files and
the same Kubernetes Deployment schema; each number is the median of 5 sessions (`drive.mjs --runs 5`).
yaml-language-server validates 200 ms after an open or edit (`validationDelayMs`), which is included because an
editor waits for it too.

| Metric | oxyaml, small | yaml-language-server, small | oxyaml, big | yaml-language-server, big |
|---|---:|---:|---:|---:|
| Startup | **2.6 ms** | 230 ms | **2.8 ms** | 232 ms |
| Warm open → diagnostics | **1.7 ms** | 217 ms | **103 ms** | 1,064 ms |
| Edit → diagnostics | **0.3 ms** | 214 ms | **2.6 ms** | 1,040 ms |
| Completion | **0.6 ms** | 9.5 ms | **1 ms** | 81.1 ms |
| Hover | **0.3 ms** | 1.2 ms | **0.3 ms** | 1.7 ms |
| Peak RSS | **16.6 MB** | 123 MB | **91.4 MB** | 1,345 MB |

Small: 500 lines, 20 Deployments. Big: 50,000 lines, 2,000 Deployments in one multi-document file.
The [bench-gate workflow](../.github/workflows/bench-gate.yml) produces these numbers with
`node tools/bench/readme.mjs` and uploads [`benchmarks.json`](assets/benchmarks.json) with the rendered chart;
`node tools/bench/chart.mjs` redraws the README chart from it. On an Intel Core i7-2600 (2011) every number is
about 2–3× slower for both servers; the ratios stay the same.

## Performance budgets

Release targets for Linux x86-64 with a release build and the inputs from `tools/bench/gen.mjs`.
[`gate.mjs`](../tools/bench/gate.mjs) reads this table and fails when a median misses a budget; it runs in the
[bench-gate workflow](../.github/workflows/bench-gate.yml) on release tags.

| Metric | small (500 lines) | big (50k lines) |
|---|---|---|
| startup to initialize response | ≤ 10 ms | ≤ 10 ms |
| open → diagnostics (schema cached) | ≤ 15 ms | ≤ 250 ms |
| edit → diagnostics | ≤ 10 ms | ≤ 60 ms |
| completion / hover | ≤ 5 ms | ≤ 30 ms |
| peak RSS | ≤ 20 MB | ≤ 150 MB |
| `oxyaml check`, corpus files, schemas cached | at least 50× less wall time than the parity harness collecting yaml-language-server's diagnostics for the same files | |

Pull requests are guarded separately by instruction counts (`cargo bench -p oxyaml_benchmark`, the CI `bench` job).

## Reproduce the editor benchmark

From the repository root on Linux x86-64, use the toolchain in
[`rust-toolchain.toml`](../rust-toolchain.toml) and Node.js 24.

```sh
cargo build --release --bin oxyaml
node tools/bench/gen.mjs
node tools/bench/gate.mjs --json tools/bench/results/gate.json -- target/release/oxyaml --stdio
```

[`gen.mjs`](../tools/bench/gen.mjs) generates small and big files with 20 and 2,000 Kubernetes
Deployments, respectively. It fetches a pinned Kubernetes v1.33 Deployment schema if
`tools/bench/results/deployment.json` is missing.

[`gate.mjs`](../tools/bench/gate.mjs) runs five fresh sessions per file and reports medians.
It writes the measurements and budgets to `gate.json` and exits with status 1 if any budget is
missed. The JSON includes first-open times.

[`drive.mjs`](../tools/bench/drive.mjs) times startup through the initialize response, associates
the same Deployment schema with each file, and waits for diagnostics. A warm open is the second open in the same process, with
the compiled schema available. The edit time is the mean of ten incremental edits that alternate
valid and invalid `replicas` values. Completion and hover each time one request after the edits.
Peak RSS is Linux's process memory high-water mark (`VmHWM`). The report field `peakRssMB` holds
MiB because it divides the kernel's KiB value by 1,024.

## Run yaml-language-server

Install the pinned yaml-language-server and run it on the same inputs.

```sh
npm ci --prefix tools/oracle
node tools/bench/gen.mjs
for size in small big; do
  node tools/bench/drive.mjs --runs 5 "tools/bench/results/$size.yaml" tools/bench/results/deployment.json \
    -- node tools/oracle/node_modules/yaml-language-server/bin/yaml-language-server --stdio
done
```

## `oxyaml check` throughput

Recorded December 3, 2026 on Linux x86-64 with an Intel Core i7-2600 and Rust 1.100.1.
Each CLI run checked 4,202 files. The warm runs reused HTTP caches seeded by the cold runs.

| Cache state | Wall times |
|---|---:|
| Empty, two independent runs | 1.83 s, 19.27 s |
| Fresh, immediately after each cold run | 1.62 s, 1.72 s |
| Fresh, one additional run per cache | 1.52 s, 1.61 s |

The warm median was 1.615 s and peak RSS was 470–496 MiB. The same day's live LSP
comparison took 82 s across both servers and used 3,953 files. A direct comparison would use
the same files and time each server separately.

Use the same [corpus revisions](../tools/corpus/manifest.txt), a release build, and GNU time.
Run both cold/warm pairs followed by one repeat per cache. The configuration disables automatic
catalog lookups. Explicit schema references can still use the network and affect cold-run times.

```sh
cargo xtask corpus
cargo build --release --locked --bin oxyaml
mkdir -p target/check-bench
cat > target/check-bench/settings.toml <<'TOML'
[yaml.schemaStore]
enable = false

[yaml.kubernetesCRDStore]
enable = false
TOML

run_check() {
  XDG_CACHE_HOME="$1" /usr/bin/time -f '%e wall s, %M KiB peak RSS' \
    target/release/oxyaml check --config target/check-bench/settings.toml tools/corpus/data \
    > "$2"
}

cache_one=$(mktemp -d "$PWD/target/check-bench/cache.XXXXXX")
cache_two=$(mktemp -d "$PWD/target/check-bench/cache.XXXXXX")
for cache in "$cache_one" "$cache_two"; do
  run_check "$cache" "$cache/cold.txt"
  run_check "$cache" "$cache/warm.txt"
done
for cache in "$cache_one" "$cache_two"; do
  run_check "$cache" "$cache/repeat.txt"
done
```

The corpus contains invalid files, so the checker reports errors and exits with status 1.
To reproduce the separate LSP comparison, install the pinned yaml-language-server as above and run
the following command.

```sh
/usr/bin/time -f '%e wall s' node tools/parity/run.mjs --set full --category diagnostics --live \
  -- target/release/oxyaml --stdio
```
