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

Commits on Sep 2, 2023

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

    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 committed Sep 2, 2023
    Configuration menu
    Copy the full SHA
    524b981 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9e34705 View commit details
    Browse the repository at this point in the history