-
Notifications
You must be signed in to change notification settings - Fork 324
High memory traffic because of boxed SqlGuid struct #2300
Copy link
Copy link
Labels
Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the labelIssues that are ready to be picked up for anyone interested. Please self-assign and remove the label
Description
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 putting SqlGuid struct to SqlBuffer.SqlGuid property (see the image bellow).
Describe the solution you'd like
SqlBuffer already supports an efficient way to store Guid values. What I would like to do is:
- change implementation of
Microsoft.Data.SqlClient.SqlBufferremove(taking the second alternative approach, removing ofSqlGuidvalue fromStorageTypeenumSqlGuidvalue from enum looks like a bad idea);- save
Guidrepresentation ofSqlGuidto_value._guid(similar to whatGuidsetter does, but with checking ifSqlGuidvalue is null) - read
SqlGuidvalue from_value._guid
Describe alternatives you've considered
- add a field of
SqlGuidtype toSqlBuffer, but it seems memory inefficient - same as the main approach, but without removing
SqlGuidvalue fromStorageTypeenum, in case it is really important. The only place where it looks important to me iss_dbTypeToStorageTypemapping 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.Guiddoes not support nulls.
Additional context
- Microsoft.Data.SqlClient version is 5.1.0;
- We use Microsoft.Data.SqlClient together with NHibernate;
- Almost all our db tables contain Guid columns, so, memory traffic is really high in our case.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the labelIssues that are ready to be picked up for anyone interested. Please self-assign and remove the label
Type
Projects
Status
Backlog
