Force time check on TB probe in search.
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Mon, 4 Jun 2018 08:31:25 +0000 (10:31 +0200)
committerStéphane Nicolet <cassio@free.fr>
Tue, 20 Nov 2018 07:00:19 +0000 (08:00 +0100)
Because of aggressive time management and optimistic assumptions
about move overhead, it's still very easy to get Stockfish to forfeit
on time when we hit an endgame and have Syzygy EGTB on a spinning
drive. The latency from serving a few thousand EGTB probes (~10ms each),
of which there can currently be up to 4000 outstanding before a time
check, will easily overwhelm the default Move Overhead of 30ms.

This problem was first raised by Gian-Carlo Pascutto and some solutions
and improvements were discussed in the following pull requests:
https://github.com/official-stockfish/Stockfish/pull/1471
https://github.com/official-stockfish/Stockfish/pull/1623
https://github.com/official-stockfish/Stockfish/pull/1783

This patch is a minimal change proposed by Marco Costalba to lower
the impact of the bug. We now force a check of the clock right after
each tablebase read.

No functional change.

src/search.cpp

index 08bf90f89845673b79b8197c40e17bab2eccc119..f4e1da977990f18d2b77e988cbbc4c1c0798370e 100644 (file)
@@ -683,6 +683,10 @@ namespace {
             TB::ProbeState err;
             TB::WDLScore wdl = Tablebases::probe_wdl(pos, &err);
 
+            // Force check of time on the next occasion
+            if (thisThread == Threads.main())
+                static_cast<MainThread*>(thisThread)->callsCnt = 0;
+
             if (err != TB::ProbeState::FAIL)
             {
                 thisThread->tbHits.fetch_add(1, std::memory_order_relaxed);