From 2c1f79a8b461c324cf331cf3ae641208b2737274 Mon Sep 17 00:00:00 2001 From: Ben Ye Date: Wed, 20 Sep 2023 17:02:52 -0700 Subject: [PATCH] always lookup name symbol first Signed-off-by: Ben Ye --- pkg/block/indexheader/binary_reader.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/block/indexheader/binary_reader.go b/pkg/block/indexheader/binary_reader.go index 16ef73ac3b0..39a40fb2ad9 100644 --- a/pkg/block/indexheader/binary_reader.go +++ b/pkg/block/indexheader/binary_reader.go @@ -925,15 +925,6 @@ func (r *BinaryReader) postingsOffset(name string, values ...string) ([]index.Ra } func (r *BinaryReader) LookupSymbol(o uint32) (string, error) { - cacheIndex := o % valueSymbolsCacheSize - r.valueSymbolsMx.Lock() - if cached := r.valueSymbols[cacheIndex]; cached.index == o && cached.symbol != "" { - v := cached.symbol - r.valueSymbolsMx.Unlock() - return v, nil - } - r.valueSymbolsMx.Unlock() - if s, ok := r.nameSymbols[o]; ok { return s, nil } @@ -944,6 +935,15 @@ func (r *BinaryReader) LookupSymbol(o uint32) (string, error) { o += headerLen - index.HeaderLen } + cacheIndex := o % valueSymbolsCacheSize + r.valueSymbolsMx.Lock() + if cached := r.valueSymbols[cacheIndex]; cached.index == o && cached.symbol != "" { + v := cached.symbol + r.valueSymbolsMx.Unlock() + return v, nil + } + r.valueSymbolsMx.Unlock() + s, err := r.symbols.Lookup(o) if err != nil { return s, err