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

feat: choose p2pool squad based on cpu cores [DNM] #1125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ version = "0.7.7"

[build-dependencies]
embed-resource = "2.5.0"
tauri-build = {version = "1.5.5", features = ["isolation"]}
tauri-build = {version = "1.5.5", features = ["isolation"] }

[dependencies]
anyhow = "1"
async-trait = "0.1.81"
async_zip = {version = "0.0.17", features = ["full"]}
async_zip = {version = "0.0.17", features = ["full"] }
auto-launch = "0.5.0"
base64 = "0.22.1"
blake2 = "0.10"
Expand All @@ -32,26 +32,27 @@ keyring = {version = "3.0.5", features = [
"windows-native",
"apple-native",
"linux-native",
]}
] }
libsqlite3-sys = {version = "0.25.1", features = [
"bundled",
]}# Required for tari_wallet
] }# Required for tari_wallet
log = "0.4.22"
log4rs = "1.3.0"
minotari_node_grpc_client = {git = "https://github.com/tari-project/tari.git", branch = "development"}
minotari_wallet_grpc_client = {git = "https://github.com/tari-project/tari.git", branch = "development"}
nix = {version = "0.29.0", features = ["signal"]}
nix = {version = "0.29.0", features = ["signal"] }
num_cpus = "1.16.0"
nvml-wrapper = "0.10.0"
open = "5"
phraze = "0.3.15"
rand = "0.8.5"
regex = "1.10.5"
reqwest = {version = "0.12.5", features = ["stream", "json", "multipart"]}
reqwest = {version = "0.12.5", features = ["stream", "json", "multipart"] }
sanitize-filename = "0.5"
semver = "1.0.23"
sentry = {version = "0.34.0", features = ["anyhow"]}
sentry = {version = "0.34.0", features = ["anyhow"] }
sentry-tauri = "0.3.0"
serde = {version = "1", features = ["derive"]}
serde = {version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9.10"
sha2 = "0.10.8"
Expand All @@ -62,7 +63,7 @@ tari_common = {git = "https://github.com/tari-project/tari.git", branch = "devel
tari_common_types = {git = "https://github.com/tari-project/tari.git", branch = "development"}
tari_core = {git = "https://github.com/tari-project/tari.git", branch = "development", features = [
"transactions",
]}
] }
tari_crypto = "0.21.0"
tari_key_manager = {git = "https://github.com/tari-project/tari.git", branch = "development"}
tari_shutdown = {git = "https://github.com/tari-project/tari.git", branch = "development"}
Expand All @@ -87,12 +88,12 @@ tauri = {version = "1.8.0", features = [
"icon-ico",
"icon-png",
"process-command-api",
]}
] }
tauri-plugin-single-instance = {git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1"}
thiserror = "1.0.26"
tokio = {version = "1", features = ["full"]}
tokio-util = {version = "0.7.11", features = ["compat"]}
xz2 = {version = "0.1.7", features = ["static"]}# static bind lzma
tokio = {version = "1", features = ["full"] }
tokio-util = {version = "0.7.11", features = ["compat"] }
xz2 = {version = "0.1.7", features = ["static"] }# static bind lzma
zip = "2.2.0"

[target.'cfg(windows)'.dependencies]
Expand All @@ -101,7 +102,7 @@ winreg = "0.52.0"
# needed for keymanager. TODO: Find a way of creating a keymanager without bundling sqlite
chrono = "0.4.38"
device_query = "2.1.0"
libsqlite3-sys = {version = "0.25.1", features = ["bundled"]}
libsqlite3-sys = {version = "0.25.1", features = ["bundled"] }
log = "0.4.22"
nvml-wrapper = "0.10.0"
rand = "0.8.5"
Expand Down
16 changes: 15 additions & 1 deletion src-tauri/src/p2pool_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::process_adapter::ProcessStartupSpec;
use crate::process_adapter::{ProcessAdapter, ProcessInstance, StatusMonitor};
use crate::utils::file_utils::convert_to_string;

use crate::utils::hardware_utils;
#[cfg(target_os = "windows")]
use crate::utils::setup_utils::setup_utils::add_firewall_rule;

Expand Down Expand Up @@ -81,7 +82,10 @@ impl ProcessAdapter for P2poolAdapter {
let pid_file_name = self.pid_file_name().to_string();

args.push("--squad".to_string());
args.push("default_2".to_string());

let squad = determine_squad();

args.push(squad);
let mut envs = HashMap::new();
match Network::get_current_or_user_setting_or_default() {
Network::Esmeralda => {
Expand Down Expand Up @@ -155,3 +159,13 @@ impl P2poolStatusMonitor {
self.stats_client.stats().await
}
}

fn determine_squad() -> String {
let cpu_category = hardware_utils::get_cpu_category();
match cpu_category {
hardware_utils::CpuCategory::LowEnd => "cpu_low".to_string(),
hardware_utils::CpuCategory::MidEnd => "cpu_mid".to_string(),
hardware_utils::CpuCategory::HighEnd => "cpu_high".to_string(),
hardware_utils::CpuCategory::Unknown => "default_3".to_string(),
}
}
17 changes: 17 additions & 0 deletions src-tauri/src/utils/hardware_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pub(crate) enum CpuCategory {
Unknown,
LowEnd,
MidEnd,
HighEnd,
}

pub(crate) fn get_cpu_category() -> CpuCategory {
let cores = num_cpus::get_physical();
if cores <= 4 {
CpuCategory::LowEnd
} else if cores <= 8 {
CpuCategory::MidEnd
} else {
CpuCategory::HighEnd
}
}
1 change: 1 addition & 0 deletions src-tauri/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod auto_rollback;
pub mod file_utils;
pub mod hardware_utils;
pub mod logging_utils;
pub mod platform_utils;
pub mod setup_utils;