From 7ae2464cf305d6d215aca867d4666a246d1808dc Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 19 Mar 2020 18:14:01 -0700 Subject: [PATCH] Fix windows build by removing sys-info (#8860) (#8973) automerge --- Cargo.lock | 29 ++++++++++++++--------------- core/Cargo.toml | 2 +- core/tests/cluster_info.rs | 2 +- ledger/Cargo.toml | 2 +- ledger/src/blockstore_db.rs | 2 +- metrics/Cargo.toml | 2 +- metrics/src/metrics.rs | 6 ++++-- rayon-threadlimit/Cargo.toml | 2 +- rayon-threadlimit/src/lib.rs | 2 +- runtime/Cargo.toml | 1 - 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c25b242648..fc479493b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,6 +1319,15 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "gethostname" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "getrandom" version = "0.1.6" @@ -3934,6 +3943,7 @@ dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3964,7 +3974,6 @@ dependencies = [ "solana-sys-tuner 1.0.8", "solana-vote-program 1.0.8", "solana-vote-signer 1.0.8", - "sys-info 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "systemstat 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4157,6 +4166,7 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4180,7 +4190,6 @@ dependencies = [ "solana-stake-program 1.0.8", "solana-vote-program 1.0.8", "symlink 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sys-info 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4292,6 +4301,7 @@ name = "solana-metrics" version = "1.0.8" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gethostname 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4299,7 +4309,6 @@ dependencies = [ "serial_test 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "serial_test_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-sdk 1.0.8", - "sys-info 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4408,7 +4417,7 @@ name = "solana-rayon-threadlimit" version = "1.0.8" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sys-info 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4468,7 +4477,6 @@ dependencies = [ "solana-stake-program 1.0.8", "solana-storage-program 1.0.8", "solana-vote-program 1.0.8", - "sys-info 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5173,15 +5181,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "sys-info" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "sysctl" version = "0.4.0" @@ -6342,6 +6341,7 @@ dependencies = [ "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" "checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" +"checksum gethostname 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e692e296bfac1d2533ef168d0b60ff5897b8b70a4009276834014dd8924cc028" "checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" @@ -6627,7 +6627,6 @@ dependencies = [ "checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum sys-info 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d4eff5474e55653c77b4470bdc2278c7e22f942d59658d0e8767d1c97e02a7b9" "checksum sysctl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0501f0d0c2aa64b419abff97c209f4b82c4e67caa63e8dc5b222ecc1b574cb5c" "checksum systemstat 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2078da8d09c6202bffd5e075946e65bfad5ce2cfa161edb15c5f014a8440adee" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" diff --git a/core/Cargo.toml b/core/Cargo.toml index 3f84752551..4f488e43bc 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -34,6 +34,7 @@ jsonrpc-ws-server = "14.0.6" libc = "0.2.66" log = "0.4.8" nix = "0.17.0" +num_cpus = "1.0.0" num-traits = "0.2" rand = "0.6.5" rand_chacha = "0.1.1" @@ -62,7 +63,6 @@ solana-storage-program = { path = "../programs/storage", version = "1.0.9" } solana-vote-program = { path = "../programs/vote", version = "1.0.9" } solana-vote-signer = { path = "../vote-signer", version = "1.0.9" } solana-sys-tuner = { path = "../sys-tuner", version = "1.0.9" } -sys-info = "0.5.9" tempfile = "3.1.0" thiserror = "1.0" tokio = "0.1" diff --git a/core/tests/cluster_info.rs b/core/tests/cluster_info.rs index d165ac52a1..f209bed33d 100644 --- a/core/tests/cluster_info.rs +++ b/core/tests/cluster_info.rs @@ -15,7 +15,7 @@ use std::time::Instant; type Nodes = HashMap, Receiver<(i32, bool)>)>; fn num_threads() -> usize { - sys_info::cpu_num().unwrap_or(10) as usize + num_cpus::get() } /// Search for the a node with the given balance diff --git a/ledger/Cargo.toml b/ledger/Cargo.toml index e4ccfea2a4..9b54e426b7 100644 --- a/ledger/Cargo.toml +++ b/ledger/Cargo.toml @@ -20,6 +20,7 @@ fs_extra = "1.1.0" itertools = "0.8.2" libc = "0.2.66" log = { version = "0.4.8" } +num_cpus = "1.0.0" rand = "0.6.5" rand_chacha = "0.1.1" rayon = "1.2.0" @@ -40,7 +41,6 @@ solana-runtime = { path = "../runtime", version = "1.0.9" } solana-sdk = { path = "../sdk", version = "1.0.9" } solana-stake-program = { path = "../programs/stake", version = "1.0.9" } solana-vote-program = { path = "../programs/vote", version = "1.0.9" } -sys-info = "0.5.9" symlink = "0.1.0" tar = "0.4.26" thiserror = "1.0" diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs index 5f278c42ef..9ad31f196c 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -754,6 +754,6 @@ fn get_db_options() -> Options { options.create_if_missing(true); options.create_missing_column_families(true); // A good value for this is the number of cores on the machine - options.increase_parallelism(sys_info::cpu_num().unwrap() as i32); + options.increase_parallelism(num_cpus::get() as i32); options } diff --git a/metrics/Cargo.toml b/metrics/Cargo.toml index 69d0fee591..29c956010f 100644 --- a/metrics/Cargo.toml +++ b/metrics/Cargo.toml @@ -10,11 +10,11 @@ edition = "2018" [dependencies] env_logger = "0.7.1" +gethostname = "0.2.1" lazy_static = "1.4.0" log = "0.4.8" reqwest = { version = "0.10.1", default-features = false, features = ["blocking", "rustls-tls"] } solana-sdk = { path = "../sdk", version = "1.0.9" } -sys-info = "0.5.9" [dev-dependencies] rand = "0.6.5" diff --git a/metrics/src/metrics.rs b/metrics/src/metrics.rs index 028f22c9ea..dafa5e90cb 100644 --- a/metrics/src/metrics.rs +++ b/metrics/src/metrics.rs @@ -1,6 +1,7 @@ //! The `metrics` module enables sending measurements to an `InfluxDB` instance use crate::{counter::CounterPoint, datapoint::DataPoint}; +use gethostname::gethostname; use lazy_static::lazy_static; use log::*; use solana_sdk::hash::hash; @@ -11,7 +12,6 @@ use std::sync::{Arc, Barrier, Mutex, Once, RwLock}; use std::thread; use std::time::{Duration, Instant}; use std::{cmp, env}; -use sys_info::hostname; type CounterMap = HashMap<(&'static str, u64), CounterPoint>; @@ -317,7 +317,9 @@ fn get_singleton_agent() -> Arc> { lazy_static! { static ref HOST_ID: Arc> = { Arc::new(RwLock::new({ - let hostname: String = hostname().unwrap_or_else(|_| "".to_string()); + let hostname: String = gethostname() + .into_string() + .unwrap_or_else(|_| "".to_string()); format!("{}", hash(hostname.as_bytes())) })) }; diff --git a/rayon-threadlimit/Cargo.toml b/rayon-threadlimit/Cargo.toml index c2065650d8..5766bedf59 100644 --- a/rayon-threadlimit/Cargo.toml +++ b/rayon-threadlimit/Cargo.toml @@ -10,5 +10,5 @@ license = "Apache-2.0" edition = "2018" [dependencies] +num_cpus = "1.0.0" lazy_static = "1.4.0" -sys-info = "0.5.9" diff --git a/rayon-threadlimit/src/lib.rs b/rayon-threadlimit/src/lib.rs index b1ac5ab47a..5580f21726 100644 --- a/rayon-threadlimit/src/lib.rs +++ b/rayon-threadlimit/src/lib.rs @@ -6,7 +6,7 @@ extern crate lazy_static; lazy_static! { // reduce the number of threads each pool is allowed to half the cpu core count, to avoid rayon // hogging cpu - static ref MAX_RAYON_THREADS: usize = sys_info::cpu_num().unwrap() as usize / 2; + static ref MAX_RAYON_THREADS: usize = num_cpus::get() as usize / 2; } pub fn get_thread_count() -> usize { diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index e770ccc7cc..ade58f92ee 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -34,7 +34,6 @@ solana-sdk = { path = "../sdk", version = "1.0.9" } solana-stake-program = { path = "../programs/stake", version = "1.0.9" } solana-storage-program = { path = "../programs/storage", version = "1.0.9" } solana-vote-program = { path = "../programs/vote", version = "1.0.9" } -sys-info = "0.5.9" tempfile = "3.1.0" thiserror = "1.0"