Git Product home page Git Product logo

Comments (7)

niklasf avatar niklasf commented on May 19, 2024

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

from stockfish.wasm.

dangi12012 avatar dangi12012 commented on May 19, 2024

@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

from stockfish.wasm.

niklasf avatar niklasf commented on May 19, 2024

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.

from stockfish.wasm.

niklasf avatar niklasf commented on May 19, 2024

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.

from stockfish.wasm.

dangi12012 avatar dangi12012 commented on May 19, 2024

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.

from stockfish.wasm.

niklasf avatar niklasf commented on May 19, 2024

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

from stockfish.wasm.

niklasf avatar niklasf commented on May 19, 2024

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?

from stockfish.wasm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.