Skip to content

Fix false TT hits for zero verification keys - #1128

Draft
kuel27 wants to merge 1 commit into
codedeliveryservice:mainfrom
kuel27:fix-zero-key-tt-hit
Draft

Fix false TT hits for zero verification keys#1128
kuel27 wants to merge 1 commit into
codedeliveryservice:mainfrom
kuel27:fix-zero-key-tt-hit

Conversation

@kuel27

@kuel27 kuel27 commented Aug 29, 2026

Copy link
Copy Markdown

When a TT slot is cleared, it has a verification key of zero, but zero is also a valid 21-bit verification key. So a probe with this key can match an unused slot and read zeroed data as a valid TT entry.

This reproduces the bug:

let tt = TranspositionTable::default();
assert!(tt.read(0xed3e785687200000, 0, 0).is_none());

The assertion fails before this patch and passes after it. Fixing the false hit changes the standard bench from 2985186 to 2957947 nodes.

To fix this, reserve verification key zero for unused slots. Skip TT reads and writes for positions with this key.

Bench: 2957947

When a TT slot is cleared, it has a verification key zero, but zero is also a valid 21-bit verification key. So a probe with this key can match an unused slot and read zeroed data as a valid TT entry.

To fix this, reserve verification key zero for unused slots. Skip TT reads and writes for positions with this key.

Bench: 2957947
@peregrineshahin

Copy link
Copy Markdown
Contributor

Should fix that by using some other mechanism to determine tthits than keys, usually people reserve internal entry depth of 0 to refer to no entry but that has some complications in Reckless where a real entry could also have that depth.. I don’t think this version of the PR will do.

@kuel27
kuel27 marked this pull request as draft August 29, 2026 16:39
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