Skip to content

clear, take, half load and a one-multiply hash - #4

Merged
sbillig merged 5 commits into
mainfrom
feat/take
Nov 10, 2026
Merged

sbillig merged 5 commits into
mainfrom
feat/take

Conversation

@sbillig

@sbillig sbillig commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Four changes from fevm's tuning, and the native runner brought up to date with two of them:

  • clear removes every entry and keeps the slots for the next use.
  • Entries and tombstones fill at most half of the slots (was 7/8), which keeps probe runs short.
  • u256 keys hash with one folded multiplication instead of three: the two high limbs, rotated, fold onto the low ones.
  • take removes a key and returns its value with one search; remove shares its slot removal.
  • The runner's model of the table used the old load limit and hash, so its first scenario check failed; it now models both.

A table reused across transactions dropped its slots to forget its entries, and allocated them again on its next insertion. clear resets the control bytes and counts and keeps the slots.
A search reads control bytes one at a time until an empty slot, so its
cost follows the run length, which grows fast past half load with linear
probing: at 7/8, fevm's account searches averaged 2.7 probes, most of
them fingerprint misses. With at most half of the slots filled, fevm's
CREATE runs 8% and SELFDESTRUCT 10% fewer cycles; storage-heavy cases are
unchanged. Tables take up to twice the slots.
A lookup cannot probe before its hash, and three folded multiplications
(a lane per limb pair, then the lanes) put ~12 cycles of multiplier latency
there. Fold the two high limbs, rotated four bits, onto the two low ones and
multiply once. fevm's account lookups (address keys) and storage keys (two
hashes each) get one multiply per hash: CREATE -4.3% and transfers -4.9%
cycles. The distribution test still holds for every limb.
A caller that needed a removed entry's value found its slot, read the
value and then removed the key, searching twice. `take` searches once;
`remove` and `take` share the removal of a found slot.
The runner's model of the table kept a 7/8 load after bc26326 limited
entries and tombstones to half of the slots, and the three-multiply u256
hash after eee63c1 folded the high limbs onto the low ones, so its first
scenario check failed. It now uses both, and all 2,004 scenario checks
pass again.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T02:52:17.869295Z 17e496d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sbillig
sbillig merged commit 2de44c1 into main Nov 10, 2026
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.

1 participant