Optimize ts v2 pool#7373
Conversation
370cb81 to
beb33bd
Compare
CharlieTLe
left a comment
There was a problem hiding this comment.
The V2 pool was introduced in 918aa41 and shipped in v1.20.0, so the missing symbol clearing is a bug in a released version. Should a [BUGFIX] CHANGELOG entry be added?
| assert.Equal(t, "", underlyingArray[1]) | ||
| } |
There was a problem hiding this comment.
Three symbols are appended ("", "name", "test") but only indices 0 and 1 are checked. Should index 2 be asserted as well?
| assert.Equal(t, "", underlyingArray[1]) | |
| } | |
| assert.Equal(t, "", underlyingArray[1]) | |
| assert.Equal(t, "", underlyingArray[2]) | |
| } |
| }) | ||
| } | ||
|
|
||
| func TestReuseWriteRequestV2(t *testing.T) { |
There was a problem hiding this comment.
Could this test flake since sync.Pool doesn't guarantee Get returns the same object that was just Put? If the GC runs between the ReuseWriteRequestV2 and PreallocWriteRequestV2FromPool calls, a fresh object would be returned and the backing array assertions would be skipped.
Would it be more robust to capture a reference to the backing array before the reuse call, so the clearing can be verified directly without depending on the pool?
// Capture backing array before reuse
backingArray := req.Symbols[:cap(req.Symbols)]
ReuseWriteRequestV2(req)
// Verify clearing directly on the backing array
for i, s := range backingArray[:3] {
assert.Equalf(t, "", s, "symbol at index %d not cleared", i)
}There was a problem hiding this comment.
I fixed it at the latest commit to check if the symbol table is reset without GC.
Thanks for the comment!
fdb24ce to
f263b6c
Compare
c2a3c20 to
d3ad749
Compare
|
@CharlieTLe |
Signed-off-by: SungJin1212 <[email protected]>
d3ad749 to
e9c7d69
Compare
Signed-off-by: SungJin1212 <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Signed-off-by: SungJin1212 <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Signed-off-by: Friedrich Gonzalez <[email protected]>
* Memberlist cas error code false positive (#7408) * use errors.As in getCasErrorCode to unwrap memberlist errors Signed-off-by: SungJin1212 <[email protected]> * fix test Signed-off-by: SungJin1212 <[email protected]> --------- Signed-off-by: SungJin1212 <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]> * Fix nil when ingesterQueryMaxAttempts > 1 (#7369) * Trigger nil with test Signed-off-by: Friedrich Gonzalez <[email protected]> * Fix nil results Signed-off-by: Friedrich Gonzalez <[email protected]> * fix changelog Signed-off-by: Friedrich Gonzalez <[email protected]> --------- Signed-off-by: Friedrich Gonzalez <[email protected]> * fix: alertmanager user config disappearing when ring is unreachable (#7372) * Fix multitenant alertmanager user config disappearing when ring is unreachable Signed-off-by: Kishore K G <[email protected]> * Add change log Signed-off-by: Kishore K G <[email protected]> * format multitenant Signed-off-by: Kishore K G <[email protected]> * fix pr number Signed-off-by: Kishore K G <[email protected]> * use ErrNotFound for error validation in unit test Signed-off-by: kishorekg1999 <[email protected]> --------- Signed-off-by: Kishore K G <[email protected]> Signed-off-by: kishorekg1999 <[email protected]> Signed-off-by: kishorekg1999 <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]> * Clean Symbol Tables (#7373) Signed-off-by: SungJin1212 <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]> * Fix root cause of nil return in queryWithRetry and labelsWithRetry (#7375) Signed-off-by: Friedrich Gonzalez <[email protected]> * fix regex resolver match 0 or 1 tenant bug (#7424) * fix regex resolver match 0 or 1 tenant bug Signed-off-by: SungJin1212 <[email protected]> * fix test Signed-off-by: SungJin1212 <[email protected]> --------- Signed-off-by: SungJin1212 <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]> * skip nil values in Memberlist WatchPrefix (#7429) * skip nil values in Memberlist WatchPrefix Signed-off-by: SungJin1212 <[email protected]> * fix lint Signed-off-by: SungJin1212 <[email protected]> --------- Signed-off-by: SungJin1212 <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]> * Remove duplicate CHANGELOG entry for #7373 Signed-off-by: Friedrich Gonzalez <[email protected]> * Fix integration test flag name for release-1.21 The cherry-pick of #7424 brought the master flag name -limits.query-ingesters-within, but release-1.21 still uses -querier.query-ingesters-within (renamed in #7160, master-only). Signed-off-by: Friedrich Gonzalez <[email protected]> --------- Signed-off-by: SungJin1212 <[email protected]> Signed-off-by: Friedrich Gonzalez <[email protected]> Signed-off-by: Kishore K G <[email protected]> Signed-off-by: kishorekg1999 <[email protected]> Signed-off-by: kishorekg1999 <[email protected]> Co-authored-by: SungJin1212 <[email protected]> Co-authored-by: kishorekg1999 <[email protected]>
This PR improves V2 write request memory pooling by preventing string pointer leaks, adding explicit string clearing in
ReuseWriteRequestV2to prevent memory leaks when reusing pooled requests, and removing redundant exemplar label cleanup fromReuseTimeseriesV2.Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]