Integrated: 8294073: Performance improvement for message digest implementations
Xue-Lei Andrew Fan
xuelei at openjdk.org
Mon Nov 21 15:59:46 UTC 2022
On Tue, 20 Sep 2022 22:12:04 GMT, Xue-Lei Andrew Fan <xuelei at openjdk.org> wrote:
> Hi,
>
> In the message digest implementation, for example SHA256, in JDK, two bitwise operations could be improved with equivalent arithmetic, and then the number bitwise operations could be reduced accordingly. Specifically
> "(x and y) xor ((complement x) and z)" could be replaced with the equivalent "z xor (x and (y xor z))", and "(x and y) xor (x and z) xor (y and z)" could be replaced with the equivalent "(x and y) xor ((x xor y) and z)". Each replacement reduces one bitwise operation, and thus improve the performance.
>
> Per my testing on my MacOS laptop, the update on SHA256 improves the message digest throughput by 0.5%-0.8%. The improvement is not significant, but might be worthy of it as the update is pretty simple and trivial, for those platforms that do not support CPU intrinsic for a certain hash algorithm.
>
> This patch update SHA2 implementation only. Please let me know what do you think. If you are good with this little bit performance, I will update more message digest implementations. If no one interested in these little benefits, I will close this PR later.
>
> Thanks,
> Xuelei
This pull request has now been integrated.
Changeset: b366d17a
Author: Xue-Lei Andrew Fan <xuelei at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/b366d17a94e5b16710fd915ef4cf04aaf911b455
Stats: 4 lines in 1 file changed: 2 ins; 0 del; 2 mod
8294073: Performance improvement for message digest implementations
Reviewed-by: jjiang
-------------
PR: https://git.openjdk.org/jdk/pull/10365
More information about the security-dev
mailing list