Skip to content

Share System.IO.Pipelines.BufferSegments (make BufferSegmentStack static) across instances of Pipe #49259

@cobalthex

Description

@cobalthex

One of the benefits of System.IO.Pipelines.Pipe is its ability to be re-used and otherwise conserve memory through usage of ArrayPools internally.

Pipes create BufferSegments internally to store the memory segments it uses, which are further stored in a ReadOnlySequence.
While the buffer segments are re-used through BufferSegmentStack, this is a unique instance on every Pipe and cannot be shared.

This creates a potential issue where if using a pool of Pipes. Each pipe can have its stack grow ("boundlessly") and maybe end up with many un/under-used segments in a long-lived pool.

I would propose that having the buffer segments be responsible for owning/renting the contained array/memory and that the Pipe is only responsible for renting segments.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions