Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reduce_to_prover #148

Merged
merged 6 commits into from Mar 26, 2019
Merged

Add reduce_to_prover #148

merged 6 commits into from Mar 26, 2019

Conversation

mrmr1993
Copy link
Member

This PR adds reduce_to_prover, which

  • takes a Checked.t
  • precomputes everything inside the Checked.t except for As_prover blocks
  • stores the As_prover blocks as maps over the Run_state.t
  • bundles them together into 1 function, wraps it in a Checked.Direct

Effectively, this caches everything that can be known ahead of time in closures around the As_prover blocks, so that creating a proof from reduce_to_prover Data_spec.[...] main only runs the As_prover blocks from main.

Combined with #145, this gives:

$ `which time` dune exec coda tra -- -witness-reduced -repeat 4
[1] Base constraint system satisfied
[2] Base constraint system satisfied
[3] Base constraint system satisfied
[4] Base constraint system satisfied
24.81user 0.99system 0:25.91elapsed 99%CPU (0avgtext+0avgdata 955468maxresident)k
0inputs+3432outputs (0major+371949minor)pagefaults 0swaps
$ `which time` dune exec coda tra -- -witness-reduced -repeat 10
[1] Base constraint system satisfied
[2] Base constraint system satisfied
[3] Base constraint system satisfied
[4] Base constraint system satisfied
[5] Base constraint system satisfied
[6] Base constraint system satisfied
[7] Base constraint system satisfied
[8] Base constraint system satisfied
[9] Base constraint system satisfied
[10] Base constraint system satisfied
55.83user 1.18system 0:56.95elapsed 100%CPU (0avgtext+0avgdata 987632maxresident)k
0inputs+3440outputs (0major+547695minor)pagefaults 0swaps

vs. without calling reduce_to_prover:

$ `which time` dune exec coda tra -- -witness-only -repeat 4
[1] Base constraint system satisfied
[2] Base constraint system satisfied
[3] Base constraint system satisfied
[4] Base constraint system satisfied
49.79user 1.07system 0:51.56elapsed 98%CPU (0avgtext+0avgdata 125312maxresident)k
23544inputs+3432outputs (8major+322816minor)pagefaults 0swaps

That is, reduce_to_prover runs in 45% of the time for 10 runs, or 50% for 4 runs.

(I overwrote my benchmarks file by mistake, so I haven't included a comparison with current master..)

@mrmr1993 mrmr1993 requested a review from imeckler March 20, 2019 19:53
@mrmr1993
Copy link
Member Author

Without #145:

$ `which time` dune exec coda tra -- -witness-reduced -repeat 4
[1] Base constraint system satisfied
[2] Base constraint system satisfied
[3] Base constraint system satisfied
[4] Base constraint system satisfied
28.32user 1.08system 0:29.89elapsed 98%CPU (0avgtext+0avgdata 983228maxresident)k
20408inputs+3456outputs (6major+437105minor)pagefaults 0swaps
$ `which time` dune exec coda tra -- -witness-reduced -repeat 10
[1] Base constraint system satisfied
[2] Base constraint system satisfied
[3] Base constraint system satisfied
[4] Base constraint system satisfied
[5] Base constraint system satisfied
[6] Base constraint system satisfied
[7] Base constraint system satisfied
[8] Base constraint system satisfied
[9] Base constraint system satisfied
[10] Base constraint system satisfied
67.37user 1.53system 1:08.83elapsed 100%CPU (0avgtext+0avgdata 1096508maxresident)k
0inputs+3456outputs (0major+714216minor)pagefaults 0swaps
$ `which time` dune exec coda tra -- -witness-only -repeat 4
[1] Base constraint system satisfied
[2] Base constraint system satisfied
[3] Base constraint system satisfied
[4] Base constraint system satisfied
58.82user 1.12system 0:59.87elapsed 100%CPU (0avgtext+0avgdata 133016maxresident)k
0inputs+3456outputs (0major+459649minor)pagefaults 0swaps

src/snark0.ml Outdated
let s', (_ : unit option) = run_as_prover (Some x) s in
f s' )
, a )
| Pure x -> ((fun s -> s), x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this allocates but you could also do Fn.id

@mrmr1993 mrmr1993 merged commit 62eb2c2 into master Mar 26, 2019
@mrmr1993 mrmr1993 deleted the feature/as-prover-flatten branch March 26, 2019 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants