XPerf
LanguagesC

cperf evidence policy

Gate

A cperf rule may be documented / treated as error only if both exist under packages/cperf/evidence/:

  1. <slug>.md — claim, how measured, cc version / flags, limits
  2. <slug>.jsonl — ≥1 before/after line with fields rule, case, median_ms, ops, ratio, ts, plus cc (compiler and flags; node and v8 stay null). Optional role: before = smell, after = fix.

Otherwise the rule is at most hint.

Having JSONL is necessary but not sufficient: if measured agreement is only partial (static fire without wall-clock cost on common shapes), keep hint and document the negative in the md.

Current map

As of 2026-10-22.

RuleSeverityEvidenceVerdict
cp-alloc-hoterrorcp-alloc-hot.md · cp-alloc-hot.jsonlAgree ~10.8× malloc-in-loop vs arena
cp-realloc-grow-oneerrorcp-realloc-grow-one.md · cp-realloc-grow-one.jsonlAgree ~12.6× (companion case4 ~3×); direction clear
cp-printf-hotoff (default)cp-printf-hot.md · cp-printf-hot.jsonlHot unbuf/buf ~4.8× YES; G3 corpora almost-all OK-idiom/#if 0 → off; use --preset all or --severity cp-printf-hot=hint
cp-strlen-in-condhintcp-strlen-in-cond.mdabout 125× when the string might change; about 0.93× when -O2 hoists; stay hint
cp-strcat-hotoff (default)cp-strcat-hot.mdabout 221× versus an end pointer; stays off (G3)
cp-sprintf-hothintcp-sprintf-hot.md · cp-sprintf-hot.jsonlpending; not corpus-triaged
cp-fopen-hothintcp-fopen-hot.md · cp-fopen-hot.jsonlpending; not corpus-triaged
cp-gettime-hothintcp-gettime-hot.md · cp-gettime-hot.jsonlpending; not corpus-triaged; bare time is not matched
cp-wide-bool-flagshintcp-wide-bool-flags.md · cp-wide-bool-flags.jsonlJSONL present; stays hint; not corpus-triaged; four full-width flags, no bit-field
cp-regex-hothintcp-regex-hot.md · cp-regex-hot.jsonlabout 9.7×; stay hint; not corpus-triaged; regexec is not matched
cp-alloca-hothintcp-alloca-hot.md · cp-alloca-hot.jsonlstack cover 1280000 vs 64 bytes; wall clock about 1×; stay hint; not corpus-triaged; a VLA is not matched
cp-struct-by-valuehintcp-struct-by-value.md · cp-struct-by-value.jsonlabout 12.3× cross-TU at 512 bytes; same TU about 1×; stay hint; not corpus-triaged

Regenerating

bash packages/cperf/scripts/regen-evidence-cp001.sh
bash packages/cperf/scripts/regen-evidence-cp002.sh
bash packages/cperf/scripts/regen-evidence-cp003.sh
# optional correlation suite → examples/bench/build/static-vs-o2/
bash packages/cperf/scripts/run-static-vs-o2.sh

Update the matching <slug>.md medians if the ratio moves materially.

CLI presets

Default --preset app (and engine): cp-alloc-hot=error, cp-realloc-grow-one=error, cp-strlen-in-cond=hint, cp-sprintf-hot=hint, cp-fopen-hot=hint, cp-gettime-hot=hint, cp-wide-bool-flags=hint, cp-regex-hot=hint, cp-alloca-hot=hint, cp-struct-by-value=hint, cp-printf-hot=off and cp-strcat-hot=off. The off rules are the G3 2026-10-22 demotions. Hints are not corpus-triaged. cp-regex-hot, cp-alloca-hot, and cp-struct-by-value have JSONL and stay hint. An unknown slug stays hint.

--preset all elevates every rule to error for dogfood. Overrides: --severity RULE=error|hint|off.