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

Memory management : pari_init #30

Open
omershlo opened this issue Dec 1, 2019 · 8 comments
Open

Memory management : pari_init #30

omershlo opened this issue Dec 1, 2019 · 8 comments
Labels
binding relates to c binding pari

Comments

@omershlo
Copy link
Contributor

omershlo commented Dec 1, 2019

At the moment, pari_init is called with constant 1Mb of stack memory for each function that requires the binding to class group function.

optimize 1: remove pari_init when unnecessary
optimize 2: minimize allocated stack size
optimize 3: Make the stack size dynamic based on inputs.

@omershlo omershlo added enhancement New feature or request binding relates to c binding pari and removed enhancement New feature or request labels Dec 1, 2019
@0xmountaintop
Copy link
Contributor

I test Wes19 VDF using https://github.com/KZen-networks/class/blob/2a8fa3bb58a2c177ccb1a429887d680988580b68/src/primitives/vdf.rs#L158

When changing t to >257, it seems memory overflows. It will be necessary to support big t if we want to make the codes sufficing real-world need.

@omershlo
Copy link
Contributor Author

omershlo commented Aug 2, 2020

What is the error you get?

@0xmountaintop
Copy link
Contributor

0xmountaintop commented Aug 2, 2020

What is the error you get?

by running

cargo test --lib vdf

I get

running 2 tests
  ***   bug in PARI/GP (Segmentation Fault), please report.  ***   Error in the PARI system. End of program.
error: test failed, to rerun pass '--lib'

sometimes I get

running 2 tests
  ***   impossible inverse in dvmdii: 0.  ***   Error in the PARI system. End of program.
error: test failed, to rerun pass '--lib'

and sometimes

running 2 tests
  ***   sorry, negative definite t_QFI is not yet implemented.  ***   Error in the PARI system. End of program.
error: test failed, to rerun pass '--lib'

so it seems it's not because of using 10 for t. Because rerunning it with 10 these errors may still occur.

@0xmountaintop
Copy link
Contributor

0xmountaintop commented Aug 2, 2020

gmp_classgroup in https://github.com/poanetwork/vdf works quites stably.
But their Wes19 implementation is quite complex.

I am thinking following the simplicity in https://github.com/KZen-networks/class/blob/master/src/primitives/vdf.rs, but switch to their gmp_classgroup for classgroup.

@0xmountaintop
Copy link
Contributor

gmp_classgroup in https://github.com/poanetwork/vdf works quites stably.
But their Wes19 implementation is quite complex.

I am thinking following the simplicity in https://github.com/KZen-networks/class/blob/master/src/primitives/vdf.rs, but switch to their gmp_classgroup for classgroup.

or maybe https://github.com/cambrian/accumulator/blob/master/src/group/class.rs

@omershlo
Copy link
Contributor Author

omershlo commented Aug 2, 2020

  1. about the errors, you should run with one thread, see: https://github.com/KZen-networks/class#test
  2. using Cambrian/POA class group implementation is actually a nice idea! I think it will be a bit complex to pull off but worth a try. I would go for Cambrian first.

@0xmountaintop
Copy link
Contributor

2. using Cambrian/POA class group implementation is actually a nice idea!  I think it will be a bit complex to pull off but worth a try. I would go for Cambrian first.

TBH, POA's seems more modular and easier to pull out. Besides, POA's should be more efficient: they use GMP whereas Cambrian uses rug::Integer.

@omershlo
Copy link
Contributor Author

omershlo commented Aug 2, 2020

ok, lets go with POA first !

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

No branches or pull requests

2 participants