Skip to content

Conversation

JoshLozensky
Copy link
Contributor

@JoshLozensky JoshLozensky commented Mar 13, 2025

Change all plain object locks to System.Thread.Lock objects for .NET 9 or greater.

Addresses issue #3169

@JoshLozensky JoshLozensky requested a review from a team as a code owner March 13, 2025 00:17
@github-actions

This comment was marked as duplicate.

@jennyf19
Copy link
Collaborator

Looking good, @JoshLozensky ...curious if we can add some thread safety tests and have you done any benchmarks on the perf gains when using the specialized type?

@github-actions

This comment was marked as duplicate.

@github-actions
Copy link

Summary

Summary
Generated on: 3/14/2025 - 10:24:20 PM
Coverage date: 3/14/2025 - 10:14:18 PM - 3/14/2025 - 10:23:55 PM
Parser: MultiReport (60x Cobertura)
Assemblies: 1
Classes: 7
Files: 2
Line coverage: 80.3% (620 of 772)
Covered lines: 620
Uncovered lines: 152
Coverable lines: 772
Total lines: 483
Branch coverage: 67.8% (228 of 336)
Covered branches: 228
Total branches: 336
Method coverage: Feature is only available for sponsors

Coverage

Microsoft.IdentityModel.JsonWebTokens - 80.3%
Name Line Branch
Microsoft.IdentityModel.JsonWebTokens 80.3% 67.8%
Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities 100%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated 80.3% 67.8%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F12A1AEDDDFE32BA
DF4DBFF323AF1BCB48B9F9721B7CD3E05F5E034CF225E3DF8__CreateJwsRegex_0
81.4% 67.6%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJweRegex_1
79.2% 68%
System.Text.RegularExpressions.Generated.<RegexGenerator_g>F334844C618E00D3
CEC5D3FE0D00CF0141BBEE98635313BB2CB8D3921464CE05A__CreateJwsRegex_0
81.4% 67.6%

@JoshLozensky
Copy link
Contributor Author

JoshLozensky commented Mar 15, 2025

Looking good, @JoshLozensky ...curious if we can add some thread safety tests and have you done any benchmarks on the perf gains when using the specialized type?

Table below shows the percentage change in performance for the given benchmark (negative is "good"). The AggregatePercentageChange is an average of all means from statistically significant tests in the corresponding benchmark. Refer to the formulas below for relevant definitions. It looks like there is a fairly consistent trend of about 3.8% faster validation with the new Lock.

Relevant formulas:

Difference = TimeNewLock - TimeOldLock

StandardError = StandardErrorNewLock + StandardErrorOldLock

IsSignificant = Difference > Standard Error

PercentageChange = Difference / TimeOldLock

Benchmark AggregatePercentageChange
CreateJWE 0.98%
CreateSHR -0.85%
CreateToken -2.57%
ValidateJWE -3.96%
ValidateSHR -3.75%
ValidateTokenAsync -3.82%

@JoshLozensky
Copy link
Contributor Author

JoshLozensky commented Mar 17, 2025

Looking good, @JoshLozensky ...curious if we can add some thread safety tests and have you done any benchmarks on the perf gains when using the specialized type?

I could add some thread-safety tests in a different PR if you'd like but since no logic is changed in this PR I think it is out of scope @jennyf19

Link to test PR

Copy link
Contributor

@keegan-caruso keegan-caruso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Copy link
Collaborator

@jennyf19 jennyf19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@JoshLozensky JoshLozensky merged commit 9d007d8 into dev Mar 17, 2025
6 checks passed
pmaytak added a commit that referenced this pull request Mar 21, 2025
jmprieur pushed a commit that referenced this pull request Mar 21, 2025
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.

3 participants