Skip to content

Commit

Permalink
Log more info about symboltable rebuild.
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed Apr 8, 2024
1 parent f234c67 commit 065e8db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ func (i *Ingester) createTSDB(userID string, walReplayConcurrency int) (*userTSD
localSeriesLimit: initialLocalLimit,
},
}
userDB.resetSymbolTable()
userDB.resetSymbolTable(i.logger)
userDB.triggerRecomputeOwnedSeries(recomputeOwnedSeriesReasonNewUser)

oooTW := i.limits.OutOfOrderTimeWindow(userID)
Expand Down Expand Up @@ -3089,7 +3089,7 @@ func (i *Ingester) compactBlocks(ctx context.Context, force bool, forcedCompacti
default:
reason = "regular"
err = userDB.Compact()
userDB.resetSymbolTable()
userDB.resetSymbolTable(i.logger)
}

if err != nil {
Expand Down
12 changes: 11 additions & 1 deletion pkg/ingester/user_tsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"math"
"sync"
"time"
"unsafe"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
Expand Down Expand Up @@ -629,11 +630,20 @@ func (u *userTSDB) computeOwnedSeries() int {
return count
}

func (u *userTSDB) resetSymbolTable() {
type hackSymbolTable struct {
mx sync.Mutex
p unsafe.Pointer
nextNum int
}

func (u *userTSDB) resetSymbolTable(logger log.Logger) {
var st *labels.SymbolTable
if u.db != nil && u.db.Head() != nil {
level.Info(logger).Log("msg", "RebuildSymbolTable starting")
// Compact all labels in head into one SymbolTable.
st = u.Head().RebuildSymbolTable()
x := (*hackSymbolTable)(unsafe.Pointer(st))
level.Info(logger).Log("msg", "RebuildSymbolTable finished", "addr", fmt.Sprintf("%p: %v", x, x), "size", st.Len())
} else {
st = labels.NewSymbolTable()
}
Expand Down

0 comments on commit 065e8db

Please sign in to comment.