You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to allow random-access into each row (seeking back to previous columns, re-reading the same column). By its very design, pipelines is about consuming read data and releasing buffers back, so this may not be a good fit... It's probably possible to keep the row buffered by not advancing - get a span each time, then return it without advancing (so this is probably not an issue).
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.
@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.
@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.
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.
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.
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.
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.
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?)
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.
Activity
YohDeadfall commentedon Jul 3, 2018
Just await async operations. It's a common practice.
roji commentedon Jul 3, 2018
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...
john2014 commentedon Jul 4, 2018
Here is a simple example:
public async Task GetGWB()
{
HttpClient hc = new HttpClient();
await hc.GetAsync("http://www.google.com/");
return true;
}
More examples: https://www.google.com/search?q=asp.net+async+await+example
roji commentedon Jul 4, 2018
@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()andDbCommand.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.john2014 commentedon Jul 5, 2018
My suggestion would be see how System.Data.Sqlclient handles this scenario.
Github page: https://github.com/dotnet/corefx/tree/master/src/System.Data.SqlClient
Pipeline: https://github.com/dotnet/corefx/issues?q=is%3Aissue+is%3Aopen+pipeline+label%3Aarea-System.IO.Pipelines
roji commentedon Jul 5, 2018
@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.
roji commentedon Jul 5, 2018
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.
john2014 commentedon Jul 5, 2018
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.
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.
austindrenski commentedon Jul 9, 2018
Another overview from the msdn blogs.
roji commentedon Jul 9, 2018
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.
austindrenski commentedon Jul 15, 2018
@roji Do you have a branch tracking that work? I'm excited to see how things look with the new paradigm.
4 remaining items
roji commentedon Sep 17, 2020
Assigning to @YohDeadfall who is working on similar ideas as part of the type handler redo for 6.0.
NinoFloris commentedon Aug 15, 2023
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.
bgrainger commentedon Aug 15, 2023
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?)
YohDeadfall commentedon Aug 15, 2023
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.