mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/uint64set: optimize Set.Has() for nil Set - it should be inlined now
This makes unnecessary the checkDeleted variable at lib/storage/index_db.go
This is a follow-up for b984f4672e
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/6342
This commit is contained in:
parent
832e088659
commit
784327ea30
2 changed files with 11 additions and 12 deletions
|
@ -656,7 +656,7 @@ func (is *indexSearch) searchLabelNamesWithFiltersOnDate(qt *querytracer.Tracer,
|
|||
if filter != nil && filter.Len() <= 100e3 {
|
||||
// It is faster to obtain label names by metricIDs from the filter
|
||||
// instead of scanning the inverted index for the matching filters.
|
||||
// This would help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
||||
// This should help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
||||
metricIDs := filter.AppendTo(nil)
|
||||
qt.Printf("sort %d metricIDs", len(metricIDs))
|
||||
is.getLabelNamesForMetricIDs(qt, metricIDs, lns, maxLabelNames)
|
||||
|
@ -749,13 +749,12 @@ func (is *indexSearch) getLabelNamesForMetricIDs(qt *querytracer.Tracer, metricI
|
|||
}
|
||||
|
||||
dmis := is.db.s.getDeletedMetricIDs()
|
||||
checkDeleted := dmis.Len() > 0
|
||||
|
||||
var mn MetricName
|
||||
foundLabelNames := 0
|
||||
var buf []byte
|
||||
for _, metricID := range metricIDs {
|
||||
if checkDeleted && dmis.Has(metricID) {
|
||||
if dmis.Has(metricID) {
|
||||
// skip deleted IDs from result
|
||||
continue
|
||||
}
|
||||
|
@ -882,7 +881,7 @@ func (is *indexSearch) searchLabelValuesWithFiltersOnDate(qt *querytracer.Tracer
|
|||
if filter != nil && filter.Len() <= 100e3 {
|
||||
// It is faster to obtain label values by metricIDs from the filter
|
||||
// instead of scanning the inverted index for the matching filters.
|
||||
// This would help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
||||
// This should help https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2978
|
||||
metricIDs := filter.AppendTo(nil)
|
||||
qt.Printf("sort %d metricIDs", len(metricIDs))
|
||||
is.getLabelValuesForMetricIDs(qt, lvs, labelName, metricIDs, maxLabelValues)
|
||||
|
@ -956,13 +955,12 @@ func (is *indexSearch) getLabelValuesForMetricIDs(qt *querytracer.Tracer, lvs ma
|
|||
}
|
||||
|
||||
dmis := is.db.s.getDeletedMetricIDs()
|
||||
checkDeleted := dmis.Len() > 0
|
||||
|
||||
var mn MetricName
|
||||
foundLabelValues := 0
|
||||
var buf []byte
|
||||
for _, metricID := range metricIDs {
|
||||
if checkDeleted && dmis.Has(metricID) {
|
||||
if dmis.Has(metricID) {
|
||||
// skip deleted IDs from result
|
||||
continue
|
||||
}
|
||||
|
@ -1858,12 +1856,9 @@ func (is *indexSearch) getTSIDByMetricNameNoExtDB(dst *TSID, metricName []byte,
|
|||
if len(tail) > 0 {
|
||||
logger.Panicf("FATAL: unexpected non-empty tail left after unmarshaling TSID: %X", tail)
|
||||
}
|
||||
if dmis.Len() > 0 {
|
||||
// Verify whether the dst is marked as deleted.
|
||||
if dmis.Has(dst.MetricID) {
|
||||
// The dst is deleted. Continue searching.
|
||||
continue
|
||||
}
|
||||
if dmis.Has(dst.MetricID) {
|
||||
// The dst is deleted. Continue searching.
|
||||
continue
|
||||
}
|
||||
// Found valid dst.
|
||||
return true
|
||||
|
|
|
@ -183,6 +183,10 @@ func (s *Set) Has(x uint64) bool {
|
|||
if s == nil {
|
||||
return false
|
||||
}
|
||||
return s.hasSlow(x)
|
||||
}
|
||||
|
||||
func (s *Set) hasSlow(x uint64) bool {
|
||||
hi32 := uint32(x >> 32)
|
||||
lo32 := uint32(x)
|
||||
bs := s.buckets
|
||||
|
|
Loading…
Reference in a new issue