Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crrect initialization of a few slices #12674

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/querier/ingester_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (q *IngesterQuerier) TailersCount(ctx context.Context) ([]uint32, error) {
return nil, err
}

counts := make([]uint32, len(responses))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a good change, AFAICT atm we could be allocating # of ingesters * 2 uint32's since we could have a response from every ingester

counts := make([]uint32, 0, len(responses))

for _, resp := range responses {
counts = append(counts, resp.response.(uint32))
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/stores/series/series_index_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (c *IndexReaderWriter) chunksToSeries(ctx context.Context, in []logproto.Ch
return nil, err
}

results := make([]labels.Labels, len(chunksBySeries)) // Flatten out the per-job results.
results := make([]labels.Labels, 0, len(chunksBySeries)) // Flatten out the per-job results.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also seems safe, but actually I think it should be len(perJobResults) should it not? @bboreham I'm not sure from your original PR (here) if you intended to create the slice of chunkBySeries length rather than perJobResults length

Copy link
Contributor Author

@seiyab seiyab Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, len(chunksBySeries) looks correct. I also feel len(perJobResults) is correct at first sight.
Actually, argument of append is innerSlice..., not innerSlice. And sum of their length is probably len(chunkBySeries) (groups := make([]chunkGroup, 0, len(chunksBySeries)/c.chunkBatchSize+1).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right, I misread the append line 👍 good find

for _, innerSlice := range perJobResults {
results = append(results, innerSlice...)
}
Expand Down
Loading