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