mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vendor: update github.com/VictoriaMetrics/fastcache from v1.8.0 to v1.9.0
This commit is contained in:
parent
cde4664f0d
commit
c3d02ee75a
7 changed files with 29 additions and 23 deletions
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go/storage v1.20.0
|
cloud.google.com/go/storage v1.20.0
|
||||||
github.com/VictoriaMetrics/fastcache v1.8.0
|
github.com/VictoriaMetrics/fastcache v1.9.0
|
||||||
|
|
||||||
// Do not use the original github.com/valyala/fasthttp because of issues
|
// Do not use the original github.com/valyala/fasthttp because of issues
|
||||||
// like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b
|
// like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b
|
||||||
|
|
5
go.sum
5
go.sum
|
@ -110,8 +110,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko
|
||||||
github.com/SAP/go-hdb v0.14.1/go.mod h1:7fdQLVC2lER3urZLjZCm0AuMQfApof92n3aylBPEkMo=
|
github.com/SAP/go-hdb v0.14.1/go.mod h1:7fdQLVC2lER3urZLjZCm0AuMQfApof92n3aylBPEkMo=
|
||||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||||
github.com/VictoriaMetrics/fastcache v1.8.0 h1:ybZqS7kRy8YVzYsI09GLzQhs7iqS6cOEH2avtknD1SU=
|
github.com/VictoriaMetrics/fastcache v1.9.0 h1:oMwsS6c8abz98B7ytAewQ7M1ZN/Im/iwKoE1euaFvhs=
|
||||||
github.com/VictoriaMetrics/fastcache v1.8.0/go.mod h1:n7Sl+ioh/HlWeYHLSIBIE8TcZFHg/+xgvomWSS5xuEE=
|
github.com/VictoriaMetrics/fastcache v1.9.0/go.mod h1:otoTS3xu+6IzF/qByjqzjp3rTuzM3Qf0ScU1UTj97iU=
|
||||||
github.com/VictoriaMetrics/fasthttp v1.1.0 h1:3crd4YWHsMwu60GUXRH6OstowiFvqrwS4a/ueoLdLL0=
|
github.com/VictoriaMetrics/fasthttp v1.1.0 h1:3crd4YWHsMwu60GUXRH6OstowiFvqrwS4a/ueoLdLL0=
|
||||||
github.com/VictoriaMetrics/fasthttp v1.1.0/go.mod h1:/7DMcogqd+aaD3G3Hg5kFgoFwlR2uydjiWvoLp5ZTqQ=
|
github.com/VictoriaMetrics/fasthttp v1.1.0/go.mod h1:/7DMcogqd+aaD3G3Hg5kFgoFwlR2uydjiWvoLp5ZTqQ=
|
||||||
github.com/VictoriaMetrics/metrics v1.18.1 h1:OZ0+kTTto8oPfHnVAnTOoyl0XlRhRkoQrD2n2cOuRw0=
|
github.com/VictoriaMetrics/metrics v1.18.1 h1:OZ0+kTTto8oPfHnVAnTOoyl0XlRhRkoQrD2n2cOuRw0=
|
||||||
|
@ -1299,7 +1299,6 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
|
37
vendor/github.com/VictoriaMetrics/fastcache/fastcache.go
generated
vendored
37
vendor/github.com/VictoriaMetrics/fastcache/fastcache.go
generated
vendored
|
@ -271,20 +271,18 @@ func (b *bucket) Reset() {
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bucket) Clean() {
|
func (b *bucket) cleanLocked() {
|
||||||
b.mu.Lock()
|
|
||||||
bGen := b.gen & ((1 << genSizeBits) - 1)
|
bGen := b.gen & ((1 << genSizeBits) - 1)
|
||||||
bIdx := b.idx
|
bIdx := b.idx
|
||||||
bm := b.m
|
bm := b.m
|
||||||
for k, v := range bm {
|
for k, v := range bm {
|
||||||
gen := v >> bucketSizeBits
|
gen := v >> bucketSizeBits
|
||||||
idx := v & ((1 << bucketSizeBits) - 1)
|
idx := v & ((1 << bucketSizeBits) - 1)
|
||||||
if gen == bGen && idx < bIdx || gen+1 == bGen && idx >= bIdx || gen == maxGen && bGen == 1 && idx >= bIdx {
|
if (gen+1 == bGen || gen == maxGen && bGen == 1) && idx >= bIdx || gen == bGen && idx < bIdx {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
delete(bm, k)
|
delete(bm, k)
|
||||||
}
|
}
|
||||||
b.mu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bucket) UpdateStats(s *Stats) {
|
func (b *bucket) UpdateStats(s *Stats) {
|
||||||
|
@ -296,19 +294,17 @@ func (b *bucket) UpdateStats(s *Stats) {
|
||||||
|
|
||||||
b.mu.RLock()
|
b.mu.RLock()
|
||||||
s.EntriesCount += uint64(len(b.m))
|
s.EntriesCount += uint64(len(b.m))
|
||||||
|
bytesSize := uint64(0)
|
||||||
for _, chunk := range b.chunks {
|
for _, chunk := range b.chunks {
|
||||||
s.BytesSize += uint64(cap(chunk))
|
bytesSize += uint64(cap(chunk))
|
||||||
}
|
}
|
||||||
s.MaxBytesSize += uint64(len(b.chunks))*chunkSize
|
s.BytesSize += bytesSize
|
||||||
|
s.MaxBytesSize += uint64(len(b.chunks)) * chunkSize
|
||||||
b.mu.RUnlock()
|
b.mu.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bucket) Set(k, v []byte, h uint64) {
|
func (b *bucket) Set(k, v []byte, h uint64) {
|
||||||
setCalls := atomic.AddUint64(&b.setCalls, 1)
|
atomic.AddUint64(&b.setCalls, 1)
|
||||||
if setCalls%(1<<14) == 0 {
|
|
||||||
b.Clean()
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(k) >= (1<<16) || len(v) >= (1<<16) {
|
if len(k) >= (1<<16) || len(v) >= (1<<16) {
|
||||||
// Too big key or value - its length cannot be encoded
|
// Too big key or value - its length cannot be encoded
|
||||||
// with 2 bytes (see below). Skip the entry.
|
// with 2 bytes (see below). Skip the entry.
|
||||||
|
@ -326,13 +322,15 @@ func (b *bucket) Set(k, v []byte, h uint64) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chunks := b.chunks
|
||||||
|
needClean := false
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
idx := b.idx
|
idx := b.idx
|
||||||
idxNew := idx + kvLen
|
idxNew := idx + kvLen
|
||||||
chunkIdx := idx / chunkSize
|
chunkIdx := idx / chunkSize
|
||||||
chunkIdxNew := idxNew / chunkSize
|
chunkIdxNew := idxNew / chunkSize
|
||||||
if chunkIdxNew > chunkIdx {
|
if chunkIdxNew > chunkIdx {
|
||||||
if chunkIdxNew >= uint64(len(b.chunks)) {
|
if chunkIdxNew >= uint64(len(chunks)) {
|
||||||
idx = 0
|
idx = 0
|
||||||
idxNew = kvLen
|
idxNew = kvLen
|
||||||
chunkIdx = 0
|
chunkIdx = 0
|
||||||
|
@ -340,14 +338,15 @@ func (b *bucket) Set(k, v []byte, h uint64) {
|
||||||
if b.gen&((1<<genSizeBits)-1) == 0 {
|
if b.gen&((1<<genSizeBits)-1) == 0 {
|
||||||
b.gen++
|
b.gen++
|
||||||
}
|
}
|
||||||
|
needClean = true
|
||||||
} else {
|
} else {
|
||||||
idx = chunkIdxNew * chunkSize
|
idx = chunkIdxNew * chunkSize
|
||||||
idxNew = idx + kvLen
|
idxNew = idx + kvLen
|
||||||
chunkIdx = chunkIdxNew
|
chunkIdx = chunkIdxNew
|
||||||
}
|
}
|
||||||
b.chunks[chunkIdx] = b.chunks[chunkIdx][:0]
|
chunks[chunkIdx] = chunks[chunkIdx][:0]
|
||||||
}
|
}
|
||||||
chunk := b.chunks[chunkIdx]
|
chunk := chunks[chunkIdx]
|
||||||
if chunk == nil {
|
if chunk == nil {
|
||||||
chunk = getChunk()
|
chunk = getChunk()
|
||||||
chunk = chunk[:0]
|
chunk = chunk[:0]
|
||||||
|
@ -355,15 +354,19 @@ func (b *bucket) Set(k, v []byte, h uint64) {
|
||||||
chunk = append(chunk, kvLenBuf[:]...)
|
chunk = append(chunk, kvLenBuf[:]...)
|
||||||
chunk = append(chunk, k...)
|
chunk = append(chunk, k...)
|
||||||
chunk = append(chunk, v...)
|
chunk = append(chunk, v...)
|
||||||
b.chunks[chunkIdx] = chunk
|
chunks[chunkIdx] = chunk
|
||||||
b.m[h] = idx | (b.gen << bucketSizeBits)
|
b.m[h] = idx | (b.gen << bucketSizeBits)
|
||||||
b.idx = idxNew
|
b.idx = idxNew
|
||||||
|
if needClean {
|
||||||
|
b.cleanLocked()
|
||||||
|
}
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bucket) Get(dst, k []byte, h uint64, returnDst bool) ([]byte, bool) {
|
func (b *bucket) Get(dst, k []byte, h uint64, returnDst bool) ([]byte, bool) {
|
||||||
atomic.AddUint64(&b.getCalls, 1)
|
atomic.AddUint64(&b.getCalls, 1)
|
||||||
found := false
|
found := false
|
||||||
|
chunks := b.chunks
|
||||||
b.mu.RLock()
|
b.mu.RLock()
|
||||||
v := b.m[h]
|
v := b.m[h]
|
||||||
bGen := b.gen & ((1 << genSizeBits) - 1)
|
bGen := b.gen & ((1 << genSizeBits) - 1)
|
||||||
|
@ -372,12 +375,12 @@ func (b *bucket) Get(dst, k []byte, h uint64, returnDst bool) ([]byte, bool) {
|
||||||
idx := v & ((1 << bucketSizeBits) - 1)
|
idx := v & ((1 << bucketSizeBits) - 1)
|
||||||
if gen == bGen && idx < b.idx || gen+1 == bGen && idx >= b.idx || gen == maxGen && bGen == 1 && idx >= b.idx {
|
if gen == bGen && idx < b.idx || gen+1 == bGen && idx >= b.idx || gen == maxGen && bGen == 1 && idx >= b.idx {
|
||||||
chunkIdx := idx / chunkSize
|
chunkIdx := idx / chunkSize
|
||||||
if chunkIdx >= uint64(len(b.chunks)) {
|
if chunkIdx >= uint64(len(chunks)) {
|
||||||
// Corrupted data during the load from file. Just skip it.
|
// Corrupted data during the load from file. Just skip it.
|
||||||
atomic.AddUint64(&b.corruptions, 1)
|
atomic.AddUint64(&b.corruptions, 1)
|
||||||
goto end
|
goto end
|
||||||
}
|
}
|
||||||
chunk := b.chunks[chunkIdx]
|
chunk := chunks[chunkIdx]
|
||||||
idx %= chunkSize
|
idx %= chunkSize
|
||||||
if idx+4 >= chunkSize {
|
if idx+4 >= chunkSize {
|
||||||
// Corrupted data during the load from file. Just skip it.
|
// Corrupted data during the load from file. Just skip it.
|
||||||
|
|
4
vendor/github.com/VictoriaMetrics/fastcache/file.go
generated
vendored
4
vendor/github.com/VictoriaMetrics/fastcache/file.go
generated
vendored
|
@ -272,7 +272,9 @@ func loadBuckets(buckets []bucket, dataPath string, maxChunks uint64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bucket) Save(w io.Writer) error {
|
func (b *bucket) Save(w io.Writer) error {
|
||||||
b.Clean()
|
b.mu.Lock()
|
||||||
|
b.cleanLocked()
|
||||||
|
b.mu.Unlock()
|
||||||
|
|
||||||
b.mu.RLock()
|
b.mu.RLock()
|
||||||
defer b.mu.RUnlock()
|
defer b.mu.RUnlock()
|
||||||
|
|
1
vendor/github.com/VictoriaMetrics/fastcache/malloc_heap.go
generated
vendored
1
vendor/github.com/VictoriaMetrics/fastcache/malloc_heap.go
generated
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build appengine || windows
|
||||||
// +build appengine windows
|
// +build appengine windows
|
||||||
|
|
||||||
package fastcache
|
package fastcache
|
||||||
|
|
1
vendor/github.com/VictoriaMetrics/fastcache/malloc_mmap.go
generated
vendored
1
vendor/github.com/VictoriaMetrics/fastcache/malloc_mmap.go
generated
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !appengine && !windows
|
||||||
// +build !appengine,!windows
|
// +build !appengine,!windows
|
||||||
|
|
||||||
package fastcache
|
package fastcache
|
||||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -15,7 +15,7 @@ cloud.google.com/go/iam
|
||||||
## explicit; go 1.11
|
## explicit; go 1.11
|
||||||
cloud.google.com/go/storage
|
cloud.google.com/go/storage
|
||||||
cloud.google.com/go/storage/internal/apiv2
|
cloud.google.com/go/storage/internal/apiv2
|
||||||
# github.com/VictoriaMetrics/fastcache v1.8.0
|
# github.com/VictoriaMetrics/fastcache v1.9.0
|
||||||
## explicit; go 1.13
|
## explicit; go 1.13
|
||||||
github.com/VictoriaMetrics/fastcache
|
github.com/VictoriaMetrics/fastcache
|
||||||
# github.com/VictoriaMetrics/fasthttp v1.1.0
|
# github.com/VictoriaMetrics/fasthttp v1.1.0
|
||||||
|
|
Loading…
Reference in a new issue