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

Benchmark shuffle #2353

Merged
merged 7 commits into from
Apr 9, 2021
Merged

Benchmark shuffle #2353

merged 7 commits into from
Apr 9, 2021

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Apr 9, 2021

Motivation

Research performance improvements for the shuffle routine. See #2352

Description

  • Adds multiple benchmarks to understand the cost of each component
  • Inline closure. It's the only optimization that consistently showed significant improvements. It also matches the implementations in Go and Rust. It reduces the total cpu time (expect spent on hashing) by 50%

Next steps

  • Hashing takes 80% of total CPU time so increasing the performance of our hashing library would have a big impact.
  • Then we could consider paralleling this function. Given the overhead cost of message passing in Javascript this is not a route we should take until the validator set is really big.

Proto: Each round can be computed independently (or in groups, e.g. rounds 0-10, 10-20, etc.), and then you can merge them afterwards. If you use some webworker approach, that may be may improve things.

Proto: The parallelizing thing works like:

  • create a list of 0...N for each worker
  • assign a round start and end to each worker. E.g. worker 2 does rounds 20...30 of the total 90 rounds.
  • every worker runs the list shuffle for their range of rounds
  • a final merge step: apply the "mapping" of each worker to the input, in the order of the rounds

Memory-wise: Each worker basically requires as much memory as the original algo: N uint32 values.
Plus some small constant, to cover memory of the hash function and temporary variables.

@dapplion dapplion changed the title Dapplion/benchmark shuffle Benchmark shuffle Apr 9, 2021
@codeclimate
Copy link

codeclimate bot commented Apr 9, 2021

Code Climate has analyzed commit b538e9b and detected 0 issues on this pull request.

View more on Code Climate.

@lgtm-com
Copy link

lgtm-com bot commented Apr 9, 2021

This pull request introduces 1 alert when merging 5d691aa into ec06563 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Apr 9, 2021

This pull request introduces 1 alert when merging b538e9b into ec06563 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@wemeetagain wemeetagain merged commit bfdb083 into master Apr 9, 2021
@wemeetagain wemeetagain deleted the dapplion/benchmark-shuffle branch April 9, 2021 15:33
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.

2 participants