[CSHARP-4292] Performance: Eliminate allocations in GetHashCode()for all BSON data types Created: 11/Aug/22  Updated: 28/Oct/23  Resolved: 24/Aug/22

Status: Closed
Project: C# Driver
Component/s: BSON, Performance
Affects Version/s: 2.13.2, 2.17.1
Fix Version/s: 2.18.0

Type: Improvement Priority: Major - P3
Reporter: Daniel Hegener Assignee: James Kovacs
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2022-08-11-17-40-47-892.png     PNG File image-2022-08-11-17-41-48-039.png     PNG File image-2022-08-11-17-44-13-522.png     PNG File image-2022-08-11-17-45-14-703.png    
Issue Links:
Related
is related to CSHARP-4300 Reduce memory traffic associated with... Backlog
Backwards Compatibility: Fully Compatible

 Description   

The current GetHashCode() implementations for most BSON data types allocate substantial amounts of memory which can be eliminated easily. Here's the current state in our .NET 4.7.2 process using the .NET Standard 2.0 version of the C# driver:

This is a boxing issue that be safely eliminated - I'll create a PR in a few minutes for the required change. Here's how things look after the change:



 Comments   
Comment by Githook User [ 24/Aug/22 ]

Author:

{'name': 'James Kovacs', 'email': 'jkovacs@post.harvard.edu', 'username': 'JamesKovacs'}

Message: Added Daniel Hegener <daniel.hegener@fisglobal.com> to contributors list for CSHARP-4292 among other contributions.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/7ddee4bb612c52d2938c52812a763c6162b92a5c

Comment by Boris Dogadov [ 16/Aug/22 ]

Thanks daniel.hegener@gmx.net,
From initial look this looks like a good optimization. We'll review the PR in more detail.
Please follow this ticket for further updates.

Comment by Daniel Hegener [ 11/Aug/22 ]

PR: https://github.com/mongodb/mongo-csharp-driver/pull/864

Generated at Wed Feb 07 21:47:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.