From 725c6c6bfdac732b15d19dd4bc381b67e1bb3a5f Mon Sep 17 00:00:00 2001 From: June <61218022+itsjunetime@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:54:55 -0600 Subject: [PATCH] Simpler tokio runtime (#140) * Simpler tokio runtime; 3 threads and no io driver * switch benches over to other runtime --- CHANGELOG.md | 2 ++ benches/rendering.rs | 7 ++++++- src/main.rs | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aeb8de4..d6049e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Unreleased +- Added windows support! (thank you to [@jarjk](https://github.com/jarjk) for helping out!) - Added keybindings (`0`/`$`) to scroll to left or right side of zoomed-in image ([#131](https://github.com/itsjunetime/tdf/pull/131), thank you [@IshDeshpa](https://github.com/IshDeshpa)!) +- (Internal) decreased runtime footprint of tokio runtime # v0.5.0 diff --git a/benches/rendering.rs b/benches/rendering.rs index bbdc938..0927279 100644 --- a/benches/rendering.rs +++ b/benches/rendering.rs @@ -34,7 +34,12 @@ fn for_all_combos( name: &'static str, mut f: impl FnMut(&Runtime, BenchmarkId, &'static str, ProtocolType) ) { - let rt = tokio::runtime::Runtime::new().unwrap(); + let rt = tokio::runtime::Builder::new_multi_thread() + .worker_threads(3) + .enable_time() + .build() + .unwrap(); + for proto in PROTOS { for file in FILES { f( diff --git a/src/main.rs b/src/main.rs index 19f9503..c57df94 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,11 +70,18 @@ fn reset_term() { ); } -#[tokio::main] -async fn main() -> Result<(), WrappedErr> { - let result = inner_main().await; - reset_term(); - result +fn main() -> Result<(), WrappedErr> { + let rt = tokio::runtime::Builder::new_multi_thread() + .worker_threads(3) + .enable_time() + .build() + .unwrap(); + + rt.block_on(async move { + let result = inner_main().await; + reset_term(); + result + }) } async fn inner_main() -> Result<(), WrappedErr> {