-
Notifications
You must be signed in to change notification settings - Fork 93
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
fix: avoid resetting method.hashUpdate
#95
base: develop
Are you sure you want to change the base?
fix: avoid resetting method.hashUpdate
#95
Conversation
This is done to avoid setting the variable twice, because in a multithreaded environment this destroys memory caches. Note that to make the code cleaner I used an early return in the special `sha256_ni_hashUpdate` case. Fixes intel/linux-sgx#1073 Signed-off-by: Mikołaj Lubiak <[email protected]>
To cite the issue:
|
Did a couple of benchmark runs, and the new code saves about 1,000,000,000 cache references, 10 CPU seconds (10% decrease), and halves the instruction count, in the specific benchmark case. Numbers hold roughly the same proportions in all runs.
Without fix:
Benchmark code: https://gist.github.com/mikolajlubiak/4d4c2f3286c03455f0aca256300aa3fe (from haxelion) |
Some other stats with the same benchmark: With fix:
Without fix:
|
@mikolajlubiak sorry I was AFK last week. It is unfortunate that the IPP CP API and the TCrypto API doesn't mesh well and forces us to call the I think that change can be broadly applied to all |
Yes, although this PR improves the performance a bit its still really poor.
You are right. I wanted to do that, but unfortunately had no free time. |
Thanks @mikolajlubiak and @haxelion for your valuable contribution and feedback. We'll check it internally and get back to you with an answer. |
This is done to avoid setting the variable twice, because in a multithreaded environment this destroys memory caches. Note that to make the code cleaner I used an early return in the special
sha256_ni_hashUpdate
case.Compilation using the Intel® oneAPI DPC++/C++ compiler succeeded.
Code formatted according to the .clang-format rules.
Added a note in change log and incremented the version.
Fixes intel/linux-sgx#1073