Skip to content

Commit

Permalink
fix(web): clamp default number of threads to 3
Browse files Browse the repository at this point in the history
Resolves: #1511

Firefox returns some random number for `navigator?.hardwareConcurrency`. In my case is was `16`, which does not correspond to the avaialble hardware in any way.

Here I additionally clamp the value obtained from `navigator?.hardwareConcurrency` to a range from `DEFAULT_NUM_THREADS` to `MAXIMUM_NUM_THREADS` (currently  from 2 to 3).

This solves it for Firefox, but I don't have a physical mac handy to test Safari. Not sure if testing on Browserstack is accurate - it probably runs on a VM.
  • Loading branch information
ivan-aksamentov committed Jul 12, 2024
1 parent 4d62bb7 commit 28408f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/nextclade-web/src/helpers/getNumThreads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function getNumThreads() {
}

let numThreads = navigator?.hardwareConcurrency ?? DEFAULT_NUM_THREADS
numThreads = Math.max(numThreads, DEFAULT_NUM_THREADS)
numThreads = clamp(numThreads, DEFAULT_NUM_THREADS, MAXIMUM_NUM_THREADS)

// Detect how much memory is available and adjust number of threads if per-thread memory is too low
const guess = guessNumThreads()
Expand Down

0 comments on commit 28408f5

Please sign in to comment.