-
Notifications
You must be signed in to change notification settings - Fork 294
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
High memory traffic because of boxed SqlGuid struct #2300
Comments
The changes are simple. So, I can do it if/when the issue is approved. |
@wilbit All contributors are welcomed to create PRs; we will review them and address them |
That's a bit strange. If you're calling IsDBNull it shouldn't be forcing the sql type it should be using the guid type and only creating the sql type if you request it. Can you provide a small repro? |
@Wraith2 , have you seen the stack trace on the image and code of SqlDataReader.TryReadColumnInternal(i: int_value, readHeaderOnly: true, forStreaming: false), TdsParser.GetNullSqlValue and SqlBuffer.set_SqlGuid? @kf-gonzalez I will prepare PR tomorrow. |
I saw the trace. I just remember specifically optimizing guid in the past so that it doesn't allocate. It looks like this specific case slipped past me. Looking at the code I think we should probably be calling |
I will have a look, @Wraith2 |
Here is the PR: #2306, it removed boxing of PS: I have also noticed, that |
I noticed the |
Is your feature request related to a problem? Please describe.
When our application is starting it loads a lot of data from DB and it causes memory consumption growth and high pressure to GC because of big memory traffic.
On the third place of killed objects is boxed
System.Data.SqlTypes.SqlGuid
struct.These boxed values are 99.9% created when
TdsParser
is puttingSqlGuid
struct toSqlBuffer.SqlGuid
property (see the image bellow).Describe the solution you'd like
SqlBuffer
already supports an efficient way to storeGuid
values. What I would like to do is:Microsoft.Data.SqlClient.SqlBuffer
remove(taking the second alternative approach, removing ofSqlGuid
value fromStorageType
enumSqlGuid
value from enum looks like a bad idea);Guid
representation ofSqlGuid
to_value._guid
(similar to whatGuid
setter does, but with checking ifSqlGuid
value is null)SqlGuid
value from_value._guid
Describe alternatives you've considered
SqlGuid
type toSqlBuffer
, but it seems memory inefficientSqlGuid
value fromStorageType
enum, in case it is really important. The only place where it looks important to me iss_dbTypeToStorageType
mapping array inMicrosoft.Data.SqlClient.Server.ValueUtilsSmi
, and I am not sure if it is safe to change the mapping toSqlBuffer.StorageType.Guid
. It seems like it is not safe, because implementation ofSqlBuffer.Guid
does not support nulls.Additional context
The text was updated successfully, but these errors were encountered: