Skip to content

Cache keyalg/ctalg String() in JWE encrypt/decrypt#1566

Merged
lestrrat merged 2 commits intodevelop/v3from
perf-cache-alg-string
Feb 22, 2026
Merged

Cache keyalg/ctalg String() in JWE encrypt/decrypt#1566
lestrrat merged 2 commits intodevelop/v3from
perf-cache-alg-string

Conversation

@lestrrat
Copy link
Collaborator

Avoid repeated .String() method dispatch on algorithm enums by caching at function entry.

Encrypt: 5-14% faster (RSA-OAEP -14%, A256KW -13%, ECDH-ES -5%) Decrypt: 4-7% faster (RSA-OAEP -7%, ECDH-ES -5%, A256KW -4%) Zero change in allocs or bytes allocated.

Avoid repeated .String() method dispatch on algorithm enums
by caching at function entry.

Encrypt: 5-14% faster (RSA-OAEP -14%, A256KW -13%, ECDH-ES -5%)
Decrypt: 4-7% faster (RSA-OAEP -7%, ECDH-ES -5%, A256KW -4%)
Zero change in allocs or bytes allocated.
@lestrrat lestrrat merged commit 690cac8 into develop/v3 Feb 22, 2026
23 checks passed
@lestrrat lestrrat deleted the perf-cache-alg-string branch February 22, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant