mirror of
https://github.com/bdbrown4/peltier.io.git
synced 2026-11-07 10:58:28 +00:00
Commit the spec and scaffold the system it describes:
- SPEC.md: the full v0.1 engineering spec
- crates/: trust-layer Rust workspace, unit-tested
- bench-runner: interleaved ABAB scheduling with discarded warm-ups,
deterministic bootstrap CIs over the ratio of medians,
CI-lower-bound accept rule, env fingerprinting, and a CLI with
compare + A/A self-test modes (A/A verified passing end-to-end)
- diff-test: gate outcome model, sha256 corpus pin verifier that
refuses on mismatch, per-target equivalence policy parser
(byte-identical default, explicit fp-tolerance opt-in)
- ledger: append-only SQLite attempt schema with UPDATE/DELETE
refused by triggers, anti-double-attempt query
- report: cores-saved and dollars/yr ROI math over speedup CIs,
pricing.toml inputs
- playbook/: classes 1-7 with preconditions, procedure, verification
notes, and known failure modes per class
- agent/: Python package skeleton — six-tool contract and prompting
spine, harness IPC deferred to Phase 1
- config/: accept.toml (2% threshold, 30 runs/side), pricing.toml
- targets/, corpora/, results/calibration/: layout and policy docs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2
2.1 KiB
2.1 KiB
Class 5 — Algorithmic
Complexity class and primitive selection. Highest variance: the biggest wins live here, and so do the most seductive wrong ideas.
Preconditions
- Profile signature: one dominant frame that is algorithm, not memory
(high IPC, low miss rate, still slow); superlinear scaling of runtime
with input size; hot
contains/findover linear structures; repeated recomputation of pure functions on repeated arguments.
Procedure (cheapest first)
- Better std/library primitive:
HashMapfor linear scans,sort_unstableoversort,entry()API over get-then-insert, buffered I/O,memchr-class scanning. - Precomputation: hoist invariant work out of loops; build lookup tables at startup when the domain is small.
- Memoization for pure hot functions with high argument repeat rates — confirm the repeat rate from a counting instrument before adding a cache.
- Complexity-class replacement (the real prize): O(n²) → O(n log n) with a known-correct algorithm. Prefer a well-tested library implementation over a hand-rolled one, always.
Verification notes
- HashMap iteration order is not deterministic order: if results flow from iteration order into output, replay diverges — either sort at the boundary or reject the change.
- Memoization + interior mutability in multithreaded targets touches the concurrency review tier (SPEC §8).
- Differential fuzz is load-bearing here: algorithmic replacements have edge-case surfaces (empty input, duplicates, already-sorted, unicode) where "equivalent" algorithms differ. 10k iterations minimum, seeded with corpus-derived cases.
Known failure modes
- Asymptotic win, constant-factor loss at real input sizes — the ledger records the workload; the verdict is measured at that workload.
- Caches without bounds: memoization that trades a 10% speedup for unbounded RSS growth. Check max RSS; bound the cache.
- "Equivalent" floating-point reformulations that aren't (different rounding paths) — FP output changes route to the tolerance policy or human review, never silently absorbed.