|
APIVersionMetrics::update tracks the last used DateTime of a given <Application Name, API Version> pair. For every request, we take a global mutex, do a two level lookup through hash tables and then update a datetime.
I surmise, that for a given client the pair of <Application Name, API Version> never changes after initial connection. For instance, with non-internal clients, Application Name can only be set on the first hello command. For internal clients (mongos -> mongod), Application Name can be changed but it is unlikely. The API Version likely also does not change during the lifetime of a connection.
To avoid the two level lookup and global lock, we could cache a handle in mongo::Client to an atomicword for date_t and then reuse that it <Application Name, API Version> has not changed.
I would expect a small perf benefit by avoiding the lock and lookups.
|