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: metrics performance patch #4108

Merged
merged 2 commits into from
Jun 29, 2023
Merged

fix: metrics performance patch #4108

merged 2 commits into from
Jun 29, 2023

Conversation

sjaanus
Copy link
Contributor

@sjaanus sjaanus commented Jun 28, 2023

In our hosted instance, we faced issue of metrics loading 5-10 seconds. We had two environments, around 70 applications, and 48 hour buckets, resulting in ~7000 permutations.

The main issue arose when the metrics.filter function was called, which involved running the compare function on all metrics for each permutation. With 3000 metrics in total, this led to over 20 million calls to the compareAsc function worse case scenario, causing a delay of 5-10 seconds for metric loading.

To improve performance, I optimized the logic by prefiltering the metrics based on the environment and appName. This eliminated the need to run the same function on all metrics repeatedly. Now, the compareAsc function is expected to be called only around 5000 times, resulting in a significant tenfold performance increase.

@vercel
Copy link

vercel bot commented Jun 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2023 7:48am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Jun 28, 2023 7:48am

Copy link
Contributor

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

Definitely a nice improvement. :)

@sjaanus sjaanus merged commit 19770fc into main Jun 29, 2023
16 checks passed
@sjaanus sjaanus deleted the fix-perf-metrics branch June 29, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants