Skip to content

Commit ce98532

Browse files
authored
feat(l1,l2): name rayon threads for easier debugging (#5269)
**Motivation** Rayon currently inherits the name of the thread that calls it first, which creates confusion when, for example, one tries to see which threads incur the most contention. **Description** Initialize the global thread pool on init to ensure the Rayon workers each have a unique name.
1 parent 4e239ae commit ce98532

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/ethrex/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ serde_json.workspace = true
4343
tokio = { workspace = true, features = ["full"] }
4444
anyhow = "1.0.86"
4545
rand = "0.8.5"
46+
rayon.workspace = true
4647
local-ip-address = "0.6"
4748
tokio-util.workspace = true
4849
lazy_static.workspace = true

cmd/ethrex/ethrex.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ async fn server_shutdown(
4949
async fn main() -> eyre::Result<()> {
5050
let CLI { opts, command } = CLI::parse();
5151

52+
rayon::ThreadPoolBuilder::default()
53+
.thread_name(|i| format!("rayon-worker-{i}"))
54+
.build_global()
55+
.expect("failed to build rayon threadpool");
56+
5257
if let Some(subcommand) = command {
5358
return subcommand.run(&opts).await;
5459
}

0 commit comments

Comments
 (0)