[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: |
|
||||||||||||||||
| 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: (cherry picked from commit 025efaf470f0dadfe925df8e9a9ef662cfa8522f) |
| Comment by Githook User [ 23/Jun/23 ] |
|
Author: {'name': 'Matt Broadstone', 'email': 'mbroadst@mongodb.com', 'username': 'mbroadst'}Message: |
| 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 |