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

Pedersen hasher consuming more memory than expected #841

Closed
schomatis opened this issue Aug 26, 2019 · 2 comments
Closed

Pedersen hasher consuming more memory than expected #841

schomatis opened this issue Aug 26, 2019 · 2 comments
Assignees

Comments

@schomatis
Copy link
Contributor

schomatis commented Aug 26, 2019

A sector size of 1 MiB takes ~700 MiB of RSS, this is a lot but it actually seems like a fixed amount since much bigger sector sizes (256 MiB) also consumed something close to that, see #837 (comment). (edit: missed a digit, it was 7 GiB for 256 MiB, so I'm not sure what's the ratio for the fixed and variable memory consumption here)

RUST_LOG=trace /usr/bin/time -v cargo run --example zigzag -- --size 1024 --hasher pedersen


    Finished dev [unoptimized + debuginfo] target(s) in 0.30s
     Running `target/debug/examples/zigzag --size 1024 --hasher pedersen`
 2019-08-26T02:20:15.659 INFO  zigzag > hasher: pedersen
 2019-08-26T02:20:15.659 INFO  zigzag > data size: 1 MB
 2019-08-26T02:20:15.659 INFO  zigzag > m: 5
 2019-08-26T02:20:15.659 INFO  zigzag > expansion_degree: 8
 2019-08-26T02:20:15.659 INFO  zigzag > layer_challenges: Fixed { layers: 10, count: 1 }
 2019-08-26T02:20:15.660 INFO  zigzag > all_challenges: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
 2019-08-26T02:20:15.660 INFO  zigzag > total_challenges: 10
 2019-08-26T02:20:15.660 INFO  zigzag > layers: 10
 2019-08-26T02:20:15.660 INFO  zigzag > partitions: 1
 2019-08-26T02:20:15.660 INFO  zigzag > circuit: false
 2019-08-26T02:20:15.660 INFO  zigzag > groth: false
 2019-08-26T02:20:15.661 INFO  zigzag > bench: false
 2019-08-26T02:20:15.661 INFO  zigzag > running setup
 2019-08-26T02:20:15.662 INFO  zigzag > setup complete
 2019-08-26T02:20:15.662 INFO  zigzag > generating zeroed data
 2019-08-26T02:20:15.662 INFO  zigzag > running replicate
 2019-08-26T02:20:15.794 INFO  storage_proofs::layered_drgporep > encoding (layer: 0)
 2019-08-26T02:21:06.675 INFO  storage_proofs::layered_drgporep > encoding (layer: 1)
 2019-08-26T02:21:57.314 INFO  storage_proofs::layered_drgporep > encoding (layer: 2)
 2019-08-26T02:22:48.215 INFO  storage_proofs::layered_drgporep > encoding (layer: 3)
 2019-08-26T02:23:42.711 INFO  storage_proofs::layered_drgporep > encoding (layer: 4)
 2019-08-26T02:24:37.125 INFO  storage_proofs::layered_drgporep > encoding (layer: 5)
 2019-08-26T02:24:56.505 INFO  storage_proofs::layered_drgporep > returning tree (layer: 3)
 2019-08-26T02:24:59.571 INFO  storage_proofs::layered_drgporep > returning tree (layer: 4)
 2019-08-26T02:24:59.718 INFO  storage_proofs::layered_drgporep > returning tree (layer: 2)
 2019-08-26T02:25:06.015 INFO  storage_proofs::layered_drgporep > returning tree (layer: 1)
 2019-08-26T02:25:09.417 INFO  storage_proofs::layered_drgporep > returning tree (layer: 0)
 2019-08-26T02:25:14.086 INFO  storage_proofs::layered_drgporep > returning tree (layer: 5)
 2019-08-26T02:25:31.642 INFO  storage_proofs::layered_drgporep > encoding (layer: 6)
 2019-08-26T02:25:59.020 INFO  storage_proofs::layered_drgporep > returning tree (layer: 6)
 2019-08-26T02:26:24.411 INFO  storage_proofs::layered_drgporep > encoding (layer: 7)
 2019-08-26T02:26:52.175 INFO  storage_proofs::layered_drgporep > returning tree (layer: 7)
 2019-08-26T02:27:16.501 INFO  storage_proofs::layered_drgporep > encoding (layer: 8)
 2019-08-26T02:27:44.097 INFO  storage_proofs::layered_drgporep > returning tree (layer: 8)
 2019-08-26T02:28:08.946 INFO  storage_proofs::layered_drgporep > encoding (layer: 9)
 2019-08-26T02:28:36.360 INFO  storage_proofs::layered_drgporep > returning tree (layer: 9)
 2019-08-26T02:29:25.879 INFO  storage_proofs::layered_drgporep > returning tree (layer: 10)
 2019-08-26T02:29:25.879 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 0)
 2019-08-26T02:29:25.880 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 1)
 2019-08-26T02:29:25.880 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 2)
 2019-08-26T02:29:25.880 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 3)
 2019-08-26T02:29:25.880 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 4)
 2019-08-26T02:29:25.880 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 5)
 2019-08-26T02:29:25.880 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 6)
 2019-08-26T02:29:25.880 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 7)
 2019-08-26T02:29:25.881 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 8)
 2019-08-26T02:29:25.881 INFO  storage_proofs::layered_drgporep > setting tau/aux (layer: 9)
 2019-08-26T02:29:25.925 INFO  zigzag                           > replication_time: 550.263125177s
 2019-08-26T02:29:25.925 INFO  zigzag                           > replication_time/byte: 524.77µs
 2019-08-26T02:29:25.925 INFO  zigzag                           > replication_time/GiB: 563467.49698048s
 2019-08-26T02:29:25.926 INFO  zigzag                           > generating 1 partition proofs
 2019-08-26T02:29:25.954 INFO  zigzag                           > vanilla_proving_time: 28.450181ms
 2019-08-26T02:29:25.954 INFO  zigzag                           > sampling verifying (samples: 5)
 2019-08-26T02:30:11.575 INFO  zigzag                           > Verification complete
 2019-08-26T02:30:11.575 INFO  zigzag                           > average_vanilla_verifying_time: 9.124110211 seconds
	Command being timed: "cargo run --example zigzag -- --size 1024 --hasher pedersen"
	User time (seconds): 2273.08
	System time (seconds): 0.76
	Percent of CPU this job got: 381%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 9:56.33
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 707796          <------------
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 1
	Minor (reclaiming a frame) page faults: 184341
	Voluntary context switches: 834
	Involuntary context switches: 207832
	Swaps: 0
	File system inputs: 0
	File system outputs: 19448
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

(Not including the blake2s comparison, but rest assured it's not that.)

Note that actually Pedersen is the default hasher (added to the command here just for illustrative purposes) but I've been missing this (not sure for how long) since I tend to use blake2s for its higher speed. It would be useful to add a benchmark that tracks max RSS for the default zigzag (which I think is something currently being worked on).

@schomatis schomatis added P0 Highest priority perf-memory labels Aug 26, 2019
@dignifiedquire dignifiedquire removed the P0 Highest priority label Aug 26, 2019
@dignifiedquire
Copy link
Contributor

This is expected, since we have enabled spedersen: The default window size is 16 and as such erquires around 650Mib memory for caches, independent of the sector size. See this table: #697 (comment) for more details.

PR that changed this #783

@schomatis
Copy link
Contributor Author

Thanks for the clarification, closing then, sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants