-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Lodestar tree hashing performance #2206
Comments
To profile our hashTreeRoot I've modified
|
After more tests with different approaches seems that
Has almost same performance if not a bit worse, +5%. updateRoot(a, b) {
const INPUT_LENGTH = this.ctx.INPUT_LENGTH;
const input = new Uint8Array(this.ctx.memory.buffer, this.ctx.input.value, INPUT_LENGTH);
input.set(a);
input.set(b, 32);
this.ctx.update(this.ctx.input.value, 64);
return this;
} |
Just as curiosity I compared as-sha256 with bcrypto/sha256, by reverting this commit ChainSafe/persistent-merkle-tree@8460f03
|
Benchmarked Lighthouse's hashing lib let start = ProcessTime::now();
for i in 0..1000000 {
let res = hash32_concat(&hash_a, &hash_b);
}
let cpu_time: Duration = start.elapsed();
println!(" {:?}", cpu_time); Results compared to JS to concat 2 32bytes + hash:
So the concat + hash power is the same. I've counted the num of hashes computed in each node to get the root of genesis-mainnet-100000 (15587377 bytes)
In Lodestar case the numbers are consistent with the hashing power:
Then, how can Lighthouse compute the root of the state x5 times faster if the hashing function is not faster, and appears to compute a similar number of hashes? Note that my knowledge of the inner workings of Lighthouse's libs is limited, so I must be missing something. However:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
Assigning to me so it doesn't get closed. I stopped the tests on the previous comment, if anyone wants to continue investigating, go for it. |
Closing since this issue has no actionable items |
Purpose: profiling our state transition function computing the hashTreeRoot of state and blocks has shown to take significant chunk of total time.
I've compared a benchmark that Lighthouse has on their tree hash lib with our tree backed types. There seems to be some room for improvement on our side. I'm trying to get a benchmark of their hashing lib vs our to help narrow down where is the performance difference coming from.
Forced single core (ms)
Multi-threading (8 cores) (ms)
Note on profiling: Doing a profile of hashing is not useful because the resolution is too low. By default the sampling is 1ms, while a fast sha256 implementation can do 1000 hashes in 1ms. I've tried setting
--cpu-prof interval 1
to increase the sampling frequency x1000 but seems to have no effect on the resulting profile.The text was updated successfully, but these errors were encountered: