[Perf] Use a shared lock to avoid slow paths
Whenever a tf function is invoked, it calls ResourceMgr::Cleanup. Because most functions do not use the step container, this is often a no-op. Unfortunately, it grabs an exclusive lock on the process-wide (or session-wide) resource manager. This sometimes causes the slow-path to be taken when there are lots of concurrent function invocations (each using their own step counter). As a performance optimization, we first check (using a non-exclusive lock) whether there is a step container that needs to be cleaned up in the first place. PiperOrigin-RevId: 222259910
Loading
Please sign in to comment