diff --git a/Cargo.lock b/Cargo.lock index 36c7c044760..8f0eaf96a97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8229,6 +8229,7 @@ dependencies = [ "serde_json", "smallvec", "thiserror 2.0.17", + "thread-priority", "tokio", "tracing", ] @@ -12490,6 +12491,20 @@ dependencies = [ "syn 2.0.111", ] +[[package]] +name = "thread-priority" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2210811179577da3d54eb69ab0b50490ee40491a25d95b8c6011ba40771cb721" +dependencies = [ + "bitflags 2.10.0", + "cfg-if", + "libc", + "log", + "rustversion", + "windows 0.61.3", +] + [[package]] name = "thread_local" version = "1.1.9" diff --git a/Cargo.toml b/Cargo.toml index 5bf6c208590..db2a634d8a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -534,22 +534,24 @@ op-alloy-rpc-jsonrpsee = { version = "0.22.4", default-features = false } op-alloy-flz = { version = "0.13.1", default-features = false } # misc -either = { version = "1.15.0", default-features = false } -arrayvec = { version = "0.7.6", default-features = false } aquamarine = "0.6" +arrayvec = { version = "0.7.6", default-features = false } auto_impl = "1" backon = { version = "1.2", default-features = false, features = ["std-blocking-sleep", "tokio-sleep"] } bincode = "1.3" bitflags = "2.4" boyer-moore-magiclen = "0.2.16" -bytes = { version = "1.5", default-features = false } brotli = "8" +byteorder = "1" +bytes = { version = "1.5", default-features = false } cfg-if = "1.0" +chrono = "0.4.41" clap = "4" dashmap = "6.0" derive_more = { version = "2", default-features = false, features = ["full"] } dirs-next = "2.0.0" dyn-clone = "1.0.17" +either = { version = "1.15.0", default-features = false } eyre = "0.6" fdlimit = "0.3.0" humantime = "2.1" @@ -557,6 +559,8 @@ humantime-serde = "1.1" itertools = { version = "0.14", default-features = false } linked_hash_set = "0.1" lz4 = "1.28.1" +mini-moka = "0.10" +miniz_oxide = { version = "0.8.4", default-features = false } modular-bitfield = "0.11.2" notify = { version = "8.0.0", default-features = false, features = ["macos_fsevent"] } nybbles = { version = "0.4.2", default-features = false } @@ -577,17 +581,14 @@ smallvec = "1" strum = { version = "0.27", default-features = false } strum_macros = "0.27" syn = "2.0" -thiserror = { version = "2.0.0", default-features = false } tar = "0.4.44" +tar-no-std = { version = "0.3.2", default-features = false } +thiserror = { version = "2.0.0", default-features = false } +thread-priority = "3" tracing = { version = "0.1.0", default-features = false } tracing-appender = "0.2" url = { version = "2.3", default-features = false } zstd = "0.13" -byteorder = "1" -mini-moka = "0.10" -tar-no-std = { version = "0.3.2", default-features = false } -miniz_oxide = { version = "0.8.4", default-features = false } -chrono = "0.4.41" # metrics metrics = "0.24.0" diff --git a/crates/engine/tree/Cargo.toml b/crates/engine/tree/Cargo.toml index ba99898a842..e30c0b24dd5 100644 --- a/crates/engine/tree/Cargo.toml +++ b/crates/engine/tree/Cargo.toml @@ -58,13 +58,14 @@ metrics.workspace = true reth-metrics = { workspace = true, features = ["common"] } # misc +crossbeam-channel.workspace = true dashmap.workspace = true -schnellru.workspace = true -rayon.workspace = true -tracing.workspace = true derive_more.workspace = true parking_lot.workspace = true -crossbeam-channel.workspace = true +rayon.workspace = true +schnellru.workspace = true +thread-priority.workspace = true +tracing.workspace = true # optional deps for test-utils reth-prune-types = { workspace = true, optional = true } diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 9d8d2df82fb..64bc50b743c 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -45,6 +45,7 @@ use std::{ }, time::Instant, }; +use thread_priority::{ThreadBuilderExt, ThreadPriority}; use tokio::sync::{ mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}, oneshot::{self, error::TryRecvError}, @@ -409,7 +410,15 @@ where evm_config, ); let incoming = task.incoming_tx.clone(); - std::thread::Builder::new().name("Engine Task".to_string()).spawn(|| task.run()).unwrap(); + std::thread::Builder::new() + .name("Engine Task".to_string()) + .spawn_with_priority(ThreadPriority::Max, |result| { + if let Err(err) = result { + warn!(target: "engine::tree", ?err, "Failed to set thread priority"); + } + task.run() + }) + .unwrap(); (incoming, outgoing) }