Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Performance improvements inJsonValue.#103733

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
eiriktsarpalis merged 4 commits intodotnet:mainfromeiriktsarpalis:jsonnode-perf
Jun 20, 2024

Conversation

eiriktsarpalis
Copy link
Member

One of the oddities ofJsonNode design is that it permits encapsulation of arbitrary .NET objects via theJsonValue type. This is known to create performance problems since it's not possible to introspectJsonValue instances without serializing and deserializing the underlying object first. The problem is fairly pervasive since JSON primitives such as boolean, numbers and strings are all represented usingJsonValue.

This PR refactors the implementation ofJsonValue so that common primitive types and deserialized values backed byJsonElement are fully segregated from the implementation that admits arbitrary objects. Consequently this change recordssubstantial performance improvements:

MethodBranchMeanRatioAllocatedAlloc Ratio
DeepEqualsmain2,859.165 ns1.004224 B1.00
DeepEqualsPR270.130 ns0.09-0.00
DeepEquals_JsonElementmain660.551 ns1.00328 B1.00
DeepEquals_JsonElementPR432.391 ns0.65-0.00
GetValueKindmain612.784 ns1.000616 B1.00
GetValueKindPR5.243 ns0.009-0.00
GetValueKind_JsonElementmain15.557 ns1.00-NA
GetValueKind_JsonElementPR11.111 ns0.71-NA

martincostello, KeterSCP, PaulusParssinen, ilmax, campersau, ShreyasJejurkar, and Zagrthos reacted with rocket emoji
@eiriktsarpaliseiriktsarpalis added this to the9.0.0 milestoneJun 19, 2024
@eiriktsarpaliseiriktsarpalis self-assigned thisJun 19, 2024
@eiriktsarpaliseiriktsarpalis added the tenet-performancePerformance related issue labelJun 19, 2024
@dotnet-policy-serviceDotnet Policy Service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json,@gregsdennis
See info inarea-owners.md if you want to be subscribed.

@gregsdennis
Copy link
Contributor

Just confirming that we're not losing the ability to store arbitrary objects inJsonValue. I actually utilize this inmy JSON-e implementation.

@eiriktsarpalis
Copy link
MemberAuthor

Just confirming that we're not losing the ability to store arbitrary objects inJsonValue. I actually utilize this inmy JSON-e implementation.

We couldn't do that. This change simply isolates that use case from the hot path scenaria.

gregsdennis reacted with thumbs up emoji

@eiriktsarpalis
Copy link
MemberAuthor

/ba-g suppressing unrelated test failure to merge ahead of snap.

@eiriktsarpaliseiriktsarpalis merged commitd9b9676 intodotnet:mainJun 20, 2024
75 of 83 checks passed
@eiriktsarpaliseiriktsarpalis deleted the jsonnode-perf branchJune 20, 2024 20:52
rzikm pushed a commit to rzikm/dotnet-runtime that referenced this pull requestJun 24, 2024
* Performance improvements in JsonValue.*Fixdotnet#103715.* Add more test cases and fix a number of bugs related to DeepEquals and escaping.* Fix number handling corner case.
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@stephentoubstephentoubstephentoub approved these changes

@jozkeejozkeejozkee approved these changes

@krwqkrwqAwaiting requested review from krwq

Assignees

@eiriktsarpaliseiriktsarpalis

Labels
Projects
None yet
Milestone
9.0.0
Development

Successfully merging this pull request may close these issues.

4 participants
@eiriktsarpalis@gregsdennis@stephentoub@jozkee

[8]ページ先頭

©2009-2025 Movatter.jp