Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changesets/fix_simon_rayonless_sysinfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Fix increased memory usage in `sysinfo` since Router 1.59.0 ([PR #6634](https://github.com/apollographql/router/pull/6634))

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.

By [@SimonSapin](https://github.com/SimonSapin) in https://github.com/apollographql/router/pull/6634
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6603,7 +6603,6 @@ dependencies = [
"libc",
"memchr",
"ntapi",
"rayon",
"windows 0.57.0",
]

Expand Down
2 changes: 1 addition & 1 deletion apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ serde_yaml = "0.8.26"
static_assertions = "1.1.0"
strum_macros = "0.26.0"
sys-info = "0.9.1"
sysinfo = { version = "0.32.0", features = ["windows"] }
sysinfo = { version = "0.32.0", features = ["system", "windows"], default_features = false }
thiserror = "1.0.61"
tokio.workspace = true
tokio-stream = { version = "0.1.15", features = ["sync", "net"] }
Expand Down
3 changes: 2 additions & 1 deletion apollo-router/src/plugins/fleet_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct SystemGetter {
impl SystemGetter {
fn new() -> Self {
let mut system = System::new();
system.refresh_all();
system.refresh_cpu_all();
system.refresh_memory();
Self {
system,
start: Instant::now(),
Expand Down