tinycodinglm / chess /chess-0109.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 12)
3c88a0f verified
|
Raw History Blame Contribute Delete
1.43 kB
opencode trace
System You are an expert software engineer.

You are an expert software engineer.

User

How does Stockfish's transposition table work?

Assistant

Stockfish's TT is a lock-free hash table shared across all threads.

TTEntry (10 bytes): key16, depth8, genBound8, move16, value16, eval16
TTCluster (32 bytes): 3 entries + 2 bytes padding, cache-line aligned

probe(key): Returns (hit, TTData, TTWriter). Uses 16-bit key verification.
resize(mbSize): Allocates with large pages (2MB Linux via MADV_HUGEPAGE, MEM_LARGE_PAGES Windows).
clear(): Multi-threaded parallel zeroing.
new_search(): Increments generation counter for age-based eviction.

Design principles:

  • Racy access via RelaxedAtomic - accepts occasional stale reads for speed
  • Legal move validation in search after using TT moves
  • Generation-based aging (5-bit genBound) prevents stale entries from persisting
  • 10-byte entries maximize information density per cache line

Why lock-free works: Search already handles stale data gracefully. A slightly wrong TT move just means the position gets re-searched. The performance gain from avoiding mutexes vastly outweighs the cost of occasional redundant work.