Max Threads / Hash size

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
AxolotlFever
Posts: 46
Joined: Sun Nov 11, 2018 8:26 pm
Location: Germany
Full name: Louis Mackenzie-Smith
Contact:

Max Threads / Hash size

Post by AxolotlFever » Thu May 09, 2019 2:57 pm

Hi all,

how do engines decide what the maximum number of allowed threads should be? I am limited to a 4 core machine, and using a large number of threads does not improve playing strength, and I do not know what would happen if my engine was run on something powerful. Same with hash sizes.

So the question is, what number should I pick for max threads, and max hash size, given that I am not sure how I could test it?

Thanks kindly,
Louis

Joost Buijs
Posts: 896
Joined: Thu Jul 16, 2009 8:47 am
Location: Almere, The Netherlands

Re: Max Threads / Hash size

Post by Joost Buijs » Fri May 10, 2019 6:11 am

AxolotlFever wrote:
Thu May 09, 2019 2:57 pm

how do engines decide what the maximum number of allowed threads should be? I am limited to a 4 core machine, and using a large number of threads does not improve playing strength, and I do not know what would happen if my engine was run on something powerful. Same with hash sizes.

So the question is, what number should I pick for max threads, and max hash size, given that I am not sure how I could test it?
It depends on what kind of CPU you have, if it has Hyperthreading or SMT you can try a number of threads equal to the number of physical cores or even some more if you have an efficient parallel algorithm. On CPU's without Hyperthreading it might be wise to leave at least one core dedicated to the OS.

It also depends on how you handle the parallel algorithm, some engines have their threads spinning 100% of the time waiting for work (this really hogs the OS when using all available cores), others use condition-variables or events to kickoff a thread when it has work to do. So just do what works best for you.

I usually see a slowdown when the hash size get larger than (let say) 1 GB. this happens because the TLB gets over stressed, you can improve on this by using large or huge pages in memory but this is cumbersome to use. For bullet and blitz games 1 GB. is more than enough and for games with longer time controls I would not go higher than 8 GB. Other people can have a different opinion about this though.

Post Reply