Replies: 6 comments 8 replies
-
I'm not sure what the larger design is, and what's started to drive the broader SqlClientX effort; I get the impression that a design's been developed offline and is being committed piecemeal. Based on discussions within the PRs, my understanding is that the long-term goal is to replace the managed TDS implementation (completely or in part) and eliminate the various async-over-sync / sync-over-async code paths, then to move towards removing the native TDS implementation. This would maintain the .NET Framework and .NET targets, but enforce the documented SQL Server version compatibility more stringently and deadhead the code which supports it (so .NET Framework would probably lose SQL Server 2000 support and both versions would probably lose SQL Server 2005/2008/2012 support.) We looked at an issue around connection-level packet locking a few months ago, and I'd tried to implement MARS and transports with minimal locking. I eventually found that while the transport layer could be improved, this increased lock contention in TdsParser and rendered the changes nearly meaningless until that could be addressed. I don't personally think that a partial TDS replacement would make a major performance difference, so suspect that the goal is a full replacement. I'd also like to understand the wider SqlClientX effort though - a lot of this is educated guesswork and speculation. |
Beta Was this translation helpful? Give feedback.
-
Thanks @Wraith2 for starting this discussion. IntroductionMicrosoft.Data.SqlClient (will be called SqlClient in the rest of the discussions), is a feature rich driver which has been serving the needs of the SQL Server customers since a really long time. The driver has evolved from System.Data.SqlClient namespace in System.Data.dll in .Net framework, to System.Data.SqlClient.dll in .Net core to now Microsoft.Data.SqlClient which can be used by applications on .Net framework and .Net runtime(s). We looked at the issues in SqlClient and though there are many reported on Github, but there are two issues which stood out, which the team decided to prioritize, to solve the needs of the modern applications built on .Net, which intend to use SQL server as the database
Connection poolFor Connection Pool throughput issue, the issue is quite simple. The driver's connection pool was created for conservative warm up, and doesn't allow a burst of connections. We need to change the connection pool design to allow more than one connection to be opened in parallel. We will cover the strategy to tackle the connection pool in separate discussions, or different post in this discussion. However to increase the throughput of the connection pool, we need to move away from current Connection establishment method, where we invoke a constructor Async API performance improvementToday, the Async APIs of SqlClient are much slower to perform, when compared to the sync APIs. Async is not expected to be always faster than Sync, but even with a modest workload using SqlClient, with reasonably large amount of data, the async APIs performance can be lot better. This can be seen in various issues reported on Github, and many issues brought to the attention of our team, from customers inside Microsoft itself. We have had significant contributions from the community to improve the async behavior of SqlClient, and it is clear that the SqlClient today, is lot better than what it was about 6-7 years ago. Q: But can the driver performance be even better, with a completely managed .Net implementation of SqlClient? Based on the feedback from EF team, and the folks who have worked on the driver, we spent some time working on writing the driver to be able to fetch some large data with async APIs (1MB, 5 MB , 10 MB, 20MB) varchar (max) from the server and test its performance. @roji had opened the issue #593 which shows that the driver performance while reading large data using Async APIs leaves a lot to be desired from the driver performance. At this point we had the following to work with:
Working with these principles, an implementation of SqlClient focussed on Async I/O using .Net 8 runtime, was tried. https://github.com/saurabh500/SqlClient/tree/refactor We noticed a VERY VERY significant difference between the current implementation of MDS and the experiment in the link I have posted above. It turns out that we can improve the driver's async performance for large data reads by atleast 2X (and I am being very very conservative with this number). The benchmarks were done on Windows and on Linux. There was no native SNI involved in the new implementation. I haven't performed any benchmarks with Tech empower. Keep in mind, that the implementation that I have posted above was a matter of writing code for only a week, to see if using the principles above, without any micro-optimizations can really improve SqlClient! Well, turns out that the principles can hold true for SqlClient's perf improvements. Well, good. Now what? SqlClientX is bornWe have this large driver codebase, with a lot of features, and this proof that it can be better. So how do we combine the two? We all agree that if we change the way the I/O is rewritten in the driver, then we need to make sure that all the parts of the driver which touch I/O (which is a lot of parts of the driver), will need to be changed. It all starts with the connection, and then goes into the Query execution. It is hard to remove pieces of the driver, and write them and plug them back in, so we decided to start with Connection Pool, and start by taking care of connection pool throughput improvement, followed by query execution. What we are doing is, for public surface area like These We want to be able to somehow be able to tell When we know that SqlConnectionX and its other X friends are ready ( I will define "ready"), we want to be able to offer SqlConnectionX's implementation as the default implementation. Goals
@Wraith2 I hope I have begun to answer your questions. I imagine more questions coming up about SNI and what not. But I think I will stop my post at this point. We can take more discussions around why Stream, why not Pipeline, or when Pipeline etc. But I hope to focus this discussion on the goals of SqlClientX. I hope my point about Backward compatibility speaks of the platform and runtime.
Yes and no. We have a general idea about what we are trying to do and how we want to structure the connectivity pieces of the driver. Not everything is ironed out, like Exception handling, event source tracing as you can tell from my PR. However, we felt that we need to have a point of view of how we want ClientX to look like. We have folks working on the driver, who have a lot of experience with the driver and other team members, for who the driver space is new. Hence you will see some patterns emerge in how the driver would look which is the outcome of the discussion inside the team. Overall the patterns would not change, but there is some fine tuning that is needed. /cc @Wraith2 @ErikEJ @edwardneal @roji @benrr101 @mdaigle @VladimirReshetnikov @samsharma2700 @ajcvickers @David-Engel @JRahnama Folks, I am sure I haven't copied all those who might be interested in this blurb. Feel free to tag other contributors for SqlClient. |
Beta Was this translation helpful? Give feedback.
-
@roji is the right person to comment on Woodstar. |
Beta Was this translation helpful? Give feedback.
-
Many of the folks contributing to the PRs work in the SQL Server organization. |
Beta Was this translation helpful? Give feedback.
-
I can linearize the performance and bring it into line with sync performance in terms of time, there is additional memory overhead (largely inline with existing async) but it's tolerable. I've been able to do this for years, see #593 (comment) I spent the weekend reimplementing that PR on the current codebase and adding test coverage for the new packet handling that is needed to make it stable. I've been waiting for the merge of the codebases to get to a point where i didn't have to duplicate the work onto the two coedbases but i've given up waiting. A major problem with SqlClient is that there isn't enough investment in it. We could move a lot faster if PR's could be reviewed and tested faster. Another major problem is communication, if you'd opened a feature request for some of the things that need doing a community member might have picked them up and given it a go but because any internal-to-MS requirements aren't communicated the first contributors know of it is when a PR turns up to add the feature. |
Beta Was this translation helpful? Give feedback.
-
I've started a discussion for the connection pool redesign over at #2612. |
Beta Was this translation helpful? Give feedback.
-
There have been a number of PR's referencing SqlClientX and they seem to be adding new functionality.
I'd like to understand the parameters of this effort, what platforms and runtimes is it targeting.
I'd like to know what features it is going to be used to add if it is possible to do so.
I'd like to know how this changes the datalab/woodstar work that seems to have stalled.
I'd like to understand the driving force behind the effort because it seems to be coming from non-EF set of developers meaning that political things inside MS have changed.
I'd like to know how external contributors can be involved and informed about this and help out if it is possible.
/cc @saurabh500
Beta Was this translation helpful? Give feedback.
All reactions