Skip to content

Commit 4e7841b

Browse files
change adaptive way to EMA (#7401)
* change adaptive way to EMA Signed-off-by: SungJin1212 <tjdwls1201@gmail.com> * changelog Signed-off-by: SungJin1212 <tjdwls1201@gmail.com> * typo Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> --------- Signed-off-by: SungJin1212 <tjdwls1201@gmail.com> Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> Co-authored-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
1 parent d38e2a4 commit 4e7841b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## master / unreleased
44
* [FEATURE] Distributor: Add experimental `-distributor.enable-start-timestamp` flag for Prometheus Remote Write 2.0. When enabled, `StartTimestamp (ST)` is ingested. #7371
55
* [FEATURE] Memberlist: Add `-memberlist.cluster-label` and `-memberlist.cluster-label-verification-disabled` to prevent accidental cross-cluster gossip joins and support rolling label rollout. #7385
6-
* [ENHANCEMENT] Distributor: Introduce dynamic `Symbols` slice capacity pooling. #7398
6+
* [ENHANCEMENT] Distributor: Introduce dynamic `Symbols` slice capacity pooling. #7398 #7401
77
* [ENHANCEMENT] Metrics Helper: Add native histogram support for aggregating and merging, including dual-format histogram handling that exposes both native and classic bucket formats. #7359
88
* [ENHANCEMENT] Cache: Add per-tenant TTL configuration for query results cache to control cache expiration on a per-tenant basis with separate TTLs for regular and out-of-order data. #7357
99
* [CHANGE] Querier: Make query time range configurations per-tenant: `query_ingesters_within`, `query_store_after`, and `shuffle_sharding_ingesters_lookback_period`. Uses `model.Duration` instead of `time.Duration` to support serialization but has minimum unit of 1ms (nanoseconds/microseconds not supported). #7160

pkg/cortexpb/timeseriesv2.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,15 @@ func ReuseWriteRequestV2(req *PreallocWriteRequestV2) {
102102
// Update the dynamic symbol capacity.
103103
for {
104104
current := dynamicSymbolsCapacity.Load()
105-
if symbolsCap <= current {
106-
// break when other goroutines have already updated the capacity to a larger value
105+
// We use an EMA to update the capacity.
106+
newAvg := max((current*9+symbolsCap*1)/10, int64(initialSymbolsCapacity))
107+
108+
if current == newAvg {
109+
// nothing to change
107110
break
108111
}
109-
if dynamicSymbolsCapacity.CompareAndSwap(current, symbolsCap) {
112+
113+
if dynamicSymbolsCapacity.CompareAndSwap(current, newAvg) {
110114
break
111115
}
112116
}

pkg/cortexpb/timeseriesv2_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ func TestReuseWriteRequestV2(t *testing.T) {
100100

101101
ReuseWriteRequestV2(req)
102102

103-
// Verify that the dynamic capacity has scaled up
104-
assert.Equal(t, int64(newCap), dynamicSymbolsCapacity.Load())
103+
// Verify that the dynamic capacity has been updated
104+
expectedCap := max((currentCap*9+int64(newCap))/10, int64(initialSymbolsCapacity))
105+
assert.Equal(t, expectedCap, dynamicSymbolsCapacity.Load())
105106
})
106107
t.Run("outlier capacity does not update dynamic capacity and is discarded", func(t *testing.T) {
107108
currentCap := dynamicSymbolsCapacity.Load()

0 commit comments

Comments
 (0)