Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.