azure-activedirectory-identitymodel-extensions-for-dotnet icon indicating copy to clipboard operation
azure-activedirectory-identitymodel-extensions-for-dotnet copied to clipboard

Use Base64.DecodeFromUtf8InPlace

Open keegan-caruso opened this issue 11 months ago • 0 comments

Use Base64.DecodeFromUtf8InPlace for base64 decode

Description

Base64.DecodeFromUtf8InPlace is SIMD aware.

CPU: ~ -12% on token read time

before:

Method Mean Error StdDev Median P90 P95 P100 Gen0 Allocated
ReadJWS_FromMemory 3.487 us 0.0287 us 0.0612 us 3.465 us 3.601 us 3.604 us 3.605 us 0.1068 2.67 KB
ReadJWS_FromString 3.492 us 0.0101 us 0.0217 us 3.490 us 3.524 us 3.529 us 3.545 us 0.1068 2.67 KB

after:

Method Mean Error StdDev P90 P95 P100 Gen0 Allocated
ReadJWS_FromMemory 3.068 us 0.0139 us 0.0303 us 3.094 us 3.117 us 3.151 us 0.1068 2.67 KB
ReadJWS_FromString 3.076 us 0.0134 us 0.0292 us 3.113 us 3.121 us 3.127 us 0.1068 2.67 KB

Note: this was run with a cpu with the following intrinsics: AVX-512F+CD+BW+DQ+VL+VBMI

keegan-caruso avatar Feb 28 '24 00:02 keegan-caruso