Skip to content

Commit d1387fe

Browse files
authored
Create a noOpInterner in case string interning is disabled (#6705)
Signed-off-by: alanprot <[email protected]>
1 parent 8cc83a6 commit d1387fe

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: pkg/ingester/ingester.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2386,7 +2386,7 @@ func (i *Ingester) createTSDB(userID string) (*userTSDB, error) {
23862386

23872387
instanceLimitsFn: i.getInstanceLimits,
23882388
instanceSeriesCount: &i.TSDBState.seriesCount,
2389-
interner: util.NewLruInterner(),
2389+
interner: util.NewLruInterner(i.cfg.LabelsStringInterningEnabled),
23902390
labelsStringInterningEnabled: i.cfg.LabelsStringInterningEnabled,
23912391

23922392
blockRetentionPeriod: i.cfg.BlocksStorageConfig.TSDB.Retention.Milliseconds(),

Diff for: pkg/util/strings.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,21 @@ type Interner interface {
157157

158158
// NewLruInterner returns a new Interner to be used to intern strings.
159159
// The interner will use a LRU cache to return the deduplicated strings
160-
func NewLruInterner() Interner {
160+
func NewLruInterner(enabled bool) Interner {
161+
if !enabled {
162+
return &noOpInterner{}
163+
}
161164
return &pool{
162165
lru: expirable.NewLRU[string, string](maxInternerLruCacheSize, nil, internerLruCacheTTL),
163166
}
164167
}
165168

169+
type noOpInterner struct{}
170+
171+
func (n noOpInterner) Intern(s string) string {
172+
return s
173+
}
174+
166175
type pool struct {
167176
lru *expirable.LRU[string, string]
168177
}

0 commit comments

Comments
 (0)