mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 15:16:42 +00:00
wip
This commit is contained in:
parent
d724da794f
commit
59b7bef051
1 changed files with 23 additions and 13 deletions
|
@ -296,15 +296,21 @@ type statsPipeProcessorShardNopad struct {
|
||||||
|
|
||||||
columnIdxs []int
|
columnIdxs []int
|
||||||
keyBuf []byte
|
keyBuf []byte
|
||||||
|
keyBufPrev []byte
|
||||||
|
spgPrev *statsPipeGroup
|
||||||
|
|
||||||
stateSizeBudget int
|
stateSizeBudget int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (shard *statsPipeProcessorShard) getStatsPipeGroup(key []byte) *statsPipeGroup {
|
func (shard *statsPipeProcessorShard) getStatsPipeGroup(key []byte) *statsPipeGroup {
|
||||||
spg := shard.m[string(key)]
|
if shard.spgPrev != nil && string(shard.keyBufPrev) == string(key) {
|
||||||
if spg != nil {
|
// Fast path - return the spg for the same key.
|
||||||
return spg
|
return shard.spgPrev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Slow path - locate spg by key.
|
||||||
|
spg := shard.m[string(key)]
|
||||||
|
if spg == nil {
|
||||||
sfps := make([]statsFuncProcessor, len(shard.funcs))
|
sfps := make([]statsFuncProcessor, len(shard.funcs))
|
||||||
for i, f := range shard.funcs {
|
for i, f := range shard.funcs {
|
||||||
sfp, stateSize := f.newStatsFuncProcessor()
|
sfp, stateSize := f.newStatsFuncProcessor()
|
||||||
|
@ -316,6 +322,10 @@ func (shard *statsPipeProcessorShard) getStatsPipeGroup(key []byte) *statsPipeGr
|
||||||
}
|
}
|
||||||
shard.m[string(key)] = spg
|
shard.m[string(key)] = spg
|
||||||
shard.stateSizeBudget -= len(key) + int(unsafe.Sizeof("")+unsafe.Sizeof(spg)+unsafe.Sizeof(sfps[0])*uintptr(len(sfps)))
|
shard.stateSizeBudget -= len(key) + int(unsafe.Sizeof("")+unsafe.Sizeof(spg)+unsafe.Sizeof(sfps[0])*uintptr(len(sfps)))
|
||||||
|
}
|
||||||
|
|
||||||
|
shard.keyBufPrev = append(shard.keyBufPrev[:0], key...)
|
||||||
|
shard.spgPrev = spg
|
||||||
return spg
|
return spg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue