use sleeping threads

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

Moderator: Ras

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

Re: use sleeping threads?

Post by syzygy »

"Use Sleeping Threads" refers to what a thread does when it is waiting for work. If set to true, the thread sleeps. If set to false, the thread spins.

If you use hyperthreading, i.e. if you use 8 threads on a cpu with 4 cores and 8 logical hardware threads, then setting "Use Sleeping Threads" to true should give a small benefit.

This is because a spinning hyperthread takes away resources from the other hyperthread on the same core. (Using the "pause" instruction inside the spin loop helps a bit but does completely solve the problem.) If the hyperthread instead sleeps, the OS will bring it in a state where it does not use any resources.

If you set the number of threads equal to the number of cores and run Stockfish on an otherwise idle machine, then setting "Use Sleeping Threads" to false should normally give somewhat higher nps. In this case it does not matter that a spinning thread takes away resources from the other hyperthread on the same core, because that other hyperthread is not doing anything anyway (it will in fact be sleeping too).
User avatar
Matthias Gemuh
Posts: 3245
Joined: Thu Mar 09, 2006 9:10 am

Re: use sleeping threads?

Post by Matthias Gemuh »

syzygy wrote:"Use Sleeping Threads" refers to what a thread does when it is waiting for work. If set to true, the thread sleeps. If set to false, the thread spins.

... .
"Use" is the wrong verb if you want something to sleep.
"Let Threads Sleep" is better terminology if "true" makes threads sleep.

Matthias.
My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
shrapnel
Posts: 1339
Joined: Fri Nov 02, 2012 9:43 am
Location: New Delhi, India

Re: use sleeping threads

Post by shrapnel »

Graham Banks wrote:
Joerg Oster wrote:No.
Afaik, it means, threads without work should sleep and not keep spinning. See http://talkchess.com/forum/viewtopic.ph ... 14&t=37574
Confusing use of language.
Should be changed to Non-use of sleeping threads or something that more correctly indicates what is meant.
Perhaps because English isn't the first language of the main Stockfish authors, although their Programming skills are second to none ! You should see their notes on the Stockfish Development page...brutal, merciless SLAUGHTER of the English language :lol:
i7 5960X @ 4.1 Ghz, 64 GB G.Skill RipJaws RAM, Twin Asus ROG Strix OC 11 GB Geforce 2080 Tis
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: use sleeping threads

Post by mcostalba »

shrapnel wrote:
Graham Banks wrote:
Joerg Oster wrote:No.
Afaik, it means, threads without work should sleep and not keep spinning. See http://talkchess.com/forum/viewtopic.ph ... 14&t=37574
Confusing use of language.
Should be changed to Non-use of sleeping threads or something that more correctly indicates what is meant.
Perhaps because English isn't the first language of the main Stockfish authors, although their Programming skills are second to none ! You should see their notes on the Stockfish Development page...brutal, merciless SLAUGHTER of the English language :lol:
Here "sleeping threads" is assumed to be the name of the setup, so should be read:

Use "sleeping threads"

Like

Use "ponder on", use "infinite analysis", etc..

It is true that I am not native speaker so my English is poor, but because instead I see that you are mother-language could I ask to please suggest a better name for the option ? (assuming that you have understood what we are talking about....it is not a trivial assumption but today I am in a good mood).
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: use sleeping threads

Post by zullil »

mcostalba wrote:
could I ask to please suggest a better name for the option ?
Please see http://talkchess.com/forum/viewtopic.ph ... 56&t=48612
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: use sleeping threads

Post by mcostalba »

zullil wrote:
mcostalba wrote:
could I ask to please suggest a better name for the option ?
Please see http://talkchess.com/forum/viewtopic.ph ... 56&t=48612
hmmm I am not sure this is better.

I'd prefer simply "sleeping threads" without 'use', in the same way of 'pondering' or 'infinite analysis'....but I'm curious to see what kind of suggestion comes out from the guy from Oxfordshire here above.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: use sleeping threads

Post by zullil »

mcostalba wrote:
hmmm I am not sure this is better.
"Use" is problematic. Even "Use Search Log" would be better as "Write Search Log", since the engine writes the file, rather than uses (ie, reads) the file. My opinion, anyway.
mcostalba wrote: .but I'm curious to see what kind of suggestion comes out from the guy from Oxfordshire here above.
:lol:
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: use sleeping threads

Post by michiguel »

mcostalba wrote:
zullil wrote:
mcostalba wrote:
could I ask to please suggest a better name for the option ?
Please see http://talkchess.com/forum/viewtopic.ph ... 56&t=48612
hmmm I am not sure this is better.

I'd prefer simply "sleeping threads" without 'use', in the same way of 'pondering' or 'infinite analysis'....but I'm curious to see what kind of suggestion comes out from the guy from Oxfordshire here above.
First of all, I do not think there is anything wrong with the original, but then again, I am not a native speaker :-)

However, if you are looking for alternatives, you may want to consider

"spinning threads" = on/off
(the action here is to spin, rather than sleep, which implies lack of action)

or
"threads type" = spinning/sleeping
(It is conceivable the possibility to have more than two options. So both options here are spelled out)

Miguel
User avatar
Matthias Gemuh
Posts: 3245
Joined: Thu Mar 09, 2006 9:10 am

Re: use sleeping threads

Post by Matthias Gemuh »

michiguel wrote:...
"threads type" = spinning/sleeping
...
Miguel
... or
"Idle Threads" = spinning/sleeping.
My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
Modern Times
Posts: 3759
Joined: Thu Jun 07, 2012 11:02 pm

Re: use sleeping threads?

Post by Modern Times »

Matthias Gemuh wrote:
syzygy wrote:"Use Sleeping Threads" refers to what a thread does when it is waiting for work. If set to true, the thread sleeps. If set to false, the thread spins.

... .
"Use" is the wrong verb if you want something to sleep.
"Let Threads Sleep" is better terminology if "true" makes threads sleep.

Matthias.
This is good.

I'm still confused as to what the currently worded parameter does. I had interpreted "Use Sleeping Threads" TRUE as meaning - put those threads to work, don't let them sleep. But from what I read above, it is the opposite ?