项目文件夹

文件
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

59 行
2.1 KiB
Markdown

# Cold-index perf regression harness
A `go test` target that cold-indexes a small, fixed Go fixture through the real
indexer pipeline and guards against wall-clock regressions.
## What it measures
Each run constructs a fresh graph + indexer (the same `indexer.New` / `Index`
path the daemon uses) and cold-indexes `testdata/fixture`. Per pass it records:
- **wall-clock** — time for the `Index` call
- **allocated bytes** — `runtime.MemStats.TotalAlloc` delta across the pass
- **GC CPU fraction** — `runtime.MemStats.GCCPUFraction` (plus `NumGC` and
`PauseTotalNs` deltas)
It times several passes (`GORTEX_BENCH_INDEX_RUNS`, default 8) and keeps the
**minimum** wall-clock as the representative figure — the minimum is the most
stable estimator, since jitter only ever adds time. Only wall-clock is gated;
allocation and GC fraction are recorded so later GC-tuning and bulk-persistence
work can watch them move.
## The gate
The best wall-clock is compared against `testdata/baseline.json`. The test
fails when it exceeds the baseline by more than **15%**.
The baseline is recorded **without** the race detector. Under `-race`, time and
allocation inflate several-fold, so the harness prints the numbers but skips the
gate — `go test -race ./...` stays green.
## Running
```bash
go test ./bench/index-perf/ # measure + gate
go test -run ColdIndex -v ./bench/index-perf/ # print the numbers
```
## Regenerating the baseline
Run on the target machine after an intentional change:
```bash
GORTEX_BENCH_INDEX_UPDATE_BASELINE=1 go test ./bench/index-perf/
```
Commit the updated `testdata/baseline.json`.
## Knobs
| Env var | Effect |
| --- | --- |
| `GORTEX_BENCH_INDEX_UPDATE_BASELINE=1` | rewrite the committed baseline and pass |
| `GORTEX_BENCH_INDEX_FIXTURE=/abs/dir` | cold-index another tree instead of the fixture |
| `GORTEX_BENCH_INDEX_RUNS=16` | number of timed cold-index passes |
The fixture lives under `testdata/` so the Go toolchain (and `go test ./...`,
`go vet`, golangci-lint) ignores it, while the indexer still parses it because
the harness points the index walk directly at the directory.