Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lift 16 Thread limit for Ryzen and future Processors #26

Closed
dangi12012 opened this issue Jan 13, 2021 · 7 comments
Closed

Lift 16 Thread limit for Ryzen and future Processors #26

dangi12012 opened this issue Jan 13, 2021 · 7 comments

Comments

@dangi12012
Copy link

The 1gb and 16 thread limit is really bad compared to native stockfish-avx performance.
On Ryzen and future intel processors (anything above 8 cores) you lose speed.

So i would suggest setting threadpool size up to 64 threads. (This will yield +100% nps)
I dont know if 1GB is a hard limit but i would suggest 4GB. (This probably will yield +5%)

stockfish.wasm is currently limiting analysis performance on lichess.org.

@niklasf
Copy link
Member

niklasf commented Jan 13, 2021

Unfortunately browsers aren't quite ready for this, with restrictions on the number of web workers for threads and allocated memory. (And it does make some sense that vendors are careful, not allowing random websites to allocate 4GB of RAM and run extremely CPU intensive tasks.) Will raise the limits, when it becomes possible in mainstream browsers.

A browser extension to make native Stockfish available might be a good approach, though: lichess-org/lila#7909

@niklasf niklasf closed this as completed Jan 13, 2021
@dangi12012
Copy link
Author

dangi12012 commented Jan 13, 2021

@niklasf @apetresc
Well some browsers for sure arent but you could always check if you are running chrome 80+ no?
Chromium has no thread limit as far as i am aware of. No such mention in the Documentation

@niklasf
Copy link
Member

niklasf commented Jan 13, 2021

Ok, I guess we can consider it a bit more carefully.

Is there a way to feature test that, rather than checking browser versions? What's navigator.hardwareConcurrency for you in Firefox and Chrome?

The memory limit is harder. 4 GiB is the maximum for wasm32, but we can't use all memory for hashtables. So 2 GiB would be the only feasible power of two. But even for that, it's not clear, that there will always be I continguous slice of 2 GiB available, especially when resizing the hashtable. navigator.deviceMemory for feature detection is only available in Chrome, and it goes to a maximum of 8 GiB, which is not a lot of margin for other stuff on the system (including perhaps even a second multi-variant instance, as used on Lichess when switching between study chapters). Overall, I don't think it's worth the small strength gain.

@niklasf niklasf reopened this Jan 13, 2021
@niklasf
Copy link
Member

niklasf commented Jan 13, 2021

Oh, also let's not forget about the memory overhead of threads. Extrapolating #4 (comment), we'd need more than 1 GiB of memory for threads alone. A mitigating factor is that someone with 64 threads will very likely also have a bit of RAM to go with it.

@dangi12012
Copy link
Author

dangi12012 commented Jan 13, 2021

Memory is not the issue. Going in hashtable size from 1 to 4GiB does not yield great increase so 1gb is ok i think. (only few percentage after 256mb in my experience)
Keep in mind Firefox has 3.77% market share and is declining - and Microsoft just switched to Chromium.

[16 Cores] AMD Ryzen 9 5950X
[Chrome] navigator.hardwareConcurrency = 32
[Firefox] navigator.hardwareConcurrency = 16

[12 Cores] AMD Ryzen 9 3900X
[Chrome] navigator.hardwareConcurrency = 24
[Firefox] navigator.hardwareConcurrency = 16

I think you could savely allow up to navigator.hardwareConcurrency for stockfish.wasm - chess scales very well with cores
So the max_threads is not const but a readonly variable initialized once.

@niklasf
Copy link
Member

niklasf commented Jan 13, 2021

Oh, that's great! I was expecting Firefox to give 32 or 64, and then fail when allocating more than 20.

@niklasf
Copy link
Member

niklasf commented Jan 14, 2021

Increase to 32 published as v0.9.1, and deployed to the Lichess testing site https://lichess.dev/analysis (via lichess-org/lila@2703beb). Can you please confirm that it works in Chrome and Firefox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants