Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to clean up the PooledBuffer implementation and simplify PoolingStreamBufferWriter by removing _bytesWritten tracking. However, the changes to PoolingStreamBufferWriter introduce critical bugs that violate the IBufferWriter<byte> contract.
Key changes:
- Refactored session handling in
Serializer.csto reduce code duplication - Optimized
PooledBuffermethods with better span handling and simplified null checks - Simplified
PoolingStreamBufferWriterby removing_bytesWrittenfield (introduces bugs)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Orleans.Serialization/Serializer.cs | Refactored to move session creation outside if/else blocks and consistently use Writer.CreatePooled helper |
| src/Orleans.Serialization/Codecs/ByteArrayCodec.cs | Changed to use PooledBuffer.CopyTo method instead of manual enumeration |
| src/Orleans.Serialization/Buffers/PooledBuffer.cs | Multiple optimizations: better span slicing, simplified null checks, refactored SequenceSegment construction, improved pooling logic |
| src/Orleans.Serialization/Buffers/Adaptors/PoolingStreamBufferWriter.cs | CRITICAL: Removed _bytesWritten tracking, breaking IBufferWriter contract |
| src/Orleans.Serialization/Buffers/Adaptors/BufferWriterExtensions.cs | Removed struct constraint from generic type parameters for more flexibility |
| src/Orleans.Core/Messaging/CachingSiloAddressCodec.cs | Changed to convert PooledBuffer to array before disposal and write separately |
ReubenBond
reviewed
Jan 7, 2026
This was referenced Feb 9, 2026
Closed
Closed
This was referenced Feb 11, 2026
This was referenced Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PooledBuffer._bytesWrittentracking fromPoolingStreamBufferWriter.Microsoft Reviewers: Open in CodeFlow