Commit 1bcdfbac authored by Brennan Saeta's avatar Brennan Saeta Committed by TensorFlower Gardener
Browse files

[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
parent 177b34c3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment