aws / aws-sdk-net

The official AWS SDK for .NET. For more information on the AWS SDK for .NET, see our web site:
http://aws.amazon.com/sdkfornet/
Apache License 2.0
2.03k stars 849 forks source link

Switch to .NET built-in MD5, it's 1.5X faster than your implementation #2598

Open alex-jitbit opened 1 year ago

alex-jitbit commented 1 year ago

Describe the feature

Method Mean Error StdDev Gen0 Allocated
NetCore_MD5_HashData 371.0 ns 9.32 ns 0.51 ns 0.0062 40 B
AWS_SDK_MD5 441.9 ns 9.98 ns 0.55 ns 0.1211 760 B

As you can see, .NET 6 built-in MD5 api is 1.5x faster and allocates 20x less memory. Any reason for not using .NET built in MD5.HashData() static method?

Use Case

MD5 hashing is used heavily in the SDK, switching to .NET 's built-in will speed things up a lot.

Acknowledgements

AWS .NET SDK and/or Package version used

3.7.106.30

Targeted .NET Platform

.NET 5/6

Operating System and version

Windows 10, Ubuntu

ashishdhingra commented 1 year ago

@alex-jitbit Good afternoon. Thanks for submitting feature request and the statistics w.r.t. performance on the MD5 calculation. Kindly note that AWS SDK for .NET also targets NetStandard20 netcoreapp3.1 and .NET Framework. This needs review with the team. Feel free to contribute a PR which could be reviewed by the team.

normj commented 1 year ago

@alex-jitbit I do like the idea of conditionally switching to the .NET version when it is available. We need to see how easy it would be for the SDK to use either implementation depending on the environment.