-
Notifications
You must be signed in to change notification settings - Fork 40
perf: inline SszEx.hash
function
#722
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
Conversation
# NOTE: the `Checkpoint` values in latest_messages are `LatestMessage`s | ||
latest_messages: %{Types.validator_index() => Checkpoint.t()}, |
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.
I was puzzled by this when working on other things, so I added this comment
@@ -18,6 +18,7 @@ defmodule LambdaEthereumConsensus.SszEx do | |||
@zero_chunk <<0::size(@bits_per_chunk)>> | |||
@zero_hashes ZeroHashes.compute_zero_hashes() | |||
|
|||
@compile {:inline, hash: 1} |
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.
TIL
@@ -18,6 +18,7 @@ defmodule LambdaEthereumConsensus.SszEx do | |||
@zero_chunk <<0::size(@bits_per_chunk)>> | |||
@zero_hashes ZeroHashes.compute_zero_hashes() | |||
|
|||
@compile {:inline, hash: 1} | |||
@spec hash(iodata()) :: binary() |
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.
shouldnt this function live outside of SSZ? I see it's being used in other places too, like shuffling
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.
Maybe. We just added it here since adding a new module for this function seemed like too much
Since the function is just an "alias" to
:crypto.hash
, we can safely inline all calls. This gives a ~5% performance increase when hashing, according to benchmarks.