From fd5bbae8e275713d25bca205a7137a6e5f192eaf Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Fri, 30 Oct 2026 11:33:39 +0000 Subject: [PATCH] perf(research): cache Hamming tail envelopes in complete caller --- research/cached-hamming-tail/PROFILE.txt | 24 + research/cached-hamming-tail/PROOF.md | 89 +++ research/cached-hamming-tail/README.md | 147 ++++ research/cached-hamming-tail/SOURCES.json | 36 + research/cached-hamming-tail/TASK.json | 61 ++ .../TIMINGS-CONFIRMATION.json | 714 ++++++++++++++++++ .../cached-hamming-tail/TIMINGS-INITIAL.json | 330 ++++++++ research/cached-hamming-tail/VERIFY.json | 50 ++ research/cached-hamming-tail/benchmark.py | 99 +++ research/cached-hamming-tail/kernel.py | 74 ++ research/cached-hamming-tail/source.py | 31 + research/cached-hamming-tail/timing_check.py | 76 ++ research/cached-hamming-tail/verify.py | 148 ++++ 13 files changed, 1879 insertions(+) create mode 100644 research/cached-hamming-tail/PROFILE.txt create mode 100644 research/cached-hamming-tail/PROOF.md create mode 100644 research/cached-hamming-tail/README.md create mode 100644 research/cached-hamming-tail/SOURCES.json create mode 100644 research/cached-hamming-tail/TASK.json create mode 100644 research/cached-hamming-tail/TIMINGS-CONFIRMATION.json create mode 100644 research/cached-hamming-tail/TIMINGS-INITIAL.json create mode 100644 research/cached-hamming-tail/VERIFY.json create mode 100644 research/cached-hamming-tail/benchmark.py create mode 100644 research/cached-hamming-tail/kernel.py create mode 100644 research/cached-hamming-tail/source.py create mode 100644 research/cached-hamming-tail/timing_check.py create mode 100644 research/cached-hamming-tail/verify.py diff --git a/research/cached-hamming-tail/PROFILE.txt b/research/cached-hamming-tail/PROFILE.txt new file mode 100644 index 0000000000..1de656c44e --- /dev/null +++ b/research/cached-hamming-tail/PROFILE.txt @@ -0,0 +1,24 @@ + 493367 function calls (486018 primitive calls) in 0.079 seconds + + Ordered by: cumulative time + List reduced from 22 to 18 due to restriction <18> + + ncalls tottime percall cumtime percall filename:lineno(function) + 1 0.000 0.000 0.079 0.079 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:130(search) + 7350/1 0.006 0.000 0.079 0.079 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:136(visit) + 7350 0.004 0.000 0.070 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:114(reject) + 4434 0.009 0.000 0.035 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:42(tail_envelope) + 4896 0.010 0.000 0.029 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:75(union_reject) + 19817 0.011 0.000 0.017 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:47() + 15054 0.016 0.000 0.016 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:18(pair_support) + 62363 0.008 0.000 0.012 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:77() + 307110 0.011 0.000 0.011 0.000 {method 'bit_count' of 'int' objects} + 7350 0.001 0.000 0.002 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:71(remaining_reject) + 28519 0.001 0.000 0.001 0.000 {built-in method builtins.len} + 7349 0.001 0.000 0.001 0.000 {built-in method builtins.max} + 9792 0.001 0.000 0.001 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:25(choose2) + 7350 0.000 0.000 0.000 0.000 /Users/nick/git/imb-research-12/research/five-label-prefix-completion/bounds.py:13(require) + 2141 0.000 0.000 0.000 0.000 {built-in method builtins.min} + 1656 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} + 828 0.000 0.000 0.000 0.000 {method 'bit_length' of 'int' objects} + 2 0.000 0.000 0.000 0.000 {built-in method builtins.sorted} diff --git a/research/cached-hamming-tail/PROOF.md b/research/cached-hamming-tail/PROOF.md new file mode 100644 index 0000000000..41463c843a --- /dev/null +++ b/research/cached-hamming-tail/PROOF.md @@ -0,0 +1,89 @@ +# Exact cached Hamming envelopes + +This is an implementation-equivalence proof for the shared-tail predicate of +SHIN09-git's PR6046. The predecessor's completion theorem and canonical caller +remain cited premises. No predecessor mathematical claim is audited here. +The new contribution was produced by Nick Petalas. Apache-2.0. + +Let P be the distinct visited vertices, with last vertex q in P. Let r be the +remaining edge budget. Write D(P) for the nonzero pair differences and define + +``` +H(q,r) = {x : weight(q XOR x) + weight(x) <= r} +U = H(q,r) minus P. +``` + +The source's already simplified exact envelope is + +``` +E = D(P) union {p XOR x : p in P, x in U}. +``` + +The following identity removes the prefix-dependent exclusion from the support +calculation, while retaining it in the future-vertex count: + +``` +E = (D(P) union union_(p in P) (p XOR H(q,r))) minus {0}. +``` + +To prove inclusion from left to right, use U subset H. For the reverse inclusion, +consider an added x in H intersect P. For every p in P, p XOR x belongs to D(P) +unless p=x, in which case it is zero and is removed. Thus the larger cached set +adds no nonzero difference. This identity holds for arbitrary distinct vertices; +it does not require the path condition used by the source's completion theorem. + +`tables` enumerates H for all 32 endpoints and all budgets 0 through 12. For each +distinct mask it computes all 32 XOR translations. A bitset stores membership +of vertex x at bit x. At coordinate i, XOR by 2^i exchanges the two halves of +each consecutive block of 2^(i+1) bit positions. `translate` performs that +exchange by two masks and shifts. The five coordinate exchanges commute, and +their product is exactly x maps to x XOR p. All masks have at most 32 bits. + +For a validated source prefix, `envelope` forms U by `reach & (ALL XOR seen)`. +It ORs the precomputed translations for every old vertex into the literal +source pair support, then removes zero. Consequently both U and E equal the +source outputs exactly. The necessary conditions `|U| >= 12-|P|` and +`E = all nonzero masks` therefore return the same decision at every prefix. + +The adapter retains the source's remaining-label and parity-union checks in +their original order. It changes only the subsequent shared-tail test in +`two_without_cap`. The source traversal, child order, simple-prefix gate, +closing-edge test and final word checks are unchanged. Induction along that +same traversal gives identical entered nodes, prunes, closed words and +universal words. The original predicate is restored on successful return and +on exceptions by a `finally` block. Each invocation has its own authenticated +source module; no shared file or maintained engine is mutated. + +There are 416 reach entries and 13,312 logical translated entries. Identical +reach masks share translation tuples. Storage is bounded by those fixed counts; +it is not a prefix cache that grows with search history. Setup is paid once in +every candidate call and is included in both caller and full-process timing. +The remaining per-prefix support loop visits at most twelve old vertices. +The source's repeated scan over all 32 candidate vertices and nested old/new +pair loop disappear from this stage. The unchanged cheap checks and DFS still +cost time, so this is not a claim of the same speedup for a complete research +package, another census, another dimension or another Python implementation. + +The verifier compares all 13,312 translations against literal set translation, +then all 21,640 canonical simple prefixes against the original kernel. It +compares the full returned word tuples from both complete callers. These finite +checks corroborate the identity and adapter proof; they do not establish new +word-census exclusions, a seven-label result, or the predecessor theorem. + +## Implementation constraints + +The new kernel has no recursion. Its fixed loops have bounds 5, 32, 13 and 12. +The finite verifier's iterative DFS has a 21,641-iteration guard and at most 56 +pending entries. Benchmarking admits at most thirty pairs with thirty-second +child timeouts. The retained caller has unchanged recursive depth at most +eleven; that source-control deviation is bounded and not expanded here. + +CPython allocates managed objects during execution. The live cache and prefix +state have the fixed bounds above; no allocation-free claim is made. The +source adapter compiles exactly one SHA-256-authenticated, declared Python file +to avoid stale bytecode. This bounded source loading and the private predicate +replacement are explicit metaprogramming and indirect-call deviations. No +untrusted code path or arbitrary callback is accepted. Warning-strict normal +and optimized verification exercise success, unsupported mode, adapter failure +and actual source-corruption paths. Runtime checks use exceptions so they +remain enabled under optimized Python. diff --git a/research/cached-hamming-tail/README.md b/research/cached-hamming-tail/README.md new file mode 100644 index 0000000000..1a6f558871 --- /dev/null +++ b/research/cached-hamming-tail/README.md @@ -0,0 +1,147 @@ +# Cached Hamming envelopes in the complete prefix-completion caller + +This contribution was produced by Nick Petalas. Apache-2.0. + +**Implementation-equivalence proof with exact finite conformance and a measured +local runtime improvement.** A fixed bitset cache replaces the repeated +future-vertex and old/new difference loops in SHIN09-git's PR6046 shared-tail +predicate. The complete five-label, length-twelve no-cap caller retains exactly +the same rejection decisions, traversal and returned word tuples. + +Across all thirty alternating fresh-process pairs, the candidate has a **10.96% +lower median paired wall time**, with 28/30 paired wins and zero errors. This is +a local performance observation, not a portable timing guarantee. The cache is +built inside each timed caller. The complete process includes interpreter +startup, imports, source authentication, cache setup, traversal and JSON output. + +| Complete process | Median | Minimum | Maximum | +| --- | ---: | ---: | ---: | +| Unchanged source caller | 63.815 ms | 62.508 ms | 72.149 ms | +| Same caller with cached tail predicate | 56.849 ms | 55.466 ms | 167.177 ms | + +The slow candidate outlier is retained. An initial nine-pair experiment had +overlapping ranges and inconclusive rank-sum evidence. Before any further +measurement, the decision was to run one additional twenty-one-pair experiment +without changing the timed code and retain all thirty pairs. Both complete raw +receipts are committed. Their combined descriptive two-sided rank-sum +probability is `11226165959/59132290782430712`, about `1.90e-7`. Host contention +and sequential sampling limit its interpretation; it is not a portable speed +certificate. No samples from those two fixed experiments were removed and no +timing threshold runs in CI. An earlier in-process development probe and the +untimed profile were used to choose the implementation, not as published +performance samples. + +## The new step + +For visited vertices P, endpoint q and remaining budget r, let +`H={x: weight(q XOR x)+weight(x)<=r}`. The predecessor uses `U=H minus P` and +the support `D(P) union (P XOR U)`. The exact identity + +``` +D(P) union (P XOR U) = (D(P) union (P XOR H)) minus {0} +``` + +lets the implementation cache H and its XOR translations independently of the +prefix. Differences involving an already visited x are already in D(P), except +zero. The future cardinality still excludes every visited point. This is an +exact implementation of the same predicate, not a new pruning theorem. +[PROOF.md](PROOF.md) gives the equivalence, adapter and resource arguments. + +An untimed profile of the original complete caller attributes 0.035 of 0.079 +instrumented seconds to `tail_envelope`, including 4,434 calls. Its vertex scan +and nested difference loop are the replaced work. The unchanged parity-union +checks consume 0.029 instrumented seconds and constrain the attainable gain. +[PROFILE.txt](PROFILE.txt) retains the full profile; profiler times are not the +reported wall-time measurement. The measured wall-time reduction is smaller +than the replaced stage's profile share. + +The cache has 416 reach entries and 13,312 logical translated entries, with +identical masks sharing tuples. It has a fixed bound and is discarded after +the caller. The three source files are authenticated before loading. The +adapter changes one function on its private source module and restores it on +both success and failure. No predecessor file or maintained engine is edited. + +## Evidence and reproduction + +Run from the repository root with the recorded CPython 3.12.15 interpreter: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/cached-hamming-tail/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/cached-hamming-tail/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/cached-hamming-tail/timing_check.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/cached-hamming-tail +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/cached-hamming-tail --check-source-history +``` + +An installed CPython 3.12 can replace that interpreter path. Only the standard +library is needed. Direct checks print generated receipts bound to package and +input SHA-256 hashes. They write no package files. Temporary source-corruption +fixtures use the operating system temporary directory and are removed. + +The verifier compares all 13,312 translations against literal set translation, +all 21,640 canonical simple prefixes against the source's complete future set, +support mask and rejection decision, and both full returned word tuples. Each +complete caller enters 7,350 nodes, prunes 4,381 and returns 828 closed words, +all universal. Both tuple hashes are +`2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727`. +Six controls cover an overpermissive cache, omitted visited set, omitted XOR +translation, unsupported mode, caller-failure restoration and an actual changed +source file. These are checks of the new implementation's equivalence, not a +new scientific audit of the predecessor census or its completion theorem. + +`timing_check.py` authenticates every timed source and recomputes all retained +measurement arithmetic. It does not rerun benchmarks or certify host speed. +To collect new measurements, choose an external output path that does not exist: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/cached-hamming-tail/benchmark.py --pairs 9 --output /absolute/external/path.json +``` + +Each child has a thirty-second timeout. All samples check the counts and both +complete tuple hashes before accepting an output. The recorded machine has +eighteen logical CPUs; load averages at orientation were 1.72, 2.73 and 2.63. +Another Python process was active. Measurements are sequential and alternate +which side runs first. OS caches were not flushed and other host work was not +controlled. The receipts retain the exact platform, interpreter and load data. + +## Scope and credit + +Scientific base is canonical main `2485805a6d47f36ea83ddde6327d453ac82d44dc`, +priority revision 8. The selected conditional result remains PR6030. The +[advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19292017) +takes PR6046's explicit cached-envelope runtime question. The `replay-runtime` +card is refined to this standalone caller. This does not alter the selected +frontier, supply a new kappa, or make a complete multiplication theorem claim. + +Credit SHIN09-git for PR6046's shared-tail theorem, simplified predicate, +comparison traversal and open implementation question. Credit Ali Romman for +the distinct matching-capacity predicate and incremental matching engine; +Mihir Srivastava for the five-label handoff; Ross Richardson for the prefix-walk +model; Nicholas Stone for the parity correction; unpaidmoon, James Reed and +the retained word-census contributors for their cited work. The earlier +matching-balance, union-support and position-block work retains its attribution. +Classical bitsets, Hamming distance and XOR permutations are not claimed as new. + +Live open PRs, active Discussions and recent account work were checked. The +overlap helper covered 316 open PRs with complete pagination at +2026-10-30T11:25:39Z, but only 95 of 8,722 local note records; its broader +Discussion refresh timed out. Separate live GraphQL reads covered start-here, +twelve active Discussions and the latest thirty handoff comments. Main README +and merged-PR searches included cached Hamming envelopes, prefix completion, +incremental pair support and tail bitsets. This bounded coverage is not a +novelty certificate; historical diffs and unpublished work remain limits. + +No larger census, maintained-engine integration/default change, full historical +replay, selected cold replay, Lean or Docker run, native/dirty-restoration +construction, supplier admission or all-size theorem is supplied. All five +framework assumptions remain. Independent human and formal proof-kernel review +are unclaimed. + +## Open next questions + +Does this cache improve a named maintained-engine caller after its complete +setup and other predicates are paid? First select one exact small caller and +budget a full enabled-versus-disabled comparison with identical complete +outputs. A separate integration and resource budget are required; these local +results do not justify a larger census or a default change. No follow-up is +reserved. [TASK.json](TASK.json) records the same question and blockers. diff --git a/research/cached-hamming-tail/SOURCES.json b/research/cached-hamming-tail/SOURCES.json new file mode 100644 index 0000000000..40b8e7cef9 --- /dev/null +++ b/research/cached-hamming-tail/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/five-label-prefix-completion/PROOF.md", + "usage": "input", + "git_blob": "1f504817b2f4281e0551ac9fc24dfed2d9a3585c", + "sha256": "54731461e8636b0048bb01ad6bde4b92ce718959923a5cb58e888a519d94ac9d" + }, + { + "path": "research/five-label-prefix-completion/README.md", + "usage": "input", + "git_blob": "1f3be2eab0c9df69e9965f4f9afe2d486ef04049", + "sha256": "591816a89f4f733b69fe218a66efd9f396e3c260ee2f3c0f4a8cdcd893571c83" + }, + { + "path": "research/five-label-prefix-completion/bounds.py", + "usage": "input", + "git_blob": "3022224471f1578d4d7f6e3d31c9c0c091029a55", + "sha256": "e9023abd49e92ae4c5d0bcbf265ad0883d9408a51bab5354e321102f2f20f522" + } + ] +} diff --git a/research/cached-hamming-tail/TASK.json b/research/cached-hamming-tail/TASK.json new file mode 100644 index 0000000000..6b6dbc2e6d --- /dev/null +++ b/research/cached-hamming-tail/TASK.json @@ -0,0 +1,61 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "priority_revision": 8, + "base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "actual_scope": "Exact cached Hamming envelopes in PR6046's complete five-label length-twelve shared-tail caller.", + "scope_change_reason": "Take PR6046's explicitly open cached-envelope implementation question; retain its predicate and whole caller.", + "bottleneck_link": "Lower the complete cost of a sound prefix filter before considering maintained-engine integration.", + "budget_minutes": 60, + "stop_rule": "Ship the first verified complete-caller improvement; stop without a larger census or additional optimization.", + "outcome": "completed", + "evidence": "PROOF.md; 21640 prefix comparisons; 13312 table comparisons; full caller equality; six controls; all sixty fresh-process measurements retained.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Does this cache improve a named maintained-engine caller after its full setup and remaining predicates are paid?", + "why_it_matters": "The present implementation changes a standalone research comparison, not the production census.", + "first_step": "Choose one exact small caller and budget a full enabled-versus-disabled comparison with identical complete outputs.", + "blocked_by": "A separate integration and resource budget; no larger census or default change is justified here." + } + ] +} diff --git a/research/cached-hamming-tail/TIMINGS-CONFIRMATION.json b/research/cached-hamming-tail/TIMINGS-CONFIRMATION.json new file mode 100644 index 0000000000..b85c9a9510 --- /dev/null +++ b/research/cached-hamming-tail/TIMINGS-CONFIRMATION.json @@ -0,0 +1,714 @@ +{ + "cpu_count": 18, + "errors": 0, + "faster_pairs": 20, + "finished_at": "2026-10-30T11:29:00.091764+00:00", + "input_sha256": { + "research/five-label-prefix-completion/PROOF.md": "54731461e8636b0048bb01ad6bde4b92ce718959923a5cb58e888a519d94ac9d", + "research/five-label-prefix-completion/README.md": "591816a89f4f733b69fe218a66efd9f396e3c260ee2f3c0f4a8cdcd893571c83", + "research/five-label-prefix-completion/bounds.py": "e9023abd49e92ae4c5d0bcbf265ad0883d9408a51bab5354e321102f2f20f522" + }, + "load_average": [ + 2.376953125, + 2.59716796875, + 2.57958984375 + ], + "median_paired_ratio": 0.8884365151608707, + "pairs": 21, + "platform": "macOS-27.0.1-arm64-arm-64bit", + "python": "3.12.15 (main, Oct 14 2026, 00:55:37) [Clang 23.1.3 ]", + "rows": [ + { + "caller_ns": 37279708, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 0, + "side": "baseline", + "wall_ns": 62916291 + }, + { + "caller_ns": 30844667, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 0, + "side": "candidate", + "wall_ns": 57504042 + }, + { + "caller_ns": 30525083, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 1, + "side": "candidate", + "wall_ns": 56149500 + }, + { + "caller_ns": 36892167, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 1, + "side": "baseline", + "wall_ns": 63030250 + }, + { + "caller_ns": 36868250, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 2, + "side": "baseline", + "wall_ns": 63621084 + }, + { + "caller_ns": 30522542, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 2, + "side": "candidate", + "wall_ns": 56462583 + }, + { + "caller_ns": 30400417, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 3, + "side": "candidate", + "wall_ns": 56383000 + }, + { + "caller_ns": 37674875, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 3, + "side": "baseline", + "wall_ns": 64400958 + }, + { + "caller_ns": 37194792, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 4, + "side": "baseline", + "wall_ns": 63388750 + }, + { + "caller_ns": 30338959, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 4, + "side": "candidate", + "wall_ns": 56128542 + }, + { + "caller_ns": 30639000, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 5, + "side": "candidate", + "wall_ns": 56455625 + }, + { + "caller_ns": 37261084, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 5, + "side": "baseline", + "wall_ns": 63668416 + }, + { + "caller_ns": 37332042, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 6, + "side": "baseline", + "wall_ns": 62756125 + }, + { + "caller_ns": 30275416, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 6, + "side": "candidate", + "wall_ns": 55754833 + }, + { + "caller_ns": 30439125, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 7, + "side": "candidate", + "wall_ns": 56765041 + }, + { + "caller_ns": 37489875, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 7, + "side": "baseline", + "wall_ns": 63781541 + }, + { + "caller_ns": 37220750, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 8, + "side": "baseline", + "wall_ns": 62616833 + }, + { + "caller_ns": 30229542, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 8, + "side": "candidate", + "wall_ns": 56295167 + }, + { + "caller_ns": 29878541, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 9, + "side": "candidate", + "wall_ns": 55465583 + }, + { + "caller_ns": 36604416, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 9, + "side": "baseline", + "wall_ns": 62508334 + }, + { + "caller_ns": 37257875, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 10, + "side": "baseline", + "wall_ns": 62793917 + }, + { + "caller_ns": 30295250, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 10, + "side": "candidate", + "wall_ns": 57079042 + }, + { + "caller_ns": 44577375, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 11, + "side": "candidate", + "wall_ns": 75671875 + }, + { + "caller_ns": 37590333, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 11, + "side": "baseline", + "wall_ns": 68910875 + }, + { + "caller_ns": 38310459, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 12, + "side": "baseline", + "wall_ns": 66172792 + }, + { + "caller_ns": 33103334, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 12, + "side": "candidate", + "wall_ns": 63619500 + }, + { + "caller_ns": 31928000, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 13, + "side": "candidate", + "wall_ns": 59645208 + }, + { + "caller_ns": 37468417, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 13, + "side": "baseline", + "wall_ns": 64105250 + }, + { + "caller_ns": 37133541, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 14, + "side": "baseline", + "wall_ns": 63165625 + }, + { + "caller_ns": 30296250, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 14, + "side": "candidate", + "wall_ns": 56582083 + }, + { + "caller_ns": 30472792, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 15, + "side": "candidate", + "wall_ns": 56377958 + }, + { + "caller_ns": 37537750, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 15, + "side": "baseline", + "wall_ns": 63953375 + }, + { + "caller_ns": 36956333, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 16, + "side": "baseline", + "wall_ns": 63271750 + }, + { + "caller_ns": 30413167, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 16, + "side": "candidate", + "wall_ns": 56165416 + }, + { + "caller_ns": 30304667, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 17, + "side": "candidate", + "wall_ns": 56437459 + }, + { + "caller_ns": 37474416, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 17, + "side": "baseline", + "wall_ns": 63673875 + }, + { + "caller_ns": 37567334, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 18, + "side": "baseline", + "wall_ns": 63847750 + }, + { + "caller_ns": 30480709, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 18, + "side": "candidate", + "wall_ns": 56347500 + }, + { + "caller_ns": 29956208, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 19, + "side": "candidate", + "wall_ns": 55554958 + }, + { + "caller_ns": 37113083, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 19, + "side": "baseline", + "wall_ns": 63469958 + }, + { + "caller_ns": 37739667, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 20, + "side": "baseline", + "wall_ns": 64125416 + }, + { + "caller_ns": 30779750, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 20, + "side": "candidate", + "wall_ns": 57341834 + } + ], + "scope": "Sequential fresh processes; complete caller, source reading, cache setup, startup and output included. OS caches not flushed; other host work uncontrolled. No performance threshold in CI.", + "source_sha256": { + "SOURCES.json": "ce31c68a83474ac32b839b8bdc5d4745a694bab70e4bba48f2b05384acf6bbb4", + "benchmark.py": "fb0466f9d110cb4adda55dfa775de9c70d8cc827d05525e3ee1cedb6a502072c", + "kernel.py": "228226ebdcd8140c4a975677e777372b2eba4ddab1e46956b9323c2ecfb79739", + "source.py": "e78ea90266efd698322c0e239b675ff98656a2bf8de7fd3f744509aca687e655" + }, + "started_at": "2026-10-30T11:28:57.532951+00:00", + "summary": { + "baseline": { + "max_ns": 68910875, + "median_ns": 63621084, + "min_ns": 62508334 + }, + "candidate": { + "max_ns": 75671875, + "median_ns": 56437459, + "min_ns": 55465583 + } + } +} diff --git a/research/cached-hamming-tail/TIMINGS-INITIAL.json b/research/cached-hamming-tail/TIMINGS-INITIAL.json new file mode 100644 index 0000000000..e71b8388cf --- /dev/null +++ b/research/cached-hamming-tail/TIMINGS-INITIAL.json @@ -0,0 +1,330 @@ +{ + "cpu_count": 18, + "errors": 0, + "faster_pairs": 8, + "finished_at": "2026-10-30T11:28:04.495866+00:00", + "input_sha256": { + "research/five-label-prefix-completion/PROOF.md": "54731461e8636b0048bb01ad6bde4b92ce718959923a5cb58e888a519d94ac9d", + "research/five-label-prefix-completion/README.md": "591816a89f4f733b69fe218a66efd9f396e3c260ee2f3c0f4a8cdcd893571c83", + "research/five-label-prefix-completion/bounds.py": "e9023abd49e92ae4c5d0bcbf265ad0883d9408a51bab5354e321102f2f20f522" + }, + "load_average": [ + 1.2666015625, + 2.38330078125, + 2.50390625 + ], + "median_paired_ratio": 0.8971293845135672, + "pairs": 9, + "platform": "macOS-27.0.1-arm64-arm-64bit", + "python": "3.12.15 (main, Oct 14 2026, 00:55:37) [Clang 23.1.3 ]", + "rows": [ + { + "caller_ns": 37200417, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 0, + "side": "baseline", + "wall_ns": 64503000 + }, + { + "caller_ns": 30470083, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 0, + "side": "candidate", + "wall_ns": 57174750 + }, + { + "caller_ns": 30840792, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 1, + "side": "candidate", + "wall_ns": 56933625 + }, + { + "caller_ns": 37281208, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 1, + "side": "baseline", + "wall_ns": 63462000 + }, + { + "caller_ns": 37284250, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 2, + "side": "baseline", + "wall_ns": 64193167 + }, + { + "caller_ns": 30695292, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 2, + "side": "candidate", + "wall_ns": 57121667 + }, + { + "caller_ns": 30271875, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 3, + "side": "candidate", + "wall_ns": 57044250 + }, + { + "caller_ns": 37085375, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 3, + "side": "baseline", + "wall_ns": 63884875 + }, + { + "caller_ns": 37207166, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 4, + "side": "baseline", + "wall_ns": 64004041 + }, + { + "caller_ns": 108161125, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 4, + "side": "candidate", + "wall_ns": 167176917 + }, + { + "caller_ns": 31355750, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 5, + "side": "candidate", + "wall_ns": 65240333 + }, + { + "caller_ns": 37151625, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 5, + "side": "baseline", + "wall_ns": 65894584 + }, + { + "caller_ns": 37745792, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 6, + "side": "baseline", + "wall_ns": 65262583 + }, + { + "caller_ns": 30577667, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 6, + "side": "candidate", + "wall_ns": 59297417 + }, + { + "caller_ns": 32861292, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 7, + "side": "candidate", + "wall_ns": 65806666 + }, + { + "caller_ns": 42420625, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 7, + "side": "baseline", + "wall_ns": 72149000 + }, + { + "caller_ns": 37561042, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 8, + "side": "baseline", + "wall_ns": 66469209 + }, + { + "caller_ns": 30736542, + "counts": { + "closed": 828, + "entered": 7350, + "pruned": 4381, + "universal": 828 + }, + "hashes": [ + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727", + "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + ], + "pair": 8, + "side": "candidate", + "wall_ns": 58997625 + } + ], + "scope": "Sequential fresh processes; complete caller, source reading, cache setup, startup and output included. OS caches not flushed; other host work uncontrolled. No performance threshold in CI.", + "source_sha256": { + "SOURCES.json": "ce31c68a83474ac32b839b8bdc5d4745a694bab70e4bba48f2b05384acf6bbb4", + "benchmark.py": "fb0466f9d110cb4adda55dfa775de9c70d8cc827d05525e3ee1cedb6a502072c", + "kernel.py": "228226ebdcd8140c4a975677e777372b2eba4ddab1e46956b9323c2ecfb79739", + "source.py": "e78ea90266efd698322c0e239b675ff98656a2bf8de7fd3f744509aca687e655" + }, + "started_at": "2026-10-30T11:28:03.258956+00:00", + "summary": { + "baseline": { + "max_ns": 72149000, + "median_ns": 64503000, + "min_ns": 63462000 + }, + "candidate": { + "max_ns": 167176917, + "median_ns": 58997625, + "min_ns": 56933625 + } + } +} diff --git a/research/cached-hamming-tail/VERIFY.json b/research/cached-hamming-tail/VERIFY.json new file mode 100644 index 0000000000..8c6dc88cff --- /dev/null +++ b/research/cached-hamming-tail/VERIFY.json @@ -0,0 +1,50 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/five-label-prefix-completion/PROOF.md", + "research/five-label-prefix-completion/README.md", + "research/five-label-prefix-completion/bounds.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "All 13312 table translations, 21640 prefixes, complete callers and six rejecting/failure controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Same exact coverage with assertions disabled." + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/timing_check.py" + ], + "timeout_seconds": 120, + "checks": "Authenticate all retained timed source bytes and reproduce exact arithmetic of all sixty observations; no new timing threshold." + } + ] +} diff --git a/research/cached-hamming-tail/benchmark.py b/research/cached-hamming-tail/benchmark.py new file mode 100644 index 0000000000..656ea87610 --- /dev/null +++ b/research/cached-hamming-tail/benchmark.py @@ -0,0 +1,99 @@ +"""Complete fixed-caller timings, produced by Nick Petalas. Apache-2.0.""" + +import argparse +from datetime import datetime, timezone +from hashlib import sha256 +import json +import os +from pathlib import Path +import platform +import statistics +import subprocess +import sys +import time + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import kernel +import source + + +def worker(side): + reference = source.load() + started = time.perf_counter_ns() + output = reference.search("two_without_cap") if side == "baseline" else kernel.search(reference) + counts, closed, hits = output + hashes = [sha256("".join("".join(map(str, w)) + "\n" for w in words).encode()).hexdigest() + for words in (closed, hits)] + return {"side": side, "counts": counts, "hashes": hashes, + "caller_ns": time.perf_counter_ns() - started} + + +def sample(side): + env = dict(os.environ) + env.pop("PYTHONOPTIMIZE", None) + started = time.perf_counter_ns() + result = subprocess.run([sys.executable, "-I", "-W", "error", "-B", __file__, "--worker", side], + env=env, capture_output=True, check=True, timeout=30) + wall = time.perf_counter_ns() - started + row = json.loads(result.stdout) + if result.stderr: + raise ValueError("unexpected stderr: " + result.stderr.decode()) + return {"wall_ns": wall, **row} + + +def benchmark(pairs): + started = datetime.now(timezone.utc).isoformat() + files = ("kernel.py", "source.py", "benchmark.py", "SOURCES.json") + hashes = {p: sha256((source.HERE / p).read_bytes()).hexdigest() for p in files} + rows = [] + expected = None + for pair in range(pairs): + order = ("baseline", "candidate") if pair % 2 == 0 else ("candidate", "baseline") + for side in order: + row = sample(side) + observed = (row["counts"], row["hashes"]) + if expected is None: + expected = observed + if observed != expected or row["counts"]["universal"] != 828: + raise ValueError("complete caller output mismatch") + rows.append({"pair": pair, **row}) + if hashes != {p: sha256((source.HERE / p).read_bytes()).hexdigest() for p in files}: + raise ValueError("timed source changed") + summary = {} + for side in ("baseline", "candidate"): + values = [r["wall_ns"] for r in rows if r["side"] == side] + summary[side] = {"median_ns": statistics.median(values), "min_ns": min(values), "max_ns": max(values)} + ratios = [] + for pair in range(pairs): + block = {r["side"]: r["wall_ns"] for r in rows if r["pair"] == pair} + ratios.append(block["candidate"] / block["baseline"]) + return {"started_at": started, "finished_at": datetime.now(timezone.utc).isoformat(), + "python": sys.version, "platform": platform.platform(), "cpu_count": os.cpu_count(), + "load_average": os.getloadavg(), "pairs": pairs, "errors": 0, "rows": rows, + "source_sha256": hashes, "input_sha256": source.authenticate(), "summary": summary, + "median_paired_ratio": statistics.median(ratios), "faster_pairs": sum(r < 1 for r in ratios), + "scope": "Sequential fresh processes; complete caller, source reading, cache setup, startup and output included. OS caches not flushed; other host work uncontrolled. No performance threshold in CI."} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--worker", choices=("baseline", "candidate")) + parser.add_argument("--pairs", type=int, default=9) + parser.add_argument("--output", type=Path) + args = parser.parse_args() + if args.worker: + print(json.dumps(worker(args.worker), sort_keys=True)) + return + if not 5 <= args.pairs <= 30 or args.output is None: + parser.error("provide --output and 5 <= --pairs <= 30") + if args.output.exists(): + parser.error("output already exists") + report = benchmark(args.pairs) + with args.output.open("x", encoding="utf-8") as stream: + json.dump(report, stream, indent=2, sort_keys=True) + stream.write("\n") + print(json.dumps({k: report[k] for k in ("summary", "median_paired_ratio", "faster_pairs", "errors")})) + + +if __name__ == "__main__": + main() diff --git a/research/cached-hamming-tail/kernel.py b/research/cached-hamming-tail/kernel.py new file mode 100644 index 0000000000..567733ac67 --- /dev/null +++ b/research/cached-hamming-tail/kernel.py @@ -0,0 +1,74 @@ +"""Exact fixed-domain Hamming envelopes, produced by Nick Petalas. + +Apache-2.0. The shared-tail predicate and caller are SHIN09-git's PR6046. +""" + +DIMENSION = 5 +LENGTH = 12 +SIZE = 1 << DIMENSION +ALL = (1 << SIZE) - 1 +NONZERO = ALL - 1 +LOW = (0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF) + + +def translate(bits, point): + """Return the bitset {x XOR point : x in bits}.""" + for coordinate in range(DIMENSION): + step = 1 << coordinate + if point & step: + low = LOW[coordinate] + bits = ((bits & low) << step) | ((bits & (ALL ^ low)) >> step) + return bits + + +def tables(): + """Build all 416 reach masks and their 13,312 translations once.""" + masks = [] + translated = [] + cache = {} + for last in range(SIZE): + for remaining in range(LENGTH + 1): + mask = sum(1 << x for x in range(SIZE) + if (last ^ x).bit_count() + x.bit_count() <= remaining) + masks.append(mask) + if mask not in cache: + cache[mask] = tuple(translate(mask, p) for p in range(SIZE)) + translated.append(cache[mask]) + assert len(masks) == SIZE * (LENGTH + 1) + return tuple(masks), tuple(translated) + + +def envelope(points, seen, support, reach, translated): + """Inputs are a validated simple prefix and its literal pair support.""" + index = points[-1] * (LENGTH + 1) + LENGTH - len(points) + 1 + future = reach[index] & (ALL ^ seen) + possible = support + shifts = translated[index] + for old in points: + possible |= shifts[old] + return future, possible & NONZERO + + +def cached_reject(reference, reach, translated): + """Substitute only the tail stage of the source's no-cap caller.""" + def reject(points, highest, mode): + if mode != "two_without_cap": + raise ValueError("only the fixed shared-tail no-cap caller is admitted") + if reference.remaining_reject(points, highest) or reference.union_reject(points): + return True + seen = sum(1 << p for p in points) + future, possible = envelope(points, seen, reference.pair_support(points), + reach, translated) + return future.bit_count() < LENGTH - len(points) or possible != NONZERO + return reject + + +def search(reference): + """Run the unchanged complete caller with the exact new tail kernel.""" + reach, translated = tables() + original = reference.reject + reference.reject = cached_reject(reference, reach, translated) + try: + return reference.search("two_without_cap") + finally: + reference.reject = original diff --git a/research/cached-hamming-tail/source.py b/research/cached-hamming-tail/source.py new file mode 100644 index 0000000000..1296e0dc5d --- /dev/null +++ b/research/cached-hamming-tail/source.py @@ -0,0 +1,31 @@ +"""Read the exact declared predecessor bytes; produced by Nick Petalas.""" + +from hashlib import sha256 +import json +from pathlib import Path +from types import ModuleType + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] + + +def authenticate(root=ROOT): + manifest = json.loads((HERE / "SOURCES.json").read_text()) + pins = {} + for row in manifest["files"]: + if row["usage"] == "input": + path = root / row["path"] + raw = path.read_bytes() + actual = sha256(raw).hexdigest() + if actual != row["sha256"]: + raise ValueError("source hash mismatch: " + row["path"]) + pins[row["path"]] = actual + return pins + + +def load(): + authenticate() + path = ROOT / "research/five-label-prefix-completion/bounds.py" + module = ModuleType("retained_prefix_completion") + exec(compile(path.read_bytes(), str(path), "exec"), module.__dict__) + return module diff --git a/research/cached-hamming-tail/timing_check.py b/research/cached-hamming-tail/timing_check.py new file mode 100644 index 0000000000..d3c1152e8b --- /dev/null +++ b/research/cached-hamming-tail/timing_check.py @@ -0,0 +1,76 @@ +"""Retained measurement arithmetic, produced by Nick Petalas. Apache-2.0.""" + +from fractions import Fraction +from hashlib import sha256 +import json +from math import comb +from pathlib import Path +import statistics + +HERE = Path(__file__).resolve().parent + + +def need(condition, reason): + if not condition: + raise ValueError(reason) + + +def rank_sum_probability(left, right): + """Exact two-sided permutation probability, for the fixed 30+30 sample.""" + need(len(left) == len(right) == 30, "thirty samples per side") + need(len(set(left + right)) == 60, "rank-sum calculation assumes no ties") + u = sum(x > y for x in right for y in left) + counts = {(0, 0): 1} + for rank in range(1, 61): + updated = dict(counts) + for (selected, total), count in counts.items(): + if selected < 30: + key = selected + 1, total + rank + updated[key] = updated.get(key, 0) + count + counts = updated + tail = sum(count for (selected, total), count in counts.items() + if selected == 30 and total - 465 <= min(u, 900 - u)) + return u, Fraction(2 * tail, comb(60, 30)) + + +def measurements(): + rows = [] + for filename, pairs in (("TIMINGS-INITIAL.json", 9), ("TIMINGS-CONFIRMATION.json", 21)): + report = json.loads((HERE / filename).read_text()) + need(report["pairs"] == pairs and report["errors"] == 0, "measurement coverage") + need(len(report["rows"]) == pairs * 2, "complete sample rows") + for name, expected in report["source_sha256"].items(): + need(sha256((HERE / name).read_bytes()).hexdigest() == expected, "timed source bytes") + for pair in range(pairs): + block = report["rows"][2 * pair:2 * pair + 2] + expected_order = ["baseline", "candidate"] if pair % 2 == 0 else ["candidate", "baseline"] + need([r["side"] for r in block] == expected_order, "alternating sample order") + need(all(r["pair"] == pair for r in block), "sample pair") + rows.extend(report["rows"]) + need(all(r["counts"] == {"entered": 7350, "pruned": 4381, "closed": 828, "universal": 828} + for r in rows), "same complete caller work") + expected = "2e64b75bdd56124eb0993e0dcb2b79f849435465c32bdc9329ea2c171b506727" + need(all(r["hashes"] == [expected, expected] for r in rows), "both complete word sets") + return rows + + +def main(): + rows = measurements() + baseline = [r["wall_ns"] for r in rows if r["side"] == "baseline"] + candidate = [r["wall_ns"] for r in rows if r["side"] == "candidate"] + ratios = [] + for index in range(0, 60, 2): + block = {r["side"]: r["wall_ns"] for r in rows[index:index + 2]} + ratios.append(Fraction(block["candidate"], block["baseline"])) + u, probability = rank_sum_probability(baseline, candidate) + output = {"status": "PASS_RETAINED_TIMING_ARITHMETIC", "pairs": 30, "errors": 0, + "baseline_ns": [statistics.median(baseline), min(baseline), max(baseline)], + "candidate_ns": [statistics.median(candidate), min(candidate), max(candidate)], + "median_paired_ratio": str(statistics.median(ratios)), + "faster_pairs": sum(r < 1 for r in ratios), "rank_sum_U": u, + "descriptive_two_sided_rank_sum_probability": str(probability)} + print(json.dumps(output, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/cached-hamming-tail/verify.py b/research/cached-hamming-tail/verify.py new file mode 100644 index 0000000000..8064c65570 --- /dev/null +++ b/research/cached-hamming-tail/verify.py @@ -0,0 +1,148 @@ +"""Finite equivalence checks, produced by Nick Petalas. Apache-2.0.""" + +from hashlib import sha256 +import json +from pathlib import Path +import shutil +import sys +import tempfile + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import kernel +import source + + +def need(condition, reason): + if not condition: + raise ValueError(reason) + + +def check_tables(reach, shifted): + comparisons = 0 + for last in range(32): + for remaining in range(13): + index = last * 13 + remaining + values = [x for x in range(32) + if (last ^ x).bit_count() + x.bit_count() <= remaining] + need(reach[index] == sum(1 << x for x in values), "reach mask") + for old in range(32): + expected = sum(1 << (old ^ x) for x in values) + need(shifted[index][old] == expected, "XOR translation") + comparisons += 1 + return comparisons + + +def prefixes(): + stack = [((0,), -1, 1)] + for _ in range(21641): + if not stack: + return + points, highest, seen = stack.pop() + yield points, highest, seen + if len(points) == 12: + continue + for label in range(min(highest + 1, 4), -1, -1): + value = points[-1] ^ (1 << label) + if not seen >> value & 1: + stack.append((points + (value,), max(highest, label), seen | (1 << value))) + need(len(stack) <= 56, "bounded DFS stack") + raise ValueError("prefix domain exceeded its bound") + + +def check_prefixes(reference, reach, shifted): + count = 0 + decisions = 0 + fast = kernel.cached_reject(reference, reach, shifted) + for points, highest, seen in prefixes(): + old_future, old_possible = reference.tail_envelope(points) + future, possible = kernel.envelope(points, seen, reference.pair_support(points), reach, shifted) + need(future == sum(1 << x for x in old_future), "future set") + need(possible == old_possible, "complete envelope") + need(fast(points, highest, "two_without_cap") == + reference.reject(points, highest, "two_without_cap"), "rejection decision") + decisions += 1 + count += 1 + need(count == 21640, "complete canonical prefix domain") + return {"prefixes": count, "rejection_comparisons": decisions} + + +def digest(words): + return sha256("".join("".join(map(str, w)) + "\n" for w in words).encode()).hexdigest() + + +def check_callers(reference): + original = reference.reject + baseline = reference.search("two_without_cap") + candidate = kernel.search(reference) + need(reference.reject is original, "source adapter restoration") + need(candidate == baseline, "complete caller output") + counts, closed, hits = candidate + need(counts == {"entered": 7350, "pruned": 4381, "closed": 828, "universal": 828}, "caller counts") + return {"counts": counts, "closed_sha256": digest(closed), "universal_sha256": digest(hits)} + + +def check_controls(reference, reach, shifted): + points = (0, 1, 3, 2, 6, 7, 5, 13, 9, 8) + seen = sum(1 << p for p in points) + support = reference.pair_support(points) + future, possible = kernel.envelope(points, seen, support, reach, shifted) + need((kernel.NONZERO ^ possible) == (1 << 20) | (1 << 28), "strict missing-mask witness") + need(future.bit_count() == 5, "strict future witness") + wrong = list(shifted) + index = points[-1] * 13 + 3 + wrong[index] = tuple(kernel.ALL for _ in range(32)) + need(kernel.envelope(points, seen, support, reach, wrong)[1] != possible, "overpermissive table control") + need(kernel.envelope(points, 0, support, reach, shifted)[0] != future, "visited-mask omission control") + need(kernel.translate(1, 1) != 1, "identity-translation control") + try: + kernel.cached_reject(reference, reach, shifted)(points, 4, "cheap") + except ValueError as error: + need("fixed shared-tail" in str(error), "wrong mode error") + else: + raise ValueError("unsupported mode accepted") + old_union, old_reject = reference.union_reject, reference.reject + def fail(points): + raise RuntimeError("deliberate caller failure") + reference.union_reject = fail + try: + try: + kernel.search(reference) + except RuntimeError as error: + need(str(error) == "deliberate caller failure", "wrong adapter error") + else: + raise ValueError("caller failure swallowed") + need(reference.reject is old_reject, "adapter not restored after failure") + finally: + reference.union_reject = old_union + with tempfile.TemporaryDirectory(prefix="hamming-source-") as name: + root = Path(name) + for path in source.authenticate(): + target = root / path + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(source.ROOT / path, target) + path = root / "research/five-label-prefix-completion/bounds.py" + path.write_bytes(path.read_bytes() + b"\n# altered source\n") + try: + source.authenticate(root) + except ValueError as error: + need("source hash mismatch" in str(error), "wrong source error") + else: + raise ValueError("actual source-byte corruption accepted") + return 6 + + +def main(): + reference = source.load() + reach, shifted = kernel.tables() + report = {"status": "PASS_CACHED_HAMMING_TAIL", "claim_type": "implementation equivalence and local performance", + "table_comparisons": check_tables(reach, shifted), + **check_prefixes(reference, reach, shifted), "caller": check_callers(reference), + "controls": check_controls(reference, reach, shifted), "inputs": source.authenticate()} + report["package_sha256"] = { + p.name: sha256(p.read_bytes()).hexdigest() + for p in sorted(source.HERE.iterdir()) if p.is_file()} + print(json.dumps(report, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main()