Skip to content

Commit

Permalink
Rust: Update sysinfo crate
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/executorch#3520

I need an update sysinfo for some Windows stuff, the previous version doesn't seem to work correctly (plus the documented API has changed a bit and the examples just don't build).

Reviewed By: JakobDegen

Differential Revision: D56913751

fbshipit-source-id: 30ba14269792ad46236929ba40071974dd1ce436
  • Loading branch information
Carlos Fernandez authored and facebook-github-bot committed May 9, 2024
1 parent f5f3f59 commit 150ad96
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ structopt = "0.3.23"
syn = { version = "2", features = ["extra-traits", "full", "visit"] }
sync_wrapper = "0.1.0"
sys-info = "0.9.1"
sysinfo = "0.26.8"
sysinfo = "0.30.11"
take_mut = "0.2.2"
tar = "0.4.38"
tempfile = "3.1.0"
Expand Down
3 changes: 0 additions & 3 deletions app/buck2_client_ctx/src/daemon/client/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ use buck2_cli_proto::daemon_api_client::*;
use buck2_cli_proto::*;
use buck2_wrapper_common::kill;
use buck2_wrapper_common::pid::Pid;
use sysinfo::PidExt;
use sysinfo::ProcessExt;
use sysinfo::ProcessRefreshKind;
use sysinfo::System;
use sysinfo::SystemExt;
use tonic::codegen::InterceptedService;
use tonic::transport::Channel;
use tonic::Request;
Expand Down
2 changes: 0 additions & 2 deletions app/buck2_forkserver/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,7 @@ mod tests {
#[tokio::test]
async fn test_kill_terminates_process_group() -> anyhow::Result<()> {
use sysinfo::Pid;
use sysinfo::ProcessExt;
use sysinfo::System;
use sysinfo::SystemExt;

let cmd = if cfg!(windows) {
let mut cmd = background_command("powershell");
Expand Down
6 changes: 4 additions & 2 deletions app/buck2_util/src/system_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ impl UnixSystemStats {
}

pub fn system_memory_stats() -> u64 {
use sysinfo::MemoryRefreshKind;
use sysinfo::RefreshKind;
use sysinfo::System;
use sysinfo::SystemExt;

let system = System::new_with_specifics(RefreshKind::new().with_memory());
let system = System::new_with_specifics(
RefreshKind::new().with_memory(MemoryRefreshKind::new().with_ram()),
);
system.total_memory()
}

Expand Down
3 changes: 0 additions & 3 deletions app/buck2_wrapper_common/src/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ impl KilledProcessHandle {

/// Get the status of a given process according to sysinfo.
pub fn get_sysinfo_status(pid: Pid) -> Option<sysinfo::ProcessStatus> {
use sysinfo::PidExt;
use sysinfo::ProcessExt;
use sysinfo::ProcessRefreshKind;
use sysinfo::System;
use sysinfo::SystemExt;

let pid = sysinfo::Pid::from_u32(pid.to_u32());

Expand Down
8 changes: 4 additions & 4 deletions app/buck2_wrapper_common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ use std::time::Duration;
use std::time::Instant;

use is_buck2::WhoIsAsking;
use sysinfo::PidExt;
use sysinfo::ProcessExt;
use sysinfo::System;
use sysinfo::SystemExt;

use crate::is_buck2::is_buck2_exe;
use crate::pid::Pid;
Expand Down Expand Up @@ -67,7 +64,10 @@ fn find_buck2_processes(who_is_asking: WhoIsAsking) -> Vec<ProcessInfo> {

let mut buck2_processes = Vec::new();
for (pid, process) in system.processes() {
if is_buck2_exe(process.exe(), who_is_asking) && !current_parents.contains(pid) {
let Some(exe) = process.exe() else {
continue;
};
if is_buck2_exe(exe, who_is_asking) && !current_parents.contains(pid) {
let Ok(pid) = Pid::from_u32(pid.as_u32()) else {
continue;
};
Expand Down
1 change: 0 additions & 1 deletion app/buck2_wrapper_common/src/unix/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::time::Duration;
use anyhow::Context;
use nix::sys::signal::Signal;
use sysinfo::Process;
use sysinfo::ProcessExt;

use crate::kill::get_sysinfo_status;
use crate::pid::Pid;
Expand Down
2 changes: 0 additions & 2 deletions app/buck2_wrapper_common/src/win/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

use std::time::Duration;

use sysinfo::PidExt;
use sysinfo::Process;
use sysinfo::ProcessExt;

use crate::pid::Pid;
use crate::win::winapi_process::WinapiProcessHandle;
Expand Down
2 changes: 1 addition & 1 deletion shim/third-party/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ syn1 = { package = "syn", version = "1.0.109", features = ["extra-traits", "fold
synstructure = "0.12"
sync_wrapper = "0.1.0"
sys-info = "0.9.1"
sysinfo = "0.26.8"
sysinfo = "0.30.11"
take_mut = "0.2.2"
tar = "0.4.38"
tempfile = "3.1.0"
Expand Down

0 comments on commit 150ad96

Please sign in to comment.