Skip to content

Commit b144eba

Browse files
authored
receive: port expanded postings cache from Cortex (#7914)
Port expanded postings cache from Cortex. Huge kudos to @alanprot for the implementation. I added a TODO item to convert our whole internal caching infra to be promise based. Signed-off-by: Giedrius Statkevičius <[email protected]>
1 parent fd06432 commit b144eba

File tree

9 files changed

+819
-22
lines changed

9 files changed

+819
-22
lines changed

cmd/thanos/receive.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ func runReceive(
141141

142142
level.Info(logger).Log("mode", receiveMode, "msg", "running receive")
143143

144-
multiTSDBOptions := []receive.MultiTSDBOption{}
144+
multiTSDBOptions := []receive.MultiTSDBOption{
145+
receive.WithHeadExpandedPostingsCacheSize(conf.headExpandedPostingsCacheSize),
146+
receive.WithBlockExpandedPostingsCacheSize(conf.compactedBlocksExpandedPostingsCacheSize),
147+
}
145148
for _, feature := range *conf.featureList {
146149
if feature == metricNamesFilter {
147150
multiTSDBOptions = append(multiTSDBOptions, receive.WithMetricNameFilterEnabled())
@@ -886,6 +889,9 @@ type receiveConfig struct {
886889
asyncForwardWorkerCount uint
887890

888891
featureList *[]string
892+
893+
headExpandedPostingsCacheSize uint64
894+
compactedBlocksExpandedPostingsCacheSize uint64
889895
}
890896

891897
func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
@@ -996,6 +1002,9 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
9961002

9971003
cmd.Flag("tsdb.no-lockfile", "Do not create lockfile in TSDB data directory. In any case, the lockfiles will be deleted on next startup.").Default("false").BoolVar(&rc.noLockFile)
9981004

1005+
cmd.Flag("tsdb.head.expanded-postings-cache-size", "[EXPERIMENTAL] If non-zero, enables expanded postings cache for the head block.").Default("0").Uint64Var(&rc.headExpandedPostingsCacheSize)
1006+
cmd.Flag("tsdb.block.expanded-postings-cache-size", "[EXPERIMENTAL] If non-zero, enables expanded postings cache for compacted blocks.").Default("0").Uint64Var(&rc.compactedBlocksExpandedPostingsCacheSize)
1007+
9991008
cmd.Flag("tsdb.max-exemplars",
10001009
"Enables support for ingesting exemplars and sets the maximum number of exemplars that will be stored per tenant."+
10011010
" In case the exemplar storage becomes full (number of stored exemplars becomes equal to max-exemplars),"+

docs/components/receive.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,12 @@ Flags:
552552
Allow overlapping blocks, which in turn enables
553553
vertical compaction and vertical query merge.
554554
Does not do anything, enabled all the time.
555+
--tsdb.block.expanded-postings-cache-size=0
556+
[EXPERIMENTAL] If non-zero, enables expanded
557+
postings cache for compacted blocks.
558+
--tsdb.head.expanded-postings-cache-size=0
559+
[EXPERIMENTAL] If non-zero, enables expanded
560+
postings cache for the head block.
555561
--tsdb.max-exemplars=0 Enables support for ingesting exemplars and
556562
sets the maximum number of exemplars that will
557563
be stored per tenant. In case the exemplar

0 commit comments

Comments
 (0)