Skip to content

perf: index once in rewalk, bind.refresh and digest.laws_of (#228) - #231

Merged
ngngardner merged 2 commits into
mainfrom
claude/optimistic-hypatia-27r51a
Sep 30, 2026
Merged

ngngardner merged 2 commits into
mainfrom
claude/optimistic-hypatia-27r51a

Conversation

@ngngardner

Copy link
Copy Markdown
Contributor

Fixes three of the four per-item scans in #228. No LAWS.bend changed, and bolt's lint output is byte-identical.

Changes

  • rewalk: each site's result is now checked once per straight piece. Before, it was re-checked for every twin a site was compared against. other_go, earlier and report now compare the stored flags, and other_full, earlier_one and earlier_nar are gone. The proofs of rewalk_local_counts in src/rules/PROOF.bend now go through Rewalk.rate.
    • Stress test, 150 identical +aN = walk(xs) lets: 14.7 s → 0.14 s.
    • Trade-off: a site with no twin now costs one walk of the piece, where before it cost none. A file of 400 lets with no twins went from 0.24 s to 0.68 s. Linting bolt with only rewalk on shows no measurable difference.
  • bind.refresh: one pass over the annotated binders with a cursor, instead of a full binder search for each environment entry. The binders are in source order, which Bound promises. A binder earlier than the last one read restarts the cursor, so the result stays right whatever order the environment is in. Old and new gave the same result on all 20,461 scopes of 102 files in the tree.
  • digest.laws_of: the outline items are read with a cursor that moves forward from law to law, instead of being searched from the start for each law. The Law lists were byte-identical on all 8 LAWS.bend files and on a synthetic file with 3,000 laws.
  • Both cursors, seek and from_line, carry the stop test as a Bool instead of wrapping the recursive step in a thunk, as AGENTS.md asks. thunk (U015) reports none of the new code.

Not changed: unused

unused_counts states the foreign-line lookup as List.contains over any binds. A faster exact lookup, such as a trie or a sorted cursor, would need a lemma that U32.is_eq(a, b) means a == b, and Base has none. That list is also empty in any file without foreign defs.

With scan turned on, the refresh, laws_of and rewalk per-site findings are gone. rewalk still has two scan findings: one walk per site, and the pairwise twin comparison that the law states.

Gate

  • bend PROOF.bend prints ALL PROOFS CHECK in all 7 directories.
  • bend main.bend -o bin/bolt.bin builds.
  • bolt --gpu off gives 0 errors, 73 warnings, the baseline.

🤖 Generated with Claude Code

https://claude.ai/code/session_01X7i62UAece6mwMRV3Y1b9B


Generated by Claude Code

- rewalk: rate each site once (narrow over the piece) before reporting, so
  other_go, earlier and report compare ratings instead of walking the piece
  for every pair of twin sites. The proofs of rewalk_local_counts now go
  through Rewalk.rate; no law changed.
- bind.refresh: read the annotated binders with a cursor (binders are in
  source order) instead of one full binder search per environment entry; a
  binder before the last one read starts the cursor over.
- digest.laws_of: carry the outline items forward as a cursor instead of
  searching them from the start for each law.

unused (reportable over the foreign header lines) is left as is: a faster
lookup cannot be proved equal to the List.contains that unused_counts states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X7i62UAece6mwMRV3Y1b9B
The two new cursors wrapped their recursive step in Lazy.stop, the lone
thunk AGENTS.md warns against for a search (thunk, U015). Carry the head's
test as a Bool into the next call and match on it after the list, so the
step stays a tail call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X7i62UAece6mwMRV3Y1b9B
@ngngardner
ngngardner merged commit 9994646 into main Sep 30, 2026
1 check passed
@ngngardner
ngngardner deleted the claude/optimistic-hypatia-27r51a branch September 30, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants