Skip to content
Closed
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
28 changes: 28 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ serde = { version = "1.0.192", features = ["derive"] }
serde_json = { version = "1.0.108", features = ["preserve_order"] }
url = "2.4.1"
sha256 = "1.4.0"
tokio = { version = "1", features = ["macros", "rt"] }
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread"] }
tokio-tar = "0.3.1"
md5 = "0.7.0"
base64 = "0.21.0"
Expand All @@ -46,6 +46,7 @@ sysinfo = { version = "0.33.1", features = ["serde"] }
indicatif = "0.17.8"
console = "0.15.8"
async-trait = "0.1.82"
core_affinity = "0.8.3"

[dev-dependencies]
temp-env = { version = "0.3.6", features = ["async_closure"] }
Expand Down
25 changes: 23 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod run;
mod setup;

use console::style;
use core_affinity::CoreId;
use lazy_static::lazy_static;
use local_logger::clean_logger;
use prelude::*;
Expand All @@ -27,8 +28,28 @@ lazy_static! {
format!("{VALGRIND_CODSPEED_BASE_VERSION}-0codspeed1");
}

#[tokio::main(flavor = "current_thread")]
async fn main() {
fn main() -> anyhow::Result<()> {
let runtime = tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.on_thread_start(|| {
// Core 0 is also responsible for interrupts and other system tasks. But
// this is fine, as we're not executing performance-critical code.
if !core_affinity::set_for_current(CoreId { id: 0 }) {
panic!("failed to pin worker thread to core 0");
}
})
.enable_all()
.build()?;

// NOTE: The code above doesn't set the core affinity for the main thread. We should avoid doing so, as
// the affinity is passed down to child threads/processes.

let _guard = runtime.enter();
runtime.block_on(real_main());
Ok(())
}

async fn real_main() {
let res = crate::app::run().await;
if let Err(err) = res {
for cause in err.chain() {
Expand Down
Loading