Optimize log sanitization with SearchValues for improved performance#3341
Optimize log sanitization with SearchValues for improved performance#3341
Conversation
Co-authored-by: mdchennu <45950356+mdchennu@users.noreply.github.com>
|
@copilot please update the tests in this file: https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/dev/test/Microsoft.IdentityModel.Logging.Tests/LogHelperTests.cs within this PR |
Co-authored-by: mdchennu <45950356+mdchennu@users.noreply.github.com>
I've added 15 comprehensive tests to LogHelperTests.cs covering:
All 72 tests pass on both .NET 8 and .NET 9. See commit 4f47a7d. |
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
|
Can we have a more targeted benchmark for just the logging sanitization? |
Co-authored-by: mdchennu <45950356+mdchennu@users.noreply.github.com>
I've added a targeted benchmark specifically for log sanitization in
Run with: See commit 9a2f8e5. |
Co-authored-by: mdchennu <45950356+mdchennu@users.noreply.github.com>
Summary
Updated the
Sanitizemethod inLogHelper.csto useSearchValues<char>for improved performance on .NET 8+, while maintaining full backward compatibility with older frameworks.Changes Made
using System.Buffersdirective for .NET 8+SearchValues<char>field with all 108 control and format charactersBenchmark Added
Created
LogSanitizationBenchmarks.cswith the following scenarios:Run with:
dotnet run -c release -f net9.0 --filter Microsoft.IdentityModel.Benchmarks.LogSanitizationBenchmarks*Character Set (108 total)
Testing
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.