algebra icon indicating copy to clipboard operation
algebra copied to clipboard

Ark-ec pulls in full hashbrown without feature gate

Open shamatar opened this issue 1 year ago • 6 comments

That eventually pulls things like once_cell that require atomics on some platforms (compare-exchange), and in general HashMap is quite heavy primitive that is still not in alloc of Rust itself

Full hashbrown is pulled in

  • https://github.com/arkworks-rs/algebra/blob/bb663bc27e776af81e66c94d9016bde2dbba9968/ec/src/scalar_mul/variable_base/stream_pippenger.rs#L5 - for peppinger - can be solved by feature gate. Independently, do you think unordered map wins here performance-wise vs ordered (a-la BTree)?
  • https://github.com/arkworks-rs/algebra/blob/bb663bc27e776af81e66c94d9016bde2dbba9968/ec/src/hashing/curve_maps/swu.rs#L154 - in test, dev-dependencies will just work
  • https://github.com/arkworks-rs/algebra/blob/bb663bc27e776af81e66c94d9016bde2dbba9968/ec/src/hashing/curve_maps/elligator2.rs#L161 - same, tests only

shamatar avatar Mar 26 '24 15:03 shamatar

Let me check how to replace the HashMap in stream_pippenger. (there should be other ways to get no-std hash map).

For the other two, easy.

weikengchen avatar Apr 06 '24 00:04 weikengchen

We can drop once_cell by removing the ahash feature from hashbrown.

weikengchen avatar Apr 06 '24 00:04 weikengchen

I patched it via feature in ec and poly packages, everything works except benchmarks that can not specify features (cargo limitations...). Don't know much about internals of hashbrown to comment on proposed alternative to factor out it's dependency instead

shamatar avatar Apr 06 '24 00:04 shamatar

Do you think if once_cell is no longer a dependency, would it still be a problem?

weikengchen avatar Apr 06 '24 00:04 weikengchen

https://github.com/arkworks-rs/algebra/commit/f46193b74a6f51299dcc3d835cf6694c28af99f9 Let me know your thoughts. But clearly if I can remove a dependency, it is better.

weikengchen avatar Apr 06 '24 00:04 weikengchen

On once-cell I'll need to check, I'll try to turn it off using hashbrown features in my local copy and build tomorrow

shamatar avatar Apr 06 '24 00:04 shamatar