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

[8.16] [APM] Improve performance in `dependencies` endpoints to prevent high CPU usage (#209999) #210316

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.16:

Questions ?

Please refer to the Backport tool documentation

… CPU usage (elastic#209999)

## Summary

After investigating a high CPU spike in the `dependencies` endpoints for
large quantities of data, we identified the issue as a slow deep merge
of objects. The merge operation was growing exponentially in size based
on the number of objects found with the same `id`.

We improved performance by excluding the stats object from unnecessary
merges and instead joining it using the spread operator. The results
show a significant reduction in CPU usage, preventing the event loop
from being blocked and ensuring better resource availability.

|Before|After|
|-|-|
|<img width="1728" alt="Screenshot 2025-02-06 at 12 50 41"
src="https://github.com/user-attachments/assets/6cd2bd68-6f19-42e2-bc2a-ed01a9f187c0"
/>|<img width="1728" alt="Screenshot 2025-02-06 at 13 11 20"
src="https://github.com/user-attachments/assets/3ab7d9fb-0156-4d7e-a788-95cae11131f6"
/>|
|<img width="2559" alt="Screenshot 2025-02-06 at 14 34 24"
src="https://github.com/user-attachments/assets/3950525c-f5fa-4895-ae38-7927e5497d80"
/>|<img width="2558" alt="Screenshot 2025-02-06 at 14 29 08"
src="https://github.com/user-attachments/assets/f05b6747-077b-49ea-a4ac-8528f6e2eb8f"
/>|

(cherry picked from commit 0c7fb00)
@kibanamachine kibanamachine enabled auto-merge (squash) February 10, 2025 09:57
@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team labels Feb 10, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@elasticmachine
Copy link
Contributor

elasticmachine commented Feb 10, 2025

💚 Build Succeeded

  • Buildkite Build
  • Commit: e4051cd
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-210316-e4051cdc52c5

Metrics [docs]

✅ unchanged

History

cc @miloszmarcinkowski

@kibanamachine kibanamachine merged commit 5bad64f into elastic:8.16 Feb 10, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport ci:project-deploy-observability Create an Observability project Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants