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 {
|
if filter != nil && filter.Len() <= 100e3 {
|
||||||
// It is faster to obtain label names by metricIDs from the filter
|
// It is faster to obtain label names by metricIDs from the filter
|
||||||
// instead of scanning the inverted index for the matching filters.
|
// 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)
|
metricIDs := filter.AppendTo(nil)
|
||||||
qt.Printf("sort %d metricIDs", len(metricIDs))
|
qt.Printf("sort %d metricIDs", len(metricIDs))
|
||||||
is.getLabelNamesForMetricIDs(qt, metricIDs, lns, maxLabelNames)
|
is.getLabelNamesForMetricIDs(qt, metricIDs, lns, maxLabelNames)
|
||||||
|
@ -749,13 +749,12 @@ func (is *indexSearch) getLabelNamesForMetricIDs(qt *querytracer.Tracer, metricI
|
||||||
}
|
}
|
||||||
|
|
||||||
dmis := is.db.s.getDeletedMetricIDs()
|
dmis := is.db.s.getDeletedMetricIDs()
|
||||||
checkDeleted := dmis.Len() > 0
|
|
||||||
|
|
||||||
var mn MetricName
|
var mn MetricName
|
||||||
foundLabelNames := 0
|
foundLabelNames := 0
|
||||||
var buf []byte
|
var buf []byte
|
||||||
for _, metricID := range metricIDs {
|
for _, metricID := range metricIDs {
|
||||||
if checkDeleted && dmis.Has(metricID) {
|
if dmis.Has(metricID) {
|
||||||
// skip deleted IDs from result
|
// skip deleted IDs from result
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -882,7 +881,7 @@ func (is *indexSearch) searchLabelValuesWithFiltersOnDate(qt *querytracer.Tracer
|
||||||
if filter != nil && filter.Len() <= 100e3 {
|
if filter != nil && filter.Len() <= 100e3 {
|
||||||
// It is faster to obtain label values by metricIDs from the filter
|
// It is faster to obtain label values by metricIDs from the filter
|
||||||
// instead of scanning the inverted index for the matching filters.
|
// 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)
|
metricIDs := filter.AppendTo(nil)
|
||||||
qt.Printf("sort %d metricIDs", len(metricIDs))
|
qt.Printf("sort %d metricIDs", len(metricIDs))
|
||||||
is.getLabelValuesForMetricIDs(qt, lvs, labelName, metricIDs, maxLabelValues)
|
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()
|
dmis := is.db.s.getDeletedMetricIDs()
|
||||||
checkDeleted := dmis.Len() > 0
|
|
||||||
|
|
||||||
var mn MetricName
|
var mn MetricName
|
||||||
foundLabelValues := 0
|
foundLabelValues := 0
|
||||||
var buf []byte
|
var buf []byte
|
||||||
for _, metricID := range metricIDs {
|
for _, metricID := range metricIDs {
|
||||||
if checkDeleted && dmis.Has(metricID) {
|
if dmis.Has(metricID) {
|
||||||
// skip deleted IDs from result
|
// skip deleted IDs from result
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1858,12 +1856,9 @@ func (is *indexSearch) getTSIDByMetricNameNoExtDB(dst *TSID, metricName []byte,
|
||||||
if len(tail) > 0 {
|
if len(tail) > 0 {
|
||||||
logger.Panicf("FATAL: unexpected non-empty tail left after unmarshaling TSID: %X", tail)
|
logger.Panicf("FATAL: unexpected non-empty tail left after unmarshaling TSID: %X", tail)
|
||||||
}
|
}
|
||||||
if dmis.Len() > 0 {
|
if dmis.Has(dst.MetricID) {
|
||||||
// Verify whether the dst is marked as deleted.
|
// The dst is deleted. Continue searching.
|
||||||
if dmis.Has(dst.MetricID) {
|
continue
|
||||||
// The dst is deleted. Continue searching.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Found valid dst.
|
// Found valid dst.
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -183,6 +183,10 @@ func (s *Set) Has(x uint64) bool {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
return s.hasSlow(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Set) hasSlow(x uint64) bool {
|
||||||
hi32 := uint32(x >> 32)
|
hi32 := uint32(x >> 32)
|
||||||
lo32 := uint32(x)
|
lo32 := uint32(x)
|
||||||
bs := s.buckets
|
bs := s.buckets
|
||||||
|
|
Loading…
Reference in a new issue