Locker: Improve Refresh speed (#13430)

Refresh was doing a linear scan of all locked resources. This was adding 
up to significant delays in locking on high load systems with long 
running requests.

Add a secondary index for O(log(n)) UID -> resource lookups. 
Multiple resources are stored in consecutive strings.

Bonus fixes:

 * On multiple Unlock entries unlock the write locks we can.
 * Fix `expireOldLocks` skipping checks on entry after expiring one.
 * Return fast on canTakeUnlock/canTakeLock.
 * Prealloc some places.
This commit is contained in:
Klaus Post
2021-10-15 03:12:13 -07:00
committed by GitHub
parent 76239fa1ae
commit 779060bc16
3 changed files with 129 additions and 50 deletions

View File

@@ -34,7 +34,7 @@ const (
lockMaintenanceInterval = 1 * time.Minute
// Lock validity duration
lockValidityDuration = 20 * time.Second
lockValidityDuration = 1 * time.Minute
)
// To abstract a node over network.