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

pkg/query: Use maps instead of slices for children for O(1) access #3743

Merged
merged 2 commits into from
Sep 2, 2023

Conversation

brancz
Copy link
Member

@brancz brancz commented Sep 2, 2023

This improves the performance of building flamegraph API responses
dramatically. The major change is that instead of keeping children as
slices and iterating over them to find which child to step into when
building the graph, we build a key based on the fields we're aggregating
by and use that to check if the children map already contains it.

$ benchstat old.txt new.txt
name                old time/op  new time/op  delta
ArrowFlamegraph-10  5.04ms ± 2%  1.58ms ± 2%  -68.66%  (p=0.008 n=5+5)

The second commit adds some helpers to ensure we sort the result, so we get a deterministic result.

@brancz brancz requested a review from a team as a code owner September 2, 2023 11:32
@alwaysmeticulous
Copy link

alwaysmeticulous bot commented Sep 2, 2023

✅ Meticulous spotted zero visual differences across 378 screens tested: view results.

Last updated for commit 9e34705. This comment will update as new commits are pushed.

This improves the performance of building flamegraph API responses
dramatically. The major change is that instead of keeping children as
slices and iterating over them to find which child to step into when
building the graph, we build a key based on the fields we're aggregating
by and use that to check if the children map already contains it.

```
$ benchstat old.txt new.txt
name                old time/op  new time/op  delta
ArrowFlamegraph-10  5.04ms ± 2%  1.58ms ± 2%  -68.66%  (p=0.008 n=5+5)
```
@brancz brancz merged commit 9ab5431 into main Sep 2, 2023
31 of 32 checks passed
@brancz brancz deleted the fg-perf branch September 2, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants