Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Lockless transposition table

Also known as Lockless hashing, XOR-keyed transposition table

adversarial game-tree-search

A lockless transposition table lets several threads probe and store entries without locks. Each entry is packed into one 64-bit word, and the slot holds that word next to a second word, the word XOR-ed with the position's key; a probe reads both and takes the entry only if XOR-ing them gives the key back. If another thread wrote the slot in between, the check fails and the probe misses instead of returning a torn entry. The packing has limits: move and score must fit 48 bits together, entries deeper than 62 plies are not stored, and the slot checks 64 bits of the key. Here it is PackedTable, behind the parallel feature; use it for Lazy SMP when moves and scores are small, and the locked SharedTable otherwise.

Pseudocode

algorithm Store(TT, key, entry)input: table TT, the position's key, the entry to storew ← pack(entry)                              ▷ fails if too deep to stores ← TT[low bits of key]s.data ← ws.check ← w ⊕ key                            ▷ two separate atomic writesfunction Probe(TT, key)s ← TT[low bits of key]w, c ← s.data, s.check                       ▷ two separate atomic reads, no lockif w ⊕ c ≠ key thenreturn nil                                 ▷ empty, another position, or a torn writereturn unpack(w)

In the crates

  • game-tree-search feature parallel

    Entries packed into one 64-bit word stored next to that word XOR-ed with the key, so threads probe and store without locks and a torn entry reads as a miss.

    PackedTablePacked

Lineage

Comes from

builds on Transposition table

Led to

Lazy SMP combines it

Papers

  1. A lockless transposition-table implementation for parallel search Robert M. Hyatt, Timothy Mann · 2002· ICGA Journal introduces doi 10.3233/icg-2002-25104