Skip to content

Commit fd9d332

Browse files
salvacortschaudum
andauthored
fix: Improve docs for min and max table offsets (#14890)
Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
1 parent 7dee08a commit fd9d332

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

‎docs/sources/shared/configuration.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,19 +1209,20 @@ planner:
12091209
# CLI flag: -bloom-build.planner.interval
12101210
[planning_interval: <duration> | default = 8h]
12111211
1212-
# Newest day-table offset (from today, inclusive) to build blooms for.
1213-
# Increase to lower cost by not re-writing data to object storage too
1214-
# frequently since recent data changes more often at the cost of not having
1215-
# blooms available as quickly.
1212+
# Newest day-table offset (from today, inclusive) to build blooms for. 0 start
1213+
# building from today, 1 from yesterday and so on. Increase to lower cost by
1214+
# not re-writing data to object storage too frequently since recent data
1215+
# changes more often at the cost of not having blooms available as quickly.
12161216
# CLI flag: -bloom-build.planner.min-table-offset
1217-
[min_table_offset: <int> | default = 1]
1217+
[min_table_offset: <int> | default = 0]
12181218
1219-
# Oldest day-table offset (from today, inclusive) to compact. This can be used
1220-
# to lower cost by not trying to compact older data which doesn't change. This
1219+
# Oldest day-table offset (from today, inclusive) to build blooms for. 1 till
1220+
# yesterday, 2 till day before yesterday and so on. This can be used to lower
1221+
# cost by not trying to build blooms for older data which doesn't change. This
12211222
# can be optimized by aligning it with the maximum
12221223
# `reject_old_samples_max_age` setting of any tenant.
12231224
# CLI flag: -bloom-build.planner.max-table-offset
1224-
[max_table_offset: <int> | default = 2]
1225+
[max_table_offset: <int> | default = 1]
12251226

12261227
retention:
12271228
# Enable bloom retention.

‎pkg/bloombuild/planner/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ type Config struct {
2121
// RegisterFlagsWithPrefix registers flags for the bloom-planner configuration.
2222
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
2323
f.DurationVar(&cfg.PlanningInterval, prefix+".interval", 8*time.Hour, "Interval at which to re-run the bloom creation planning.")
24-
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.")
24+
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.")
2525
// TODO(owen-d): ideally we'd set this per tenant based on their `reject_old_samples_max_age` setting,
2626
// but due to how we need to discover tenants, we can't do that yet. Tenant+Period discovery is done by
2727
// iterating the table periods in object storage and looking for tenants within that period.
2828
// In order to have this done dynamically, we'd need to account for tenant specific overrides, which are also
2929
// dynamically reloaded.
3030
// I'm doing it the simple way for now.
31-
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.")
31+
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.")
3232
cfg.RetentionConfig.RegisterFlagsWithPrefix(prefix+".retention", f)
3333
cfg.Queue.RegisterFlagsWithPrefix(prefix+".queue", f)
3434
}

‎pkg/bloombuild/planner/planner_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/grafana/loki/v3/pkg/bloombuild/planner/queue"
2323
"github.com/grafana/loki/v3/pkg/bloombuild/planner/strategies"
2424
"github.com/grafana/loki/v3/pkg/bloombuild/protos"
25+
iter "github.com/grafana/loki/v3/pkg/iter/v2"
2526
"github.com/grafana/loki/v3/pkg/storage"
2627
v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1"
2728
"github.com/grafana/loki/v3/pkg/storage/chunk/cache"
@@ -606,6 +607,36 @@ func Test_deleteOutdatedMetas(t *testing.T) {
606607
}
607608
}
608609

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

0 commit comments

Comments
 (0)