use sleeping threads

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: use sleeping threads

Post by syzygy »

Don wrote:
syzygy wrote:
Modern Times wrote:Personally I am not clear on what effect this has on the other engine when playing ponder off games.
Unless the other engine "cheats" by somehow using the cpu in non-ponder mode when it is not its turn, the option will have no effect whatsoever on the other engine.

In non-ponder mode, the Stockfish threads, and the threads of any other engine that is not buggy, will sleep (and therefore not use any resources) when the other side is to move.
It's only in ponder mode where this can be a factor - but I'm not even sure of that. In ponder mode if you do not utilize all your threads you (at least slightly) relieve the working threads of the competing program of the burden of sharing resources. However I don't know if a spinning lock has enough impact or even any impact on this since it is not heavily competing for any resources that are shared.
The spinning idle threads make it look like all threads are 100% busy all the time, even if they have nothing useful to do.

But the analysis is indeed not so simple. In ponder mode, Stockfish might actually gain from Use Sleeping Threads set to true. The reason is that with idle threads sleeping, the OS will not subtract the idle time from Stockfish's cpu quota. If the OS awards 50% of the available cpu time to Stockfish and 50% to the other engine, with idle threads sleeping the whole 50% is used for searching. On the other hand if idle threads spin instead of sleep, part of Stockfish's 50% is wasted on spinning.

The above assumes that the number of search threads for each engine is equal to the number of physical cores, and the cpu has no HT. For other configurations, the analysis is different (and depends on how search threads of each engine are distributed over the logical hyperthreads of the various cores).
Modern Times
Posts: 3546
Joined: Thu Jun 07, 2012 11:02 pm

Re: use sleeping threads

Post by Modern Times »

syzygy wrote:The spinning idle threads make it look like all threads are 100% busy all the time, even if they have nothing useful to do.
This is probably what most other engines do.