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

refactor: move sysinfo behind a feature flag and only enable it for non-macos builds #4750

Merged
merged 7 commits into from
Jul 5, 2023
Merged
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
4 changes: 3 additions & 1 deletion forc-pkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ sway-core = { version = "0.41.0", path = "../sway-core" }
sway-error = { version = "0.41.0", path = "../sway-error" }
sway-types = { version = "0.41.0", path = "../sway-types" }
sway-utils = { version = "0.41.0", path = "../sway-utils" }
sysinfo = "0.29.0"
tar = "0.4.38"
toml = "0.5"
tracing = "0.1"
url = { version = "2.2", features = ["serde"] }
vec1 = "1.8.0"
walkdir = "2"

[target.'cfg(not(target_os = "macos"))'.dependencies]
sysinfo = "0.29.0"
1 change: 0 additions & 1 deletion forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use sway_core::{
use sway_error::{error::CompileError, warning::CompileWarning};
use sway_types::{Ident, Span, Spanned};
use sway_utils::{constants, time_expr, PerformanceData, PerformanceMetric};
use sysinfo::{System, SystemExt};
use tracing::{info, warn};

type GraphIx = u32;
Expand Down
4 changes: 3 additions & 1 deletion sway-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ sway-ir = { version = "0.41.0", path = "../sway-ir" }
sway-parse = { version = "0.41.0", path = "../sway-parse" }
sway-types = { version = "0.41.0", path = "../sway-types" }
sway-utils = { version = "0.41.0", path = "../sway-utils" }
sysinfo = "0.29.0"
thiserror = "1.0"
tracing = "0.1"
uint = "0.9"
vec1 = "1.8.0"

[target.'cfg(not(target_os = "macos"))'.dependencies]
sysinfo = "0.29.0"
1 change: 0 additions & 1 deletion sway-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub mod fuel_prelude {
}

pub use engine_threading::Engines;
use sysinfo::{System, SystemExt};

/// Given an input `Arc<str>` and an optional [BuildConfig], parse the input into a [lexed::LexedProgram] and [parsed::ParseProgram].
///
Expand Down
16 changes: 12 additions & 4 deletions sway-utils/src/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::Serialize;
pub struct PerformanceMetric {
pub phase: String,
pub elapsed: f64,
pub memory_usage: u64,
pub memory_usage: Option<u64>,
}

#[derive(Debug, Default, Serialize)]
Expand All @@ -26,12 +26,20 @@ macro_rules! time_expr {
println!(" Time elapsed to {}: {:?}", $description, elapsed);
}
if cfg.metrics_outfile.is_some() {
let mut sys = System::new();
sys.refresh_system();
#[cfg(not(target_os = "macos"))]
let memory_usage = {
use sysinfo::{System, SystemExt};
let mut sys = System::new();
sys.refresh_system();
Some(sys.used_memory())
};
#[cfg(target_os = "macos")]
let memory_usage = None;

$data.metrics.push(PerformanceMetric {
phase: $key.to_string(),
elapsed: elapsed.as_secs_f64(),
memory_usage: sys.used_memory(),
memory_usage,
});
}
output
Expand Down