Improve maximum hash table memory estimation. #10190
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some browsers don't report navigator.deviceMemory to keep
fingerprintability to a minimum. Currently, lila assumes that
such a machine provides at most 256MB RAM, thus setting a 32MB
max hashtable limit.
This was a reasonable starting point when Stockfish was pure
JavaScript in a single thread, but with up 16 core WASM support
this limitation is a bit more painful.
Modify the memory estimation: if the browser is modern enough to
have full WASM/SharedArrayBuffer support, and thus run the
parallel WASM versions, assume the machine has at least 2GB of
RAM. If it doesn't, assume 512MB. This gives a maximum hashtable
of 256MB and 64MB, respectively.
The assumed minimum RAM values roughly correspond to Firefox's
official system requirements for the 32-bit and 64-bit version.
Although that doesn't necessarily correspond to WASM support,
it's a reasonable starting point for a guess.
Note that guessing wrong isn't harmful, it just gives the user
the option to shoot themselves in the foot, and even that is
limited because we still only use 1/8th of the guessed system RAM.