Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 2e318c0

Browse files
authored
Dedupe merge improvement. (#656)
* Avoid creating a new goroutine for every profiles when deduping * Removes gzip compression when using querier * Removes next async * Only async for the first batch * Do not sort in ingester and reduce batch size * Reuse rewrite array * Revert batch size * Add a span * Loser tree * Correctly count dupe * Removes allocations from At * Remove allocation from the keep responses * Removes gzip compression change * Fetch the first batch async * Removes sort change. * make fmt lint
1 parent 39a8593 commit 2e318c0

File tree

5 files changed

+549
-179
lines changed

5 files changed

+549
-179
lines changed

pkg/model/stacktraces.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ func MergeBatchMergeStacktraces(responses ...*ingestv1.MergeProfilesStacktracesR
1818
stacktraces = map[uint64]*ingestv1.StacktraceSample{}
1919
)
2020

21+
largestNames := 0
22+
23+
for _, resp := range responses {
24+
if resp != nil {
25+
if len(resp.FunctionNames) > largestNames {
26+
largestNames = len(resp.FunctionNames)
27+
}
28+
}
29+
}
30+
rewrite := make([]int32, largestNames)
31+
2132
for _, resp := range responses {
2233
// skip empty results
2334
if resp == nil || len(resp.Stacktraces) == 0 {
@@ -35,15 +46,15 @@ func MergeBatchMergeStacktraces(responses ...*ingestv1.MergeProfilesStacktracesR
3546

3647
// build up the lookup map the first time
3748
if posByName == nil {
38-
posByName = make(map[string]int32)
49+
posByName = make(map[string]int32, len(result.FunctionNames))
3950
for idx, n := range result.FunctionNames {
4051
posByName[n] = int32(idx)
4152
}
4253
}
4354

4455
// lookup and add missing functionNames
4556
var (
46-
rewrite = make([]int32, len(resp.FunctionNames))
57+
rewrite = rewrite[:len(resp.FunctionNames)]
4758
ok bool
4859
)
4960
for idx, n := range resp.FunctionNames {

0 commit comments

Comments
 (0)