{"type": "session", "harness": "opencode", "id": "chess-0108", "name": "Stockfish Parallel Search"} {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer."}} {"type": "message", "message": {"role": "user", "content": "How does Stockfish handle multi-threaded search?"}} {"type": "message", "message": {"role": "assistant", "content": "Stockfish uses Lazy SMP - the simplest and most effective parallel search approach.\n\nEach Search::Worker owns completely independent state:\n- mainHistory, captureHistory, continuationHistory\n- rootMoves (per-thread copy with effort tracking)\n- accumulatorStack (NNUE incremental state)\n- nodes, tbHits (atomic counters for aggregation)\n\nNo locks in the search loop. Only shared mutable state:\n- Lock-free TranspositionTable (racy RelaxedAtomic)\n- Global stop atomic flag\n\nThreads diverge naturally because:\n- Different random variations in search\n- TT entries influence move ordering differently per thread\n\nThreadPool::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.\n\nNUMA awareness: Thread creation with OptionalThreadToNumaNodeBinder. Custom 8MB stack per thread. SharedHistories replicated per NUMA node. Large page allocation for TT and NNUE weights."}}