[SERVER-77012] Optimize NamespaceString construction in authorization path Created: 10/May/23  Updated: 29/Oct/23  Resolved: 16/May/23

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

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

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Backport Requested:
v7.0
Sprint: Server Serverless 2023-05-15, Server Serverless 2023-05-29
Participants:

 Description   

When inspecting a recent flamegraph, we observed a decent amount of time spent in authorization and in particular in NamespaceStringUtil for parsing tenant ids for requests. A few optimizations came to mind:

  • Don't combine dbName and collectionName into a string, just to split it later when building a NamespaceString.
  • Alternatively, skip parsing completely in all paths if multitenancy is not enabled
  • Provide optimized constructors for both NamespaceString(DatabaseName, StringData) and NamespaceString(boost::optional<TenantId>, StringData, StringData) to avoid any unnecessary allocations


 Comments   
Comment by Githook User [ 16/May/23 ]

Author:

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

Message: SERVER-77012 Skip parsing for tenantIds if multitenancy disabled

(cherry picked from commit d12e38e18857307e369c23dde1873b54666d6ae3)
Branch: v7.0
https://github.com/mongodb/mongo/commit/7bdbb9dc513db9ccb36ab66ef5964be3d75a0b8d

Comment by Githook User [ 16/May/23 ]

Author:

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

Message: SERVER-77012 Skip parsing for tenantIds if multitenancy disabled
Branch: master
https://github.com/mongodb/mongo/commit/d12e38e18857307e369c23dde1873b54666d6ae3

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