[SERVER-77348] NamespaceStringOrUUID forces unnecessary allocations and copies Created: 22/May/23  Updated: 29/Oct/23  Resolved: 23/Jun/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0, 7.0.0-rc6

Type: Improvement Priority: Major - P3
Reporter: Louis Williams Assignee: Matt Broadstone
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Duplicate
is duplicated by SERVER-77640 Remove unnecessary copies caused by N... Closed
Related
Assigned Teams:
Serverless
Backwards Compatibility: Fully Compatible
Backport Requested:
v7.0
Participants:

 Description   

The nss() function forces callers to always make a copy of the Namespace string. NamespaceString checks are not uncommon, so the cost of these small memory allocations can add up over time.

We should just use a raw pointer or return an optional reference to the underlying NSS.

The specific function call that I saw show up when profiling was this isSystemDotProfile function call, which is in our hot write path on the primary.



 Comments   
Comment by Githook User [ 23/Jun/23 ]

Author:

{'name': 'Matt Broadstone', 'email': 'mbroadst@mongodb.com', 'username': 'mbroadst'}

Message: SERVER-77348 Add accessors for querying state of NamespaceStringOrUUID

(cherry picked from commit 025efaf470f0dadfe925df8e9a9ef662cfa8522f)
Branch: v7.0
https://github.com/mongodb/mongo/commit/e90e235c9053ffe14be27d3e22d1d7f87e8b60ed

Comment by Githook User [ 23/Jun/23 ]

Author:

{'name': 'Matt Broadstone', 'email': 'mbroadst@mongodb.com', 'username': 'mbroadst'}

Message: SERVER-77348 Add accessors for querying state of NamespaceStringOrUUID
Branch: master
https://github.com/mongodb/mongo/commit/025efaf470f0dadfe925df8e9a9ef662cfa8522f

Comment by Louis Williams [ 01/Jun/23 ]

The vision of this ticket would be to expose hasNss() and hasUuid() functions with getNss() and getUuid() getters that assert that the variant holds the specific type and return a reference to avoid the copy. I started work on this but since the NamespaceStringOrUUID is quite pervasive, I stopped due to time once I ran into an IDL error.

Comment by Louis Williams [ 23/May/23 ]

Moving back to open because the performance improvements are not worth the API changes to NamespaceStringOrUUID

Generated at Thu Feb 08 06:35:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.