Skip to content
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

Improve async deserialization performance #255

Merged
merged 3 commits into from
Feb 2, 2025
Merged

Improve async deserialization performance #255

merged 3 commits into from
Feb 2, 2025

Conversation

AArnott
Copy link
Owner

@AArnott AArnott commented Feb 2, 2025

  • Improve string deserialization perf overall (from DeserializeAsync methods)
  • Opportunistically use synchronous deserialization during async enumeration of top-level elements when we have the next item buffered already anyway.
  • Use sync deserialization opportunistically during async enumeration with envelopes

Together, this gets the async top-level enumeration scenario from 38% slower than MessagePack-CSharp to 14% faster.

Closes #253

@AArnott AArnott added the enhancement New feature or request label Feb 2, 2025
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

Attention: Patch coverage is 88.33333% with 7 lines in your changes missing coverage. Please review.

Project coverage is 84.49%. Comparing base (56f0454) to head (d2ba765).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/Nerdbank.MessagePack/MessagePackSerializer.cs 76.92% 3 Missing ⚠️
...rc/Nerdbank.MessagePack/StreamingDeserializer`1.cs 86.36% 3 Missing ⚠️
src/Nerdbank.MessagePack/MessagePackAsyncReader.cs 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #255      +/-   ##
==========================================
- Coverage   84.53%   84.49%   -0.05%     
==========================================
  Files         167      167              
  Lines       13663    13704      +41     
  Branches     1458     1459       +1     
==========================================
+ Hits        11550    11579      +29     
- Misses       2085     2097      +12     
  Partials       28       28              
Flag Coverage Δ
Linux 82.88% <88.33%> (+0.03%) ⬆️
Windows 84.47% <88.33%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AArnott AArnott requested a review from Copilot February 2, 2025 23:46

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

test/Nerdbank.MessagePack.Tests/StreamingEnumerableTests.cs:100

  • Ensure that the new test case adequately covers the behavior of opportunistically using synchronous deserialization during async enumeration.
[Fact]

src/Nerdbank.MessagePack/MessagePackAsyncReader.cs:224

  • Ensure that the new method GetBufferedStructuresCount is covered by tests to verify its correctness.
internal int GetBufferedStructuresCount(int countUpTo, SerializationContext context, out bool reachedMaxCount)

src/Nerdbank.MessagePack/Converters/PrimitiveConverters.cs:68

  • The word 'numbe' should be 'number'.
// We'll always require at least a reasonable numbe of bytes to decode at once,
@AArnott AArnott enabled auto-merge February 2, 2025 23:48
@AArnott AArnott merged commit 97d1011 into main Feb 2, 2025
3 checks passed
@AArnott AArnott deleted the perf branch February 2, 2025 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance comparison: streaming deserialize appears faster on older MessagePack library
1 participant