Skip to content

Investigate using System.IO.Pipelines #2035

Closed as not planned
Closed as not planned

Description

@roji

A great intro is Marc Gravell's post series: part 1, part 2.

Very related to #1900 (switching to Span).

Notes/caveats:

Activity

  1. added this to the 4.1 milestone on Jul 3, 2018
  2. self-assigned this
    on Jul 3, 2018
  3. YohDeadfall commented on Jul 3, 2018

    @YohDeadfall
    Contributor

    Just await async operations. It's a common practice.

  4. roji commented on Jul 3, 2018

    @roji
    MemberAuthor

    Just await async operations. It's a common practice.

    Can you explain? Do you mean implement sync APIs by calling Wait() on async underlying operations? This would be sync-over-async, and is very deadlock-prone.

    See https://github.com/dotnet/corefx/issues/30822 for a question on what to do with this...

  5. john2014 commented on Jul 4, 2018

    @john2014
  6. roji commented on Jul 4, 2018

    @roji
    MemberAuthor

    @john2014 that example is simple an async function awaiting on another async function. My question is what to do with the synchronous ADO.NET API, in other words how to implement stuff like DbConnection.Open() and DbCommand.ExecuteReader(). If under the hood that function invokes async APIs (because piplines don't have sync APIs), you may get deadlocks as a sync TP thread synchronously blocks on the result of an async operation which requires a TP thread to complete.

  7. roji commented on Jul 5, 2018

    @roji
    MemberAuthor

    @john2014 any particular reason to look at SqlClient for inspiration? That driver is already significantly slower than Npgsql, and as far as I know there are no plans whatsoever to integrate pipelines into it.

  8. roji commented on Jul 5, 2018

    @roji
    MemberAuthor

    More to the point for your comment, SqlClient passes a flag down the stack which controls whether actual I/O will happen synchronously or asynchronously, and this is exactly the way Npgsql currently works. The problem is with the idea of switching to use the new pipelines API, which does not have a sync API surface at all. So I don't see how SqlClient could be relevant here.

  9. john2014 commented on Jul 5, 2018

    @john2014

    Oops, after posting this I noticed that you have already posted this in corefx github page and are currently having a discussion with david fowler and others.

    any particular reason to look at SqlClient for inspiration?

    I assumed that Microsoft would be implementing Pipelines in their system.data.sqlclient library (since its a pretty good fit). Since they have decided not to implement pipeline, then it is definitely not relevant here 😄 . Sorry for the confusion.

  10. austindrenski commented on Jul 9, 2018

    @austindrenski
    Contributor

    Another overview from the msdn blogs.

  11. roji commented on Jul 9, 2018

    @roji
    MemberAuthor

    Thanks @austindrenski! I've already started experimenting with pipelines, as expected it's a huge change in the entire source code and I'm still trying to evaluate the exact value vs. cost etc.

  12. austindrenski commented on Jul 15, 2018

    @austindrenski
    Contributor

    @roji Do you have a branch tracking that work? I'm excited to see how things look with the new paradigm.

  13. 4 remaining items

  14. added this to the 5.0 milestone on Aug 26, 2019
  15. modified the milestones: 5.0, 6.0.0 on Sep 17, 2020
  16. assigned and unassigned on Sep 17, 2020
  17. roji commented on Sep 17, 2020

    @roji
    MemberAuthor

    Assigning to @YohDeadfall who is working on similar ideas as part of the type handler redo for 6.0.

  18. modified the milestones: vNext, Backlog on Apr 8, 2021
  19. NinoFloris commented on Aug 15, 2023

    @NinoFloris
    Member

    Experiments were done in https://github.com/NinoFloris/Woodstar and https://github.com/NinoFloris/Slon

    Our conclusions have been that while the abstraction would fit Npgsql for writing, using its reading apis would be a pain due to the chattyness of the ADO api surface, requiring either continuous unpacking of the ROSeq or creating elaborate handwritten statemachines. We decided that for it to be remotely workable an ArraySequenceReader would be necessary, allowing our current position and data to be stored in a field on a heap allocated object.

    Lastly we'd have to consider the impact on synchronous reading, as pipelines has no sync apis. I worked around this in Slon by issuing a zero byte read against the underlying stream before calling the async apis on the pipereader. This won't work on TFMs that don't have zero byte read support like .net framework.

  20. bgrainger commented on Aug 15, 2023

    @bgrainger
    Contributor

    There is no sync I/O option. What do we do with the sync ADO.NET APIs?

    Lastly we'd have to consider the impact on synchronous reading, as pipelines has no sync apis.

    I've wanted to experiment with Pipelines in MySqlConnector, but the lack of a sync option has always been a major blocker. (I suppose that if a viable approach hasn't materialised in the last five years, it's never going to happen?)

  21. YohDeadfall commented on Aug 15, 2023

    @YohDeadfall
    Contributor

    Almost yes, Microsoft is very conservative at adding new APIs. There must be a very strong reason to get that, and taking into account that sync paths for IO is evil, I won't expect that happening ever.

  22. removed their assignment
    on Aug 15, 2023
  23. added theissue type on Jun 18, 2025
  24. removed this from the Backlog milestone on Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions