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

You are an expert software engineer.

User

How does Stockfish handle multi-threaded search?

Assistant

Stockfish uses Lazy SMP - the simplest and most effective parallel search approach.

Each Search::Worker owns completely independent state:

  • mainHistory, captureHistory, continuationHistory
  • rootMoves (per-thread copy with effort tracking)
  • accumulatorStack (NNUE incremental state)
  • nodes, tbHits (atomic counters for aggregation)

No locks in the search loop. Only shared mutable state:

  • Lock-free TranspositionTable (racy RelaxedAtomic)
  • Global stop atomic flag

Threads diverge naturally because:

  • Different random variations in search
  • TT entries influence move ordering differently per thread

ThreadPool::get_best_thread() uses vote-based selection, not highest-score selection. This is more robust because the best-position evaluation doesn't always mean the best move.

NUMA awareness: Thread creation with OptionalThreadToNumaNodeBinder. Custom 8MB stack per thread. SharedHistories replicated per NUMA node. Large page allocation for TT and NNUE weights.