[SERVER-77103] Cache the APIVersionMetrics::update Created: 12/May/23  Updated: 14/Aug/23  Resolved: 14/Aug/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Mark Benvenuto Assignee: Xuerui Fa
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-78391 Improve performance for API version m... Open
Related
related to SERVER-77087 Make the retention period of metrics.... Closed
related to SERVER-77088 Introduce a metric that lists the num... Closed
Assigned Teams:
Replication
Sprint: Repl 2023-05-29, Repl 2023-06-12, Repl 2023-08-07, Repl 2023-08-21
Participants:

 Description   

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.


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