Skip to content

Commit

Permalink
don't cache == or !=
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchen-db committed Dec 12, 2024
1 parent b69d8f9 commit 615bd5b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/store/storepb/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ func NewMatcherConverter(cacheCapacity int, reg prometheus.Registerer) (*Matcher
func (c *MatcherConverter) MatchersToPromMatchers(ms ...LabelMatcher) ([]*labels.Matcher, error) {
res := make([]*labels.Matcher, 0, len(ms))
for _, m := range ms {
if m.Type == LabelMatcher_EQ || m.Type == LabelMatcher_NEQ {
// EQ and NEQ are very cheap, so we don't cache them.
pm, err := MatcherToPromMatcher(m)
if err != nil {
return nil, err
}
res = append(res, pm)
continue
}
if pm, ok := c.cache.Get(m); ok {
// cache hit
c.metrics.cacheHitCount.Inc()
Expand Down

0 comments on commit 615bd5b

Please sign in to comment.