Documentation
¶
Overview ¶
Package perf holds the pure, unit-testable helpers behind vix's performance benchmark tooling: synthetic on-disk corpus generation and the release-time gate that verifies the current commit was benchmarked before a release.
The orchestration (running `go test -bench`, invoking git and benchstat) lives in cmd/perftool; everything here is side-effect-light and covered by unit tests so the release gate and corpus shapes can't silently drift.
Index ¶
Constants ¶
const CorpusEnv = "VIX_PERF_CORPUS"
CorpusEnv is the environment variable the disk benchmarks read to locate the generated corpus root. When unset (or the corpus is missing) those benchmarks skip themselves rather than fabricate data.
Variables ¶
var BenchPackages = []string{
"./internal/daemon",
"./internal/daemon/brain",
"./internal/daemon/llm",
}
BenchPackages is the set of packages that carry Benchmark* functions. Both `make test-perf` and the smoke run drive exactly these.
Functions ¶
func GenerateCorpus ¶
func GenerateCorpus(root string, spec CorpusSpec) (written int, err error)
GenerateCorpus materializes spec under root/<spec.Name>. It is idempotent: a matching marker from a previous run short-circuits with written==0. A spec change (or a missing marker) triggers a clean regeneration. Files are fanned across up to 256 subdirectories so a single directory never holds the whole corpus. Content is deterministic (seeded per corpus name) so runs compare.
func PreviousResultFile ¶
PreviousResultFile picks the most-recent prior result from candidates (ordered newest-first, e.g. by git commit date), skipping the current commit's file and the frozen baseline. Returns "" when there is no prior result. Paths are returned verbatim from the input.
func ResultFileName ¶
ResultFileName returns the results filename for a commit hash.
Types ¶
type CorpusSpec ¶
type CorpusSpec struct {
Name string // subdirectory under the corpus root
NumFiles int // number of source files to materialize
FileSize int // approximate bytes per generated file
Exts []string // file extensions cycled through (e.g. ".go", ".py")
}
CorpusSpec describes one synthetic on-disk corpus for the disk benchmarks.
func DefaultCorpora ¶
func DefaultCorpora(huge bool, bigFileBytes int) []CorpusSpec
DefaultCorpora returns the standard benchmark corpora. bigFileBytes sizes each file in the "big" corpus (10 large files). When huge is true the "many" corpus is scaled to 1,000,000 tiny files — opt-in, since generating it is minutes of I/O and gigabytes on disk.
type GateResult ¶
GateResult reports whether a release may proceed and why.
func Gate ¶
func Gate(resultsDir, headCommit string, treeDirty bool) GateResult
Gate decides whether `make release` may proceed: the working tree must be clean (tracked files) and a results file for headCommit must already exist on disk (i.e. the developer ran `make test-perf` on this commit). It never touches git or the network — callers pass headCommit and treeDirty in.