Skip to content
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

Removed heap allocations from OdbcDataReader #36912

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
2 participants
@bbartels
Copy link
Contributor

bbartels commented Apr 16, 2019

Removed allocations from when data is being parsed into managed structures within the ODBCDataReader.

Method MeanCurr MeanNew AllocCurr AllocNew AllocDiff
GetDateTime() 48.18 ms 48.39 ms 862.66 KB 470.59 KB - 45.45%
GetString() 63.45 ms 63.51 ms 1333.2 KB 941.13 KB - 29.4%
GetDecimal() 80.82 ms 80.38 ms 2117.38 KB 1725.31 KB - 18.5%

[Benchmarking results of iterating through 10000 rows in a MariaDB database]

Notes:

  1. This does use an unsafe an code block to copy from the IntPtr into the Span, as there is no other way of doing this.
    Related issue: #18946

  2. There are two unused internal methods in DbBuffer.cs, I marked them with a comment, in case they should be removed.

  3. Furthermore, the new Read/Write-Numeric implementation is not quite optimal yet, as there is no way for one to create/read a decimal from/into a Span<byte>. Though I am not quite sure if it is used at all, as GetDecimal() does not seem to rely on that function.
    Related issue: #35877

@danmosemsft

This comment has been minimized.

Copy link
Member

danmosemsft commented Apr 16, 2019

Thanks for the effort. However this library is legacy code, with mostly manual tests, so we are avoiding changes that are not essential. I do not think perf changes like this meet that bar.

@bbartels

This comment has been minimized.

Copy link
Contributor Author

bbartels commented Apr 17, 2019

Thanks for the effort. However this library is legacy code, with mostly manual tests, so we are avoiding changes that are not essential. I do not think perf changes like this meet that bar.

Okay, will close this for now then!

@bbartels bbartels closed this Apr 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.