Skip to content

Commit

Permalink
Merge pull request #1373 from o1-labs/perf/field-inverse
Browse files Browse the repository at this point in the history
Faster TS field inverse
  • Loading branch information
mitschabaude authored Jan 26, 2024
2 parents fdbfc36 + b8e90d5 commit f60ef63
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed

- Improve performance of Poseidon hashing by a factor of 13x https://github.com/o1-labs/o1js/pull/1378
- Improve performance of Wasm Poseidon hashing by a factor of 13x https://github.com/o1-labs/o1js/pull/1378
- Speeds up local blockchain tests without proving by ~40%
- Improve performance of Field inverse https://github.com/o1-labs/o1js/pull/1373
- Speeds up proving by ~2-4%

## [0.15.3](https://github.com/o1-labs/o1js/compare/1ad7333e9e...be748e42e)

Expand Down
2 changes: 1 addition & 1 deletion src/bindings
12 changes: 6 additions & 6 deletions src/examples/utils/tic-toc.node.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* Helper for printing timings, in the spirit of Python's `tic` and `toc`.
*
* This is a slightly nicer version of './tic-tic.ts' which only works in Node.
* This is a slightly nicer version of './tic-toc.ts' which only works in Node.
*/

export { tic, toc };

let timingStack: [string, number][] = [];
let i = 0;
let timingStack: [string | undefined, number][] = [];

function tic(label = `Run command ${i++}`) {
process.stdout.write(`${label}... `);
function tic(label?: string) {
if (label) process.stdout.write(`${label}... `);
timingStack.push([label, performance.now()]);
}

function toc() {
let [label, start] = timingStack.pop()!;
let time = (performance.now() - start) / 1000;
process.stdout.write(`\r${label}... ${time.toFixed(3)} sec\n`);
if (label) process.stdout.write(`\r${label}... ${time.toFixed(3)} sec\n`);
return time;
}
9 changes: 4 additions & 5 deletions src/examples/utils/tic-toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

export { tic, toc };

let timingStack: [string, number][] = [];
let i = 0;
let timingStack: [string | undefined, number][] = [];

function tic(label = `Run command ${i++}`) {
console.log(`${label}... `);
function tic(label?: string) {
if (label) console.log(`${label}... `);
timingStack.push([label, performance.now()]);
}

function toc() {
let [label, start] = timingStack.pop()!;
let time = (performance.now() - start) / 1000;
console.log(`\r${label}... ${time.toFixed(3)} sec\n`);
if (label) console.log(`${label}... ${time.toFixed(3)} sec`);
return time;
}
7 changes: 7 additions & 0 deletions src/lib/util/assert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { assert };

function assert(stmt: boolean, message?: string): asserts stmt {
if (!stmt) {
throw Error(message ?? 'Assertion failed');
}
}
18 changes: 18 additions & 0 deletions src/lib/util/tic-toc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Helper for printing timings, in the spirit of Python's `tic` and `toc`.
*/

export { tic, toc };

let timingStack: [string | undefined, number][] = [];

function tic(label?: string) {
timingStack.push([label, performance.now()]);
}

function toc() {
let [label, start] = timingStack.pop()!;
let time = (performance.now() - start) / 1000;
if (label) console.log(`${label}... ${time.toFixed(3)} sec`);
return time;
}
2 changes: 1 addition & 1 deletion src/mina
Submodule mina updated 0 files
1 change: 1 addition & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.json",
"include": [
"./src/**/*.unit-test.ts",
"./src/lib/**/*.ts",
"./src/snarky.js",
"./src/bindings/js/wrapper.js"
],
Expand Down

0 comments on commit f60ef63

Please sign in to comment.