Skip to content

[ENHANCEMENT] pyroscope: optimize transformProfileResponse to O(n) - #747

Merged
jgbernalp merged 1 commit into
perses:mainfrom
luweglarz:pyroscope-profile-transform-perf
Jul 28, 2026
Merged

[ENHANCEMENT] pyroscope: optimize transformProfileResponse to O(n)#747
jgbernalp merged 1 commit into
perses:mainfrom
luweglarz:pyroscope-profile-transform-perf

Conversation

@luweglarz

@luweglarz luweglarz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

There was an explicit todo on this function to optimize from O(n2) to O(n).

The old code rescanned the whole parent level from scratch for every node. Since both levels are already sorted by start, a single pointer that only moves forward is enough in one pass.

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

@luweglarz
luweglarz requested a review from a team as a code owner July 22, 2026 14:20
@luweglarz
luweglarz requested review from jgbernalp and removed request for a team July 22, 2026 14:20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be good to add a test for this, so we can ensure it does not affect the output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is a comparison of outputs with the legacy function and the new one in test cases is what you mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a set of test cases for the refactor + regression test cases against old implementation

Signed-off-by: luweglarz <lucas.weglarz@amadeus.com>
@luweglarz
luweglarz force-pushed the pyroscope-profile-transform-perf branch from c42604b to d436c72 Compare July 24, 2026 13:11
@jgbernalp
jgbernalp added this pull request to the merge queue Jul 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 27, 2026
@jgbernalp
jgbernalp added this pull request to the merge queue Jul 28, 2026
Merged via the queue into perses:main with commit 877dab8 Jul 28, 2026
16 checks passed
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