Skip to content

Commit 70ff599

Browse files
committed
fix: Improve docs for min and max table offsets (#14890)
Co-authored-by: Christian Haudum <[email protected]> (cherry picked from commit fd9d332)
1 parent 31b2a63 commit 70ff599

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

docs/sources/shared/configuration.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -1263,19 +1263,20 @@ planner:
12631263
# CLI flag: -bloom-build.planner.interval
12641264
[planning_interval: <duration> | default = 8h]
12651265
1266-
# Newest day-table offset (from today, inclusive) to build blooms for.
1267-
# Increase to lower cost by not re-writing data to object storage too
1268-
# frequently since recent data changes more often at the cost of not having
1269-
# blooms available as quickly.
1266+
# Newest day-table offset (from today, inclusive) to build blooms for. 0 start
1267+
# building from today, 1 from yesterday and so on. Increase to lower cost by
1268+
# not re-writing data to object storage too frequently since recent data
1269+
# changes more often at the cost of not having blooms available as quickly.
12701270
# CLI flag: -bloom-build.planner.min-table-offset
1271-
[min_table_offset: <int> | default = 1]
1271+
[min_table_offset: <int> | default = 0]
12721272
1273-
# Oldest day-table offset (from today, inclusive) to compact. This can be used
1274-
# to lower cost by not trying to compact older data which doesn't change. This
1273+
# Oldest day-table offset (from today, inclusive) to build blooms for. 1 till
1274+
# yesterday, 2 till day before yesterday and so on. This can be used to lower
1275+
# cost by not trying to build blooms for older data which doesn't change. This
12751276
# can be optimized by aligning it with the maximum
12761277
# `reject_old_samples_max_age` setting of any tenant.
12771278
# CLI flag: -bloom-build.planner.max-table-offset
1278-
[max_table_offset: <int> | default = 2]
1279+
[max_table_offset: <int> | default = 1]
12791280

12801281
# Maximum number of tasks to queue per tenant.
12811282
# CLI flag: -bloom-build.planner.max-tasks-per-tenant

pkg/bloombuild/planner/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ type Config struct {
2020
// RegisterFlagsWithPrefix registers flags for the bloom-planner configuration.
2121
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
2222
f.DurationVar(&cfg.PlanningInterval, prefix+".interval", 8*time.Hour, "Interval at which to re-run the bloom creation planning.")
23-
f.IntVar(&cfg.MinTableOffset, prefix+".min-table-offset", 1, "Newest day-table offset (from today, inclusive) to build blooms for. Increase to lower cost by not re-writing data to object storage too frequently since recent data changes more often at the cost of not having blooms available as quickly.")
23+
f.IntVar(&cfg.MinTableOffset, prefix+".min-table-offset", 0, "Newest day-table offset (from today, inclusive) to build blooms for. 0 start building from today, 1 from yesterday and so on. Increase to lower cost by not re-writing data to object storage too frequently since recent data changes more often at the cost of not having blooms available as quickly.")
2424
// TODO(owen-d): ideally we'd set this per tenant based on their `reject_old_samples_max_age` setting,
2525
// but due to how we need to discover tenants, we can't do that yet. Tenant+Period discovery is done by
2626
// iterating the table periods in object storage and looking for tenants within that period.
2727
// In order to have this done dynamically, we'd need to account for tenant specific overrides, which are also
2828
// dynamically reloaded.
2929
// I'm doing it the simple way for now.
30-
f.IntVar(&cfg.MaxTableOffset, prefix+".max-table-offset", 2, "Oldest day-table offset (from today, inclusive) to compact. This can be used to lower cost by not trying to compact older data which doesn't change. This can be optimized by aligning it with the maximum `reject_old_samples_max_age` setting of any tenant.")
30+
f.IntVar(&cfg.MaxTableOffset, prefix+".max-table-offset", 1, "Oldest day-table offset (from today, inclusive) to build blooms for. 1 till yesterday, 2 till day before yesterday and so on. This can be used to lower cost by not trying to build blooms for older data which doesn't change. This can be optimized by aligning it with the maximum `reject_old_samples_max_age` setting of any tenant.")
3131
f.IntVar(&cfg.MaxQueuedTasksPerTenant, prefix+".max-tasks-per-tenant", 30000, "Maximum number of tasks to queue per tenant.")
3232
cfg.RetentionConfig.RegisterFlagsWithPrefix(prefix+".retention", f)
3333
}

pkg/bloombuild/planner/planner_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/grafana/loki/v3/pkg/bloombuild/planner/plannertest"
2121
"github.com/grafana/loki/v3/pkg/bloombuild/planner/strategies"
2222
"github.com/grafana/loki/v3/pkg/bloombuild/protos"
23+
iter "github.com/grafana/loki/v3/pkg/iter/v2"
2324
"github.com/grafana/loki/v3/pkg/storage"
2425
v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1"
2526
"github.com/grafana/loki/v3/pkg/storage/chunk/cache"
@@ -598,6 +599,36 @@ func Test_deleteOutdatedMetas(t *testing.T) {
598599
}
599600
}
600601

602+
func TestMinMaxTables(t *testing.T) {
603+
logger := log.NewNopLogger()
604+
//logger := log.NewLogfmtLogger(os.Stdout)
605+
606+
cfg := Config{
607+
PlanningInterval: 1 * time.Hour,
608+
Queue: queue.Config{
609+
MaxQueuedTasksPerTenant: 10000,
610+
},
611+
// From today till day before tomorrow
612+
MinTableOffset: 0,
613+
MaxTableOffset: 2,
614+
}
615+
planner := createPlanner(t, cfg, &fakeLimits{}, logger)
616+
617+
tables := planner.tables(time.Now())
618+
require.Equal(t, 3, tables.TotalDays())
619+
620+
dayTables, err := iter.Collect(tables)
621+
require.NoError(t, err)
622+
623+
todayTable := config.NewDayTable(config.NewDayTime(model.Now()), "index_")
624+
yesterdayTable := config.NewDayTable(config.NewDayTime(model.Now().Add(-24*time.Hour)), "index_")
625+
dayBeforeYesterdayTable := config.NewDayTable(config.NewDayTime(model.Now().Add(-48*time.Hour)), "index_")
626+
627+
require.Equal(t, dayBeforeYesterdayTable.Addr(), dayTables[0].Addr())
628+
require.Equal(t, yesterdayTable.Addr(), dayTables[1].Addr())
629+
require.Equal(t, todayTable.Addr(), dayTables[2].Addr())
630+
}
631+
601632
type fakeBuilder struct {
602633
mx sync.Mutex // Protects tasks and currTaskIdx.
603634
id string

0 commit comments

Comments
 (0)