Questions tagged [system.io.pipelines]

a .Net library that is designed to make it easier to do high performance IO in .NET. Use for questions about implementation of the library classes.

System.IO.Pipelines is a new library that is designed to make it easier to do high performance IO in .NET. The library targets the .NET Standard and works on all .NET implementations.

High Performance IO in .Net - Microsoft

28 questions
14
votes
2 answers

Why is this System.IO.Pipelines code much slower than Stream-based code?

I've written a little parsing program to compare the older System.IO.Stream and the newer System.IO.Pipelines in .NET Core. I'm expecting the pipelines code to be of equivalent speed or faster. However, it's about 40% slower. The program is simple:…
Will
  • 2,086
  • 23
  • 30
7
votes
2 answers

Obtain a Span over a struct without making a copy of the struct

I have been experimenting with Span as part of ReadOnlySequence and System.IO.Pipelines. I am currently trying to obtain a Span over a struct without using unsafe code and without making a copy of that struct. My struct is simply: …
Rowan Smith
  • 1,815
  • 15
  • 29
6
votes
1 answer

How to create a responding TCP listener with the System.IO.Pipelines package?

I want to create a TCP Listener using Kestrel and the System.IO.Pipelines package. The messages I receive will always be HL7 messages. An example message could…
user13755987
3
votes
1 answer

Example implementation of IDuplexPipe for a TCP server

I've recently discovered the System.IO.Pipelines namespace and it looks interesting. I've been trying to implement the IDuplexPipe interface in the context of a simple TCP server which accepts connections and then communicates back and forth with…
Erik Kinding
  • 1,742
  • 2
  • 15
  • 32
3
votes
1 answer

Pipelines buffer preserving until processing is complete

I am researching the possibility of using pipelines for processing binary messages coming from network. The binary messages i will be processing come with an payload and it is desirable to keep the payload in its binary form. The idea is to read out…
NullReference
  • 862
  • 1
  • 11
  • 27
3
votes
1 answer

A better way to copy a ReadOnlySequence to a Struct

So I have been working with System.Buffers and specifically the ReadOnlySequence class lately. I have a struct of primitives defined with the following: [StructLayout(LayoutKind.Sequential,Pack =1,CharSet=CharSet.Unicode)] public partial struct…
Rowan Smith
  • 1,815
  • 15
  • 29
2
votes
0 answers

PipeReader Advance for number of bytes

How to advance PipeReader exact number of bytes? (I'm not interested in skipped data) AdvanceTo overloads only expects SequencePosition which is not user constructible.
OwnageIsMagic
  • 1,949
  • 1
  • 16
  • 31
2
votes
1 answer

How to read all POST body bytes in an ASP.NET app using System.IO.Pipelines.PipeReader?

I am trying to switch my ASP.NET application using .Net 6 from Stream to PipeReader as recommended by Microsoft. Here is my custom method: private static async Task GetRequestBodyBytesAsync(PipeReader reader) { byte[] bodyBytes; do …
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
2
votes
1 answer

Can I have a C# System.IO.Pipelines.Pipe with multiple readers?

I'm using a System.IO.Pipelines.Pipe in .NET 5 to transfer data from a stream to a reader, and now I'm thinking I'd like to have several independent readers that would all process same stream of data. Is there a variant of a Pipe that would let me…
Ivan Koshelev
  • 3,830
  • 2
  • 30
  • 50
2
votes
2 answers

How do I use the PipeReader for reading a JSON flatfile?

I am trying to learn this new system.io.pipelines, and the new webapi strategy for deserializing json... I wrote my own JsonConverter, but I can't figure out the correct way to initialize a Utf9JsonReader from a json flat file fixture. here is the…
Nathan Tregillus
  • 6,006
  • 3
  • 52
  • 91
2
votes
1 answer

Read from PipeReader with timeout

Currently I'm using the following utility extension to read from a PipeReader with a specified timeout. The timeout is required to properly implement Keep-Alive within a HTTP server. internal static async Task ReadWithTimeoutAsync(this…
Gene
  • 4,192
  • 5
  • 32
  • 56
2
votes
1 answer

System.Text.Json: deserializing from System.IO.Pipelines

I am consuming Json from a TcpClient, and to get a solution with low allocation and good performance I decided to use the new System.IO.Pipelines for handling IO and System.Text.Json for deserialization. The output from the pipe is a…
Petter T
  • 3,387
  • 2
  • 19
  • 31
2
votes
1 answer

How to detect when a PipeReader has reached the end of the data source (end of pipe)?

We can call ReadAsync() and examine a buffer for read bytes... PipeReader reader = ...; ReadResult readResult = await reader.ReadAsync(); ReadOnlySequence buffer = readResult.Buffer; long availableBytes = buffer.Length If the length does not…
redcalx
  • 8,177
  • 4
  • 56
  • 105
2
votes
1 answer

Does Pipelines.Sockets.Unofficial.SocketConnection ever flush without a request?

I'm using Marc Gravell's Pipelines.Sockets.Unofficial library to get an IDuplexPipe over a socket, but I'm finding a case where I need to modify a message header before flushing. If I call Advance, am I guaranteed it will never flush until I call…
Julian Birch
  • 2,605
  • 1
  • 21
  • 36
1
vote
1 answer

My program crashes when I add the using keyword before a StreamReader, why?

I have a method which starts a DispatcherTimer that reads all messages from a System.IO.Pipes.NamedPipe. Before the timer starts, I want to read the first message. // Initiate the PipeClient pipeClient = new NamedPipeClientStream(".", pipeName,…
1
2