Fix increased memory usage in sysinfo since Router 1.59.0#6634
Merged
SimonSapin merged 3 commits intodevfrom Jan 24, 2025
Merged
Fix increased memory usage in sysinfo since Router 1.59.0#6634SimonSapin merged 3 commits intodevfrom
sysinfo since Router 1.59.0#6634SimonSapin merged 3 commits intodevfrom
Conversation
In version 1.59.0, Apollo Router started using the `sysinfo` crate to gather metrics about available CPUs and RAM. By default, that crate uses `rayon` internally to parallelize its handling of system processes. In turn, rayon creates a pool of long-lived threads. In a particular benchmark on a 32-core Linux server, this caused resident memory use to increase by about 150 MB. This is likely a combination of stack space (which only gets freed when the thread terminates) and per-thread space reserved by the heap allocator to reduce cross-thread synchronization cost. This regression is now fixed by: * Disabling `sysinfo`’s use of `rayon`, so the thread pool is not created and system processes information is gathered in a sequential loop. * Making `sysinfo` not gather that information in the first place since Router does not use it.
Collaborator
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: e45ddb3f97e162a6684ed7c0 |
This comment has been minimized.
This comment has been minimized.
|
CI performance tests
|
Contributor
Author
|
@Mergifyio backport 1.59.2 |
Contributor
✅ Backports have been createdDetails
|
nmoutschen
approved these changes
Jan 23, 2025
BrynCooke
approved these changes
Jan 23, 2025
lrlna
approved these changes
Jan 23, 2025
mergify bot
pushed a commit
that referenced
this pull request
Jan 24, 2025
(cherry picked from commit 4c41b28)
6 tasks
SimonSapin
added a commit
that referenced
this pull request
Jan 24, 2025
(cherry picked from commit 4c41b28)
6 tasks
Contributor
Author
|
@Mergifyio backport 1.x |
Contributor
✅ Backports have been createdDetails
|
Contributor
Author
|
@Mergifyio backport 1.59.2 |
Contributor
✅ Backports have been createdDetails
|
Contributor
Author
|
@Mergifyio backport 1.59.2 |
Contributor
✅ Backports have been createdDetails
|
SimonSapin
added a commit
that referenced
this pull request
Jan 24, 2025
6 tasks
Contributor
Author
|
I was hoping to make Mergify create a new PR with me impersonated as author but it reuses the old one, even after deleting the branch. So I opened #6643 manually |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 version 1.59.0, Apollo Router started using the
sysinfocrate to gather metrics about available CPUs and RAM. By default, that crate usesrayoninternally to parallelize its handling of system processes. In turn, rayon creates a pool of long-lived threads.In a particular benchmark on a 32-core Linux server, this caused resident memory use to increase by about 150 MB. This is likely a combination of stack space (which only gets freed when the thread terminates) and per-thread space reserved by the heap allocator to reduce cross-thread synchronization cost.
This regression is now fixed by:
sysinfo’s use ofrayon, so the thread pool is not created and system processes information is gathered in a sequential loop.sysinfonot gather that information in the first place since Router does not use it.Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩