mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 21:50:22 +03:00
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:
@@ -44,13 +44,12 @@ func BenchmarkLockArgs(b *testing.B) {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
req := &http.Request{
|
||||
Body: ioutil.NopCloser(bytes.NewReader(argBytes)),
|
||||
}
|
||||
req := &http.Request{}
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
req.Body = ioutil.NopCloser(bytes.NewReader(argBytes))
|
||||
getLockArgs(req)
|
||||
}
|
||||
}
|
||||
@@ -64,12 +63,12 @@ func BenchmarkLockArgsOld(b *testing.B) {
|
||||
|
||||
req := &http.Request{
|
||||
Form: values,
|
||||
Body: ioutil.NopCloser(bytes.NewReader([]byte(`obj.txt`))),
|
||||
}
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
req.Body = ioutil.NopCloser(bytes.NewReader([]byte(`obj.txt`)))
|
||||
getLockArgsOld(req)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user