Skip to content

PooledBuffer cleanup#9871

Merged
ReubenBond merged 4 commits intodotnet:mainfrom
pentp:pooledbuffer-clean
Jan 21, 2026
Merged

PooledBuffer cleanup#9871
ReubenBond merged 4 commits intodotnet:mainfrom
pentp:pooledbuffer-clean

Conversation

@pentp
Copy link
Contributor

@pentp pentp commented Jan 6, 2026

  • Cleanup PooledBuffer.
  • Remove misleading _bytesWritten tracking from PoolingStreamBufferWriter.
Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings January 6, 2026 01:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.cs to reduce code duplication
  • Optimized PooledBuffer methods with better span handling and simplified null checks
  • Simplified PoolingStreamBufferWriter by removing _bytesWritten field (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 ReubenBond enabled auto-merge January 20, 2026 20:28
@ReubenBond ReubenBond added this pull request to the merge queue Jan 21, 2026
Merged via the queue into dotnet:main with commit 989906d Jan 21, 2026
58 of 59 checks passed
@pentp pentp deleted the pooledbuffer-clean branch January 21, 2026 08:12
This was referenced Feb 9, 2026
This was referenced Feb 11, 2026
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.

2 participants

Comments