]> git.sesse.net Git - stockfish/commit - src/search.h
Get rid of timer thread
authorMarco Costalba <mcostalba@gmail.com>
Tue, 3 Nov 2015 10:15:14 +0000 (11:15 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 3 Nov 2015 10:27:00 +0000 (11:27 +0100)
commit9c9205860c5ab0e4f3180298e3f7082be259772c
treeed5a51cf3a9d6dff370e5acf1b58d9b5f903791d
parent27c5cb59127101d834636d4faa0062d4e7bd05ce
Get rid of timer thread

Unfortunately std::condition_variable::wait_for()
is not accurate in general case and the timer thread
can wake up also after tens or even hundreds of
millisecs after time has elapsded. CPU load, process
priorities, number of concurrent threads, even from
other processes, will have effect upon it.

Even official documentation says: "This function may
block for longer than timeout_duration due to scheduling
or resource contention delays."

So retire timer and use a polling scheme based on a
local thread counter that counts search() calls and
a small trick to keep polling frequency constant,
independently from the number of threads.

Tested for no regression at very fast TC 2+0.05 th 7:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 32969 W: 6720 L: 6620 D: 19629

TC 2+0.05 th 1:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 7765 W: 1917 L: 1765 D: 4083

And at STC TC, both single thread
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 15587 W: 3036 L: 2905 D: 9646

And with 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 8149 W: 1367 L: 1227 D: 5555

bench: 8639247
src/search.cpp
src/search.h
src/thread.cpp
src/thread.h