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,26 +296,36 @@ type statsPipeProcessorShardNopad struct {
|
|||
|
||||
columnIdxs []int
|
||||
keyBuf []byte
|
||||
keyBufPrev []byte
|
||||
spgPrev *statsPipeGroup
|
||||
|
||||
stateSizeBudget int
|
||||
}
|
||||
|
||||
func (shard *statsPipeProcessorShard) getStatsPipeGroup(key []byte) *statsPipeGroup {
|
||||
if shard.spgPrev != nil && string(shard.keyBufPrev) == string(key) {
|
||||
// Fast path - return the spg for the same key.
|
||||
return shard.spgPrev
|
||||
}
|
||||
|
||||
// Slow path - locate spg by key.
|
||||
spg := shard.m[string(key)]
|
||||
if spg != nil {
|
||||
return spg
|
||||
if spg == nil {
|
||||
sfps := make([]statsFuncProcessor, len(shard.funcs))
|
||||
for i, f := range shard.funcs {
|
||||
sfp, stateSize := f.newStatsFuncProcessor()
|
||||
sfps[i] = sfp
|
||||
shard.stateSizeBudget -= stateSize
|
||||
}
|
||||
spg = &statsPipeGroup{
|
||||
sfps: sfps,
|
||||
}
|
||||
shard.m[string(key)] = spg
|
||||
shard.stateSizeBudget -= len(key) + int(unsafe.Sizeof("")+unsafe.Sizeof(spg)+unsafe.Sizeof(sfps[0])*uintptr(len(sfps)))
|
||||
}
|
||||
sfps := make([]statsFuncProcessor, len(shard.funcs))
|
||||
for i, f := range shard.funcs {
|
||||
sfp, stateSize := f.newStatsFuncProcessor()
|
||||
sfps[i] = sfp
|
||||
shard.stateSizeBudget -= stateSize
|
||||
}
|
||||
spg = &statsPipeGroup{
|
||||
sfps: sfps,
|
||||
}
|
||||
shard.m[string(key)] = spg
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue