mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
59b7bef051
commit
a941bdcdbd
1 changed files with 22 additions and 19 deletions
|
@ -296,19 +296,11 @@ 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 {
|
||||||
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)]
|
spg := shard.m[string(key)]
|
||||||
if spg == nil {
|
if spg == nil {
|
||||||
sfps := make([]statsFuncProcessor, len(shard.funcs))
|
sfps := make([]statsFuncProcessor, len(shard.funcs))
|
||||||
|
@ -323,9 +315,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,8 +355,22 @@ func (spp *statsPipeProcessor) writeBlock(workerID uint, timestamps []int64, col
|
||||||
columnIdxs := shard.columnIdxs
|
columnIdxs := shard.columnIdxs
|
||||||
|
|
||||||
keyBuf := shard.keyBuf
|
keyBuf := shard.keyBuf
|
||||||
|
var spg *statsPipeGroup
|
||||||
for i := range timestamps {
|
for i := range timestamps {
|
||||||
// Construct key for the by (...) fields
|
// verify whether the key for 'by (...)' fields equals the previous key
|
||||||
|
sameValue := spg != nil
|
||||||
|
for _, idx := range columnIdxs {
|
||||||
|
if idx < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
values := columns[idx].Values
|
||||||
|
if i <= 0 || values[i-1] != values[i] {
|
||||||
|
sameValue = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !sameValue {
|
||||||
|
// Construct new key for the 'by (...)' fields
|
||||||
keyBuf = keyBuf[:0]
|
keyBuf = keyBuf[:0]
|
||||||
for _, idx := range columnIdxs {
|
for _, idx := range columnIdxs {
|
||||||
v := ""
|
v := ""
|
||||||
|
@ -376,8 +379,8 @@ func (spp *statsPipeProcessor) writeBlock(workerID uint, timestamps []int64, col
|
||||||
}
|
}
|
||||||
keyBuf = encoding.MarshalBytes(keyBuf, bytesutil.ToUnsafeBytes(v))
|
keyBuf = encoding.MarshalBytes(keyBuf, bytesutil.ToUnsafeBytes(v))
|
||||||
}
|
}
|
||||||
|
spg = shard.getStatsPipeGroup(keyBuf)
|
||||||
spg := shard.getStatsPipeGroup(keyBuf)
|
}
|
||||||
for _, sfp := range spg.sfps {
|
for _, sfp := range spg.sfps {
|
||||||
shard.stateSizeBudget -= sfp.updateStatsForRow(timestamps, columns, i)
|
shard.stateSizeBudget -= sfp.updateStatsForRow(timestamps, columns, i)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue