-
Notifications
You must be signed in to change notification settings - Fork 34
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
perf: optimize process_withdrawals
and process_sync_committee_updates
#486
perf: optimize process_withdrawals
and process_sync_committee_updates
#486
Conversation
b63413c
to
eb2067c
Compare
state.validators | ||
|> Stream.filter(&Predicates.is_active_validator(&1, epoch)) | ||
|> Stream.map(fn %Validator{effective_balance: effective_balance} -> effective_balance end) | ||
|> Enum.sum() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any benefit in using stream here considering that you are going to do a Enum.sum afterwards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need benchmarks to know whether Stream
or Enum
is more efficient for this case, but at least it should consume less memory, as it can sum the result in batches, instead of first transforming the whole list and then reducing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
No description provided.