diff --git a/CHANGELOG.md b/CHANGELOG.md index c2784c8251..07f9ad9c53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Support for custom network identifiers other than `mainnet` or `testnet` https://github.com/o1-labs/o1js/pull/1444 - `PrivateKey.randomKeypair()` to generate private and public key in one command https://github.com/o1-labs/o1js/pull/1446 +- `setNumberOfWorkers()` to allow developer to override the number of workers used during compilation and proof generation/verification https://github.com/o1-labs/o1js/pull/1456 + +### Changed + +- Improve all-around performance by reverting the Apple silicon workaround (https://github.com/o1-labs/o1js/pull/683) as the root problem is now fixed upstream https://github.com/o1-labs/o1js/pull/1456 ### Deprecated diff --git a/package-lock.json b/package-lock.json index 5cba08e5e2..5059ee4c27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "blakejs": "1.2.1", "cachedir": "^2.4.0", - "detect-gpu": "^5.0.5", "isomorphic-fetch": "^3.0.0", "js-sha256": "^0.9.0", "reflect-metadata": "^0.1.13", @@ -2641,14 +2640,6 @@ "node": ">=0.10.0" } }, - "node_modules/detect-gpu": { - "version": "5.0.37", - "resolved": "https://registry.npmjs.org/detect-gpu/-/detect-gpu-5.0.37.tgz", - "integrity": "sha512-EraWs84faI4iskB4qvE39bevMIazEvd1RpoyGLOBesRLbiz6eMeJqqRPHjEFClfRByYZzi9IzU35rBXIO76oDw==", - "dependencies": { - "webgl-constants": "^1.1.1" - } - }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -6652,11 +6643,6 @@ "makeerror": "1.0.12" } }, - "node_modules/webgl-constants": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/webgl-constants/-/webgl-constants-1.1.1.tgz", - "integrity": "sha512-LkBXKjU5r9vAW7Gcu3T5u+5cvSvh5WwINdr0C+9jpzVB41cjQAP5ePArDtk/WHYdVj0GefCgM73BA7FlIiNtdg==" - }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/package.json b/package.json index 9a01de0313..f625b3cc55 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,6 @@ "dependencies": { "blakejs": "1.2.1", "cachedir": "^2.4.0", - "detect-gpu": "^5.0.5", "isomorphic-fetch": "^3.0.0", "js-sha256": "^0.9.0", "reflect-metadata": "^0.1.13", diff --git a/src/bindings b/src/bindings index a7ade0db48..b33a7eab09 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit a7ade0db4879afeb603c246c967098e0ca6170b5 +Subproject commit b33a7eab09f6fda33b982a6cde67a51507b6b72e diff --git a/src/index.ts b/src/index.ts index 865bb01d05..6445ab3706 100644 --- a/src/index.ts +++ b/src/index.ts @@ -117,6 +117,8 @@ export { Crypto } from './lib/crypto.js'; export type { NetworkId } from './mina-signer/mina-signer.js'; +export { setNumberOfWorkers } from './lib/proof-system/workers.js'; + // experimental APIs import { memoizeWitness } from './lib/provable.js'; export { Experimental }; diff --git a/src/lib/proof-system/workers.ts b/src/lib/proof-system/workers.ts new file mode 100644 index 0000000000..9076ad7554 --- /dev/null +++ b/src/lib/proof-system/workers.ts @@ -0,0 +1,17 @@ +export { workers, setNumberOfWorkers }; + +const workers = { + numWorkers: undefined as number | undefined, +}; + +/** + * Set the number of workers to use for parallelizing the proof generation. By default the number of workers is set to the number of physical CPU cores on your machine, but there may be some instances where you want to set the number of workers manually. Some machines may have a large number of cores, but not enough memory to support that many workers. In that case, you can set the number of workers to a lower number to avoid running out of memory. On the other hand, some machines with heterogeneous cores may benefit from setting the number of workers to a lower number to avoid contention between core types if load-link/store-conditional multithreading is used. Feel free to experiment and see what works best for your use case. Maybe you can squeeze slightly more performance out by tweaking this value :) + + * @example + * ```typescript + * setNumberOfWorkers(2); // set the number of workers to 2 + * ``` + */ +const setNumberOfWorkers = (numWorkers: number) => { + workers.numWorkers = numWorkers; +};