-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove locks in SignatureProviders #1535
Conversation
src/Microsoft.IdentityModel.Tokens/AsymmetricSignatureProvider.cs
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,139 @@ | |||
//------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this class to "DisposableObjectPool"?
additional test coverage
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
@GeoK @keegan-caruso i upadate the PR, removing the locks in RsaCryptoServiceProxy and adding a programming possibility (not particularly elegant) opportunity to set the pool size. I struggled with naming and settled with DefaultSignatureProviderObjectPoolCacheSize, specifying using SignatureProvider in the name, rather than a more generic DefaultObjectPoolCacheSize, in case someone wanted to have different sizes (highly unlikely, however who knows). |
@@ -41,6 +41,8 @@ public class CryptoProviderFactory | |||
private static CryptoProviderFactory _default; | |||
private static ConcurrentDictionary<string, string> _typeToAlgorithmMap = new ConcurrentDictionary<string, string>(); | |||
private static object _cacheLock = new object(); | |||
private static int _defaultSignatureProviderObjectPoolCacheSize = Environment.ProcessorCount * 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curios on why we decided to change the default object pool size?
Line 63 in 26396d5
: this(factory, Environment.ProcessorCount * 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, curious about @GeoK 's questions and stress / perf findings
This PR adds an object pool that allows for the removal of locks when preforming crypto operations involving signatures. The 'objectpool' was copied from .net core as it is not available in 4.x.