Repository navigation
Report nodes and nps summed over all search threads - #69
Merged
Merged
Conversation
`info nodes` and `nps` counted only the main thread, so with Lazy SMP they showed roughly one thread's share of the work. Each searcher now owns a NodeCounter that only its thread writes, with relaxed atomic loads and stores that compile to a plain add, and the main engine sums its helpers' counters when it prints info, as Stockfish does. Time management and EBF still use the main thread's own iteration counts, so the search is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bench: 696698
Preserve total node publication across the updated search, quiescence and ProbCut paths. Isolate reporting-enabled search instantiations from ordinary-search LTO while sharing the typed search algorithm. Bench: 993713
Bench: 993713 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #65. Merge #65 first, then retarget this PR to its base if GitHub does not do it automatically.
What changes
info nodesandnpsnow count every search thread, as Stockfish does. Before, they counted only the main thread, so withThreads 4the engine reported roughly a quarter of its real work.Searcherowns aNodeCounter. Only that thread writes it; the main engine reads every thread's counter when it printsinfo. Relaxed atomic load and store are enough because there is a single writer. They compile to the sameaddas a plain counter, unlike Stockfish'sfetch_add, which needs a locked instruction.SearchThreadhands the helper engines to the main engine before the search starts and takes them back after the main thread is joined, so no counter is read after its engine is destroyed.Verification
Search identity: at depth 11 on 30 positions, every
infoline exceptnodes,npsandtimeis identical to UCI: go nodes, full node counts and FEN validation #65 with both GCC 15 and clang 23. Single-thread node totals are identical too: 7,274,560.Threads: one position, 5 s per run, CPUs 16–19:
These timings were taken while another build loaded the machine, so the nps values are low in absolute terms. The 4-thread total is about 3.9 times the single-thread one.
Machine code:
[[gnu::always_inline]]; without it GCC made a call per node.mov,add,mov) plus register reshuffles, 5–10 instructions out of about 1,600 per function.Speed: wall-clock timing over five alternating rounds is within noise. The machine was loaded by an unrelated build, so this only rules out a large slowdown.
Tests:
NodeCounting.ReportsNodesOfAllThreadschecks that the reported nodes equal the main thread's count plus the helper's.🤖 Generated with Claude Code