Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate blocks-storage.bucket-store.chunks-cache.subrange-size flag #4135

Merged
merged 2 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [CHANGE] Querier: returning 422 when query hits `max_fetched_chunks_per_query` and `max_fetched_series_per_query` limits in the store-gateway. #4056
* [CHANGE] Packaging: Migrate FPM packaging solution to NFPM. Rationalize packages dependencies and add package for all binaries. #3911
* [CHANGE] Store-gateway: Deprecate flag `-blocks-storage.bucket-store.chunks-cache.subrange-size` since there's no benefit to changing the default of `16000`. #4135
* [FEATURE] Ruler: added `keep_firing_for` support to alerting rules. #4099
* [ENHANCEMENT] Compactor: Add `reason` label to `cortex_compactor_runs_failed_total`. The value can be `shutdown` or `error`. #4012
* [ENHANCEMENT] Store-gateway: enforce `max_fetched_series_per_query`. #4056
Expand Down
11 changes: 0 additions & 11 deletions cmd/mimir/config-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -5268,17 +5268,6 @@
"fieldValue": null,
"fieldDefaultValue": null
},
{
"kind": "field",
"name": "subrange_size",
"required": false,
"desc": "Size of each subrange that bucket object is split into for better caching.",
"fieldValue": null,
"fieldDefaultValue": 16000,
"fieldFlag": "blocks-storage.bucket-store.chunks-cache.subrange-size",
"fieldType": "int",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "max_get_range_requests",
Expand Down
2 changes: 0 additions & 2 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ Usage of ./cmd/mimir/mimir:
The maximum size of an item stored in memcached. Bigger items are not stored. If set to 0, no maximum size is enforced. (default 1048576)
-blocks-storage.bucket-store.chunks-cache.memcached.timeout duration
The socket read/write timeout. (default 200ms)
-blocks-storage.bucket-store.chunks-cache.subrange-size int
Size of each subrange that bucket object is split into for better caching. (default 16000)
-blocks-storage.bucket-store.chunks-cache.subrange-ttl duration
TTL for caching individual chunks subranges. (default 24h0m0s)
-blocks-storage.bucket-store.consistency-delay duration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2969,11 +2969,6 @@ bucket_store:
# blocks-storage.bucket-store.chunks-cache
[memcached: <memcached>]

# (advanced) Size of each subrange that bucket object is split into for
# better caching.
# CLI flag: -blocks-storage.bucket-store.chunks-cache.subrange-size
[subrange_size: <int> | default = 16000]

# (advanced) Maximum number of sub-GetRange requests that a single GetRange
# request can be split into when fetching chunks. Zero or negative value =
# unlimited number of sub-requests.
Expand Down
12 changes: 8 additions & 4 deletions pkg/storage/tsdb/caching_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/go-kit/log"
"github.com/golang/snappy"
"github.com/grafana/dskit/cache"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/tenant"
"github.com/grafana/regexp"
"github.com/oklog/ulid"
Expand All @@ -27,22 +28,25 @@ import (
"github.com/grafana/mimir/pkg/storage/tsdb/metadata"
)

// subrangeSize is the size of each subrange that bucket objects are split into for better caching
const subrangeSize int64 = 16000

type ChunksCacheConfig struct {
cache.BackendConfig `yaml:",inline"`

SubrangeSize int64 `yaml:"subrange_size" category:"advanced"`
MaxGetRangeRequests int `yaml:"max_get_range_requests" category:"advanced"`
AttributesTTL time.Duration `yaml:"attributes_ttl" category:"advanced"`
AttributesInMemoryMaxItems int `yaml:"attributes_in_memory_max_items" category:"advanced"`
SubrangeTTL time.Duration `yaml:"subrange_ttl" category:"advanced"`
}

func (cfg *ChunksCacheConfig) RegisterFlagsWithPrefix(f *flag.FlagSet, prefix string) {
func (cfg *ChunksCacheConfig) RegisterFlagsWithPrefix(f *flag.FlagSet, prefix string, logger log.Logger) {
f.StringVar(&cfg.Backend, prefix+"backend", "", fmt.Sprintf("Backend for chunks cache, if not empty. Supported values: %s.", cache.BackendMemcached))

cfg.Memcached.RegisterFlagsWithPrefix(f, prefix+"memcached.")

f.Int64Var(&cfg.SubrangeSize, prefix+"subrange-size", 16000, "Size of each subrange that bucket object is split into for better caching.")
// TODO: Deprecated in Mimir 2.7, remove in Mimir 2.9
flagext.DeprecatedFlag(f, prefix+"subrange-size", fmt.Sprintf("Deprecated, %d bytes is now always used. Size of each subrange that bucket object is split into for better caching.", subrangeSize), logger)
f.IntVar(&cfg.MaxGetRangeRequests, prefix+"max-get-range-requests", 3, "Maximum number of sub-GetRange requests that a single GetRange request can be split into when fetching chunks. Zero or negative value = unlimited number of sub-requests.")
f.DurationVar(&cfg.AttributesTTL, prefix+"attributes-ttl", 168*time.Hour, "TTL for caching object attributes for chunks. If the metadata cache is configured, attributes will be stored under this cache backend, otherwise attributes are stored in the chunks cache backend.")
f.IntVar(&cfg.AttributesInMemoryMaxItems, prefix+"attributes-in-memory-max-items", 50000, "Maximum number of object attribute items to keep in a first level in-memory LRU cache. Metadata will be stored and fetched in-memory before hitting the cache backend. 0 to disable the in-memory cache.")
Expand Down Expand Up @@ -138,7 +142,7 @@ func CreateCachingBucket(chunksConfig ChunksCacheConfig, metadataConfig Metadata
}
}

cfg.CacheGetRange("chunks", chunksCache, isTSDBChunkFile, chunksConfig.SubrangeSize, attributesCache, chunksConfig.AttributesTTL, chunksConfig.SubrangeTTL, chunksConfig.MaxGetRangeRequests)
cfg.CacheGetRange("chunks", chunksCache, isTSDBChunkFile, subrangeSize, attributesCache, chunksConfig.AttributesTTL, chunksConfig.SubrangeTTL, chunksConfig.MaxGetRangeRequests)
}

if !cachingConfigured {
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/tsdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (d *DurationList) ToMilliseconds() []int64 {
// RegisterFlags registers the TSDB flags
func (cfg *BlocksStorageConfig) RegisterFlags(f *flag.FlagSet, logger log.Logger) {
cfg.Bucket.RegisterFlagsWithPrefixAndDefaultDirectory("blocks-storage.", "blocks", f, logger)
cfg.BucketStore.RegisterFlags(f)
cfg.BucketStore.RegisterFlags(f, logger)
cfg.TSDB.RegisterFlags(f)
cfg.EphemeralTSDB.RegisterFlags(f)
}
Expand Down Expand Up @@ -324,9 +324,9 @@ type BucketStoreConfig struct {
}

// RegisterFlags registers the BucketStore flags
func (cfg *BucketStoreConfig) RegisterFlags(f *flag.FlagSet) {
func (cfg *BucketStoreConfig) RegisterFlags(f *flag.FlagSet, logger log.Logger) {
cfg.IndexCache.RegisterFlagsWithPrefix(f, "blocks-storage.bucket-store.index-cache.")
cfg.ChunksCache.RegisterFlagsWithPrefix(f, "blocks-storage.bucket-store.chunks-cache.")
cfg.ChunksCache.RegisterFlagsWithPrefix(f, "blocks-storage.bucket-store.chunks-cache.", logger)
cfg.MetadataCache.RegisterFlagsWithPrefix(f, "blocks-storage.bucket-store.metadata-cache.")
cfg.BucketIndex.RegisterFlagsWithPrefix(f, "blocks-storage.bucket-store.bucket-index.")
cfg.IndexHeader.RegisterFlagsWithPrefix(f, "blocks-storage.bucket-store.index-header.")
Expand Down