diff --git a/forc-pkg/Cargo.toml b/forc-pkg/Cargo.toml index 4d9ffee8fda..d2120a64cd0 100644 --- a/forc-pkg/Cargo.toml +++ b/forc-pkg/Cargo.toml @@ -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" diff --git a/forc-pkg/src/pkg.rs b/forc-pkg/src/pkg.rs index eaf29b17b74..354e65fc347 100644 --- a/forc-pkg/src/pkg.rs +++ b/forc-pkg/src/pkg.rs @@ -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; diff --git a/sway-core/Cargo.toml b/sway-core/Cargo.toml index d03bab94c39..171953359c1 100644 --- a/sway-core/Cargo.toml +++ b/sway-core/Cargo.toml @@ -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" diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs index 6ee8b16fb48..e2990c4e64d 100644 --- a/sway-core/src/lib.rs +++ b/sway-core/src/lib.rs @@ -63,7 +63,6 @@ pub mod fuel_prelude { } pub use engine_threading::Engines; -use sysinfo::{System, SystemExt}; /// Given an input `Arc` and an optional [BuildConfig], parse the input into a [lexed::LexedProgram] and [parsed::ParseProgram]. /// diff --git a/sway-utils/src/performance.rs b/sway-utils/src/performance.rs index 40a9ea70673..94ad5a8ae42 100644 --- a/sway-utils/src/performance.rs +++ b/sway-utils/src/performance.rs @@ -4,7 +4,7 @@ use serde::Serialize; pub struct PerformanceMetric { pub phase: String, pub elapsed: f64, - pub memory_usage: u64, + pub memory_usage: Option, } #[derive(Debug, Default, Serialize)] @@ -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