Closed baarde closed 5 months ago
@Lukasa Thanks for your feedback. I'll use Feedback Assistant.
Would it be less ABI-impacting to make update(bufferPointer:)
public?
Potentially, yes, it's worth suggesting in your Feedback Assistant report. Do you have the number handy?
@Lukasa I've submitted a feedback: FB14076813.
Thanks @baarde.
Making the methods inlinable removes the cost of fetching the type metadata.
Checklist
Motivation:
As stated in #238, generally, users will only compute a few authentication codes and aren't really concerned by the performance. But sometimes, it may be necessary to compute a lot of authentication codes as fast as possible.
Making
authenticationCode(for:using:)
andupdate(data:)
inlinable provides a significant performance gain whenD
is known at compile time without exposing much of the implementation.Modifications:
authenticationCode(for:using:)
is annotated as inlinable.update(data:)
is annotated as inlinable.update(bufferPointer:)
is annotated as usable from inline.Result:
On its own, this change makes computing HMAC authentication codes about 125% faster than before.
On my machine (MacBook Pro 14-inch 2021)
HMAC-MD5: 49.6 seconds → 39.4 seconds HMAC-SHA1: 43.1 seconds → 33.7 seconds HMAC-SHA256: 44.6 seconds → 34.1 seconds HMAC-SHA384: 50.7 seconds → 41.3 seconds HMAC-SHA512: 50.3 seconds → 41.7 secondsTest code
```swift import Crypto import Foundation func testHMAC