use unixNanoTime instead of time.Time in lockRequestorInfo (#20140)

Bonus: Skip Source, Quorum fields in lockArgs that are never
sent during Unlock() phase.
This commit is contained in:
Harshavardhana
2024-07-24 03:24:01 -07:00
committed by GitHub
parent 6fe2b3f901
commit 3b21bb5be8
11 changed files with 197 additions and 89 deletions

View File

@@ -34,6 +34,7 @@ import (
"sync"
"time"
"unicode/utf8"
"unsafe"
"github.com/google/uuid"
"github.com/klauspost/compress/s2"
@@ -246,6 +247,24 @@ func pathsJoinPrefix(prefix string, elem ...string) (paths []string) {
return paths
}
// string concat alternative to s1 + s2 with low overhead.
func concat(ss ...string) string {
length := len(ss)
if length == 0 {
return ""
}
// create & allocate the memory in advance.
n := 0
for i := 0; i < length; i++ {
n += len(ss[i])
}
b := make([]byte, 0, n)
for i := 0; i < length; i++ {
b = append(b, ss[i]...)
}
return unsafe.String(unsafe.SliceData(b), n)
}
// pathJoin - like path.Join() but retains trailing SlashSeparator of the last element
func pathJoin(elem ...string) string {
sb := bytebufferpool.Get()