Skip to content

Commit

Permalink
Merge pull request #1456 from o1-labs/perf/apple-silicon
Browse files Browse the repository at this point in the history
Improve performance by reverting Apple silicon workaround (root problem is fixed upstream)
  • Loading branch information
jackryanservia authored Feb 22, 2024
2 parents 7f1745a + 9236c38 commit 24537f7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 0 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/bindings
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
17 changes: 17 additions & 0 deletions src/lib/proof-system/workers.ts
Original file line number Diff line number Diff line change
@@ -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;
};

0 comments on commit 24537f7

Please sign in to comment.