-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #683 from o1-labs/fix/apple-silicon-performance
Fix/apple silicon performance
- Loading branch information
Showing
14 changed files
with
1,648 additions
and
978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getGPUTier } from 'detect-gpu'; | ||
|
||
export { getEfficientNumWorkers as default }; | ||
|
||
// Return the most efficient number of workers for the platform we're running | ||
// on. This is required because of an issue with Apple silicon that's outlined | ||
// here: https://bugs.chromium.org/p/chromium/issues/detail?id=1228686 | ||
async function getEfficientNumWorkers() { | ||
let gpuTier = await getGPUTier(); | ||
let numCpus = navigator.hardwareConcurrency; | ||
// gpuTier.gpu is undefined if page was rendered server side | ||
let gpuModel = gpuTier.gpu || 'SSR'; | ||
|
||
var numWorkers = | ||
{ | ||
'apple m1': 2, | ||
'apple m1 pro': numCpus === 10 ? 3 : 2, | ||
'apple m1 max': 3, | ||
'apple m1 ultra': 7, | ||
'apple m2': 2, | ||
'SSR': ((numCpus / 6) >> 0) + 1, | ||
}[gpuModel] || numCpus - 1; | ||
|
||
return numWorkers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.