Skip to content

Add asynchronous Stream serializer APIs - #201

Merged
dameng324 merged 1 commit into
mainfrom
codex/async-stream-serializer
Jul 11, 2026
Merged

Add asynchronous Stream serializer APIs#201
dameng324 merged 1 commit into
mainfrom
codex/async-stream-serializer

Conversation

@dameng324

Copy link
Copy Markdown
Owner

Summary

  • add async Stream serialization and deserialization APIs for generic, dynamic, non-generic, and extension entry points
  • bridge the existing synchronous codec to async I/O with pooled segmented buffers
  • document that encoding/decoding remains synchronous and deserialization reads a single message to end-of-stream

Why

Some Stream implementations permit only asynchronous reads and writes. These APIs make them usable without changing LightProto's synchronous ReaderContext and WriterContext codec contracts.

Validation

  • dotnet build src\\LightProto\\LightProto.csproj -c Release --no-restore
  • dotnet test tests\\LightProto.Tests\\LightProto.Tests.csproj -c Debug --no-restore --timeout 60s --minimum-expected-tests 1
  • CSharpier check and git diff --check

The test suite includes an async-only Stream regression test and passed 13,543 tests.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 53 complexity · 2 duplication

Metric Results
Complexity 53
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@dameng324 dameng324 self-assigned this Jul 11, 2026
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.90323% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.05%. Comparing base (5b7b714) to head (2f04081).

Files with missing lines Patch % Lines
src/LightProto/Serializer.NonGeneric.cs 0.00% 25 Missing ⚠️
src/LightProto/PooledSegmentBufferWriter.cs 86.66% 6 Missing and 4 partials ⚠️
src/LightProto/Serializer.Async.cs 61.90% 4 Missing and 4 partials ⚠️
src/LightProto/Serializer.Dynamically.cs 0.00% 2 Missing ⚠️
src/LightProto/Serializer.Extensions.cs 0.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (62.90%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #201      +/-   ##
==========================================
- Coverage   95.19%   94.05%   -1.14%     
==========================================
  Files         125      127       +2     
  Lines        3394     3518     +124     
  Branches      464      488      +24     
==========================================
+ Hits         3231     3309      +78     
- Misses         90      128      +38     
- Partials       73       81       +8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.301
  [Host]    : .NET 8.0.28 (8.0.28, 8.0.2826.26413), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.9 (10.0.9, 10.0.926.27113), X64 RyuJIT x86-64-v3
  .NET 8.0  : .NET 8.0.28 (8.0.28, 8.0.2826.26413), X64 RyuJIT x86-64-v3
  .NET 9.0  : .NET 9.0.17 (9.0.17, 9.0.1726.26416), X64 RyuJIT x86-64-v3


Method Job Runtime Mean Error StdDev Ratio Allocated Alloc Ratio
Deserialize_ProtoBuf_net .NET 10.0 .NET 10.0 733.8 μs 3.57 μs 3.16 μs 1.44 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 10.0 .NET 10.0 697.2 μs 2.91 μs 2.58 μs 1.37 648.7 KB 1.13
Deserialize_LightProto .NET 10.0 .NET 10.0 510.0 μs 2.75 μs 2.44 μs 1.00 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 8.0 .NET 8.0 845.4 μs 2.82 μs 2.50 μs 1.38 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 8.0 .NET 8.0 804.8 μs 3.24 μs 2.87 μs 1.32 648.7 KB 1.13
Deserialize_LightProto .NET 8.0 .NET 8.0 611.3 μs 1.55 μs 1.29 μs 1.00 574.8 KB 1.00
Deserialize_ProtoBuf_net .NET 9.0 .NET 9.0 778.4 μs 3.18 μs 2.82 μs 1.32 562 KB 0.98
Deserialize_GoogleProtoBuf .NET 9.0 .NET 9.0 742.2 μs 1.87 μs 1.56 μs 1.26 648.7 KB 1.13
Deserialize_LightProto .NET 9.0 .NET 9.0 587.8 μs 1.45 μs 1.29 μs 1.00 574.8 KB 1.00

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.301
  [Host]    : .NET 8.0.28 (8.0.28, 8.0.2826.26413), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.9 (10.0.9, 10.0.926.27113), X64 RyuJIT x86-64-v3
  .NET 8.0  : .NET 8.0.28 (8.0.28, 8.0.2826.26413), X64 RyuJIT x86-64-v3
  .NET 9.0  : .NET 9.0.17 (9.0.17, 9.0.1726.26416), X64 RyuJIT x86-64-v3


Method Job Runtime Mean Error StdDev Ratio Allocated Alloc Ratio
Serialize_ProtoBuf_net .NET 10.0 .NET 10.0 912.8 μs 2.49 μs 2.33 μs 1.21 526.41 KB 1.03
Serialize_GoogleProtoBuf .NET 10.0 .NET 10.0 827.3 μs 2.68 μs 2.24 μs 1.10 512.95 KB 1.00
Serialize_LightProto .NET 10.0 .NET 10.0 752.3 μs 3.12 μs 2.77 μs 1.00 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 8.0 .NET 8.0 1,026.5 μs 4.64 μs 4.11 μs 1.21 526.4 KB 1.03
Serialize_GoogleProtoBuf .NET 8.0 .NET 8.0 876.4 μs 6.68 μs 5.93 μs 1.03 512.95 KB 1.00
Serialize_LightProto .NET 8.0 .NET 8.0 851.6 μs 3.27 μs 2.90 μs 1.00 512.92 KB 1.00
Serialize_ProtoBuf_net .NET 9.0 .NET 9.0 977.6 μs 5.47 μs 4.85 μs 1.20 526.4 KB 1.03
Serialize_GoogleProtoBuf .NET 9.0 .NET 9.0 858.8 μs 2.92 μs 2.44 μs 1.05 512.95 KB 1.00
Serialize_LightProto .NET 9.0 .NET 9.0 816.1 μs 9.24 μs 7.21 μs 1.00 512.92 KB 1.00

@dameng324
dameng324 merged commit 913c860 into main Jul 11, 2026
7 of 8 checks passed
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.

1 participant