-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Performance #245
Improve Performance #245
Conversation
This produces a 20% reduction in allocations in the "ManyRowsNewSync" scenario.
This reduces allocations in the "ManyRowsNewSync" scenario by 44%.
This reduces allocations in the "ManyRowsNewSync" scenario by 19%.
This reduces allocations in the "ManyRowsNewSync" scenario by 24%.
Also switch to using -1 as a sentinel instead of null to reuse function signature between read and write. This reduces allocations for the "ManyRowsNewSync" scenario by 49%.
This reduces allocations in the "ExecuteScalarNewAsync" scenario by 3%.
This reduces the allocations for the "ExecuteScalarNewSync" scenario by 10%.
SummaryThe connector was very memory-inefficient. The All Async methods still pay the performance penalty of constructing the async state machine (but should support higher concurrency). There is still room for further improvement in the async code paths. DetailsTimings after each commit in this PR, taken from my Windows desktop computer. Initial Timings
Rewrite ReadPayloadAsync
Rewrite ReadPacketAsync
Eagerly Create CancelAction
Inline MySqlSession.TryAsync
Lazily create CancelAction (RegisterCancel)
Convert ByteArrayReader/PayloadData to structs
Remove GetNextSequenceNumber Func<int?>
Remove async state machine from MySqlCommand
Fix unnecessary reallocation in ParseAndBindParameters
|
This makes "OpenFromPoolNewSync" 9x faster. If the client is disconnected, SendAsync should still throw a SocketException, allowing us to detect the failed connection.
Profiling showed that This makes Remove Socket.Poll
|
Further reductions in allocations, particularly for Defer lambda creation in WritePacketAsync
Defer lambda creation in WritePayloadAsync
|
Shipped in 0.19.0. |
Improve the speed and reduce the number of allocations in common scenarios, based on the recently-added BenchmarkDotNet benchmarks.