Skip to content

Guys, System.Buffers.Slice is so slow, it's supposed to interop with high performance System.IO.Pipelines #94629

Answered by tannergooding
Xyncgas asked this question in General
Discussion options

You must be logged in to vote

ROSequence tracks a sequence, which can possibly be many segments, and so slicing arbitrary buffers out of it can be quite expensive and is not trivial to inline. In the worst case, it ends up having to walk through many segments to find the relevant start (effectively walking a linked list) and then continue walking until it finds the end.

There are potentially things that could be done to improve that for the fast path, but you probably want to be using something like SequenceReader, which helps offset the costs (particularly when doing sequential reading)

CC. @GrabYourPitchforks

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Xyncgas
Comment options

Answer selected by Xyncgas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants