Skip to content

Use System.Text.Json for json (de)serialization #393

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

Merged
merged 2 commits into from
Jun 27, 2023

Conversation

JohnSchmeichel
Copy link
Member

@JohnSchmeichel JohnSchmeichel commented Apr 19, 2023

The serialization and deserialization cost for Newtonsoft.Json causes significant slowdowns, especially in the cases of cached tokens where the process is not long lived. Swapping in System.Text.Json improves startup times.

BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.23430.1000)
Intel Xeon CPU E5-1650 v3 3.50GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK=8.0.100-preview.2.23157.25
[Host] : .NET 6.0.16 (6.0.1623.17311), X64 RyuJIT AVX2
Job-KGDGIP : .NET 6.0.16 (6.0.1623.17311), X64 RyuJIT AVX2

System.Text.Json:

IterationCount=1 RunStrategy=ColdStart WarmupCount=0

Method Mean Error Allocated
CachedSessionToken 460.5 ms NA 519.3 KB
CachedMsalToken 1,737.0 ms NA 1979.85 KB

IterationCount=3 RunStrategy=ColdStart WarmupCount=0

Method Mean Error StdDev Median Allocated
CachedSessionToken 254.9 ms 2,957.7 ms 162.1 ms 163.6 ms 481.46 KB
CachedMsalToken 967.8 ms 12,418.7 ms 680.7 ms 586.7 ms 1889.65 KB

Newtonsoft.Json:

IterationCount=1 RunStrategy=ColdStart WarmupCount=0

Method Mean Error Allocated
CachedSessionToken 586.9 ms NA 559.24 KB
CachedMsalToken 2,074.3 ms NA 2142 KB

IterationCount=3 RunStrategy=ColdStart WarmupCount=0

Method Mean Error StdDev Median Allocated
CachedSessionToken 343.7 ms 5,947.7 ms 326.0 ms 162.1 ms 519.8 KB
CachedMsalToken 1,277.7 ms 20,494.6 ms 1,123.4 ms 660.3 ms 2064.86 KB

@JohnSchmeichel
Copy link
Member Author

/azp where

@azure-pipelines
Copy link

Azure DevOps orgs getting events for this repository:

@JohnSchmeichel JohnSchmeichel marked this pull request as ready for review June 27, 2023 23:18
@JohnSchmeichel JohnSchmeichel merged commit f7af268 into master Jun 27, 2023
@JohnSchmeichel JohnSchmeichel deleted the johsch/system-test-json branch June 27, 2023 23:50
embetten added a commit that referenced this pull request Mar 6, 2024
- Reverting system.text.json #393 PR due to #484.
- Adding warning message for single quotes in endpoint message.
- Did not change swix/swr dependencies.

---------

Co-authored-by: Jonathan Myers <[email protected]>
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