mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: optimize partSearch.searchBHS() for common case when the TSID for the current block header is bigger or equal to the current tsid
This should help improving performance at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3425
This commit is contained in:
parent
512c73cef9
commit
8c08d625ee
1 changed files with 10 additions and 8 deletions
|
@ -256,6 +256,7 @@ func (ps *partSearch) searchBHS() bool {
|
|||
for len(bhs) > 0 {
|
||||
// Skip block headers with tsids smaller than the given tsid.
|
||||
tsid := &ps.BlockRef.bh.TSID
|
||||
if bhs[0].TSID.Less(tsid) {
|
||||
n := sort.Search(len(bhs), func(i int) bool {
|
||||
return !bhs[i].TSID.Less(tsid)
|
||||
})
|
||||
|
@ -264,10 +265,11 @@ func (ps *partSearch) searchBHS() bool {
|
|||
break
|
||||
}
|
||||
bhs = bhs[n:]
|
||||
}
|
||||
bh := &bhs[0]
|
||||
|
||||
// Invariant: tsid <= bh.TSID
|
||||
|
||||
bh := &bhs[0]
|
||||
if bh.TSID.MetricID != tsid.MetricID {
|
||||
// tsid < bh.TSID: no more blocks with the given tsid.
|
||||
// Proceed to the next (bigger) tsid.
|
||||
|
|
Loading…
Reference in a new issue