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
rt: Remove threaded_scheduler()
and basic_scheduler()
#2876
Changes from 7 commits
f3b8d88
692b418
1db81a9
1ecd3bc
ccd426d
019945f
8c2b54a
a1ae97c
430993d
10a2735
0775bd4
9c22b85
45c4977
2178252
97717ac
0a8c401
1f747ca
5c9e72d
53f28e2
456af82
fabd58e
559cf99
8b78067
b982350
112cf71
f9a22e6
3270ce5
3b1eb17
61421e7
130beed
2c9acd1
bc77b12
55ba939
9003409
f8bb6a0
f10eedf
5c5f205
fb155dd
5a94b7e
22f5237
e3f2f86
3ad8f3b
5829241
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,8 @@ use std::sync::Arc; | |
use tokio::{sync::Semaphore, task}; | ||
|
||
fn uncontended(b: &mut Bencher) { | ||
let rt = tokio::runtime::Builder::new() | ||
.core_threads(6) | ||
.threaded_scheduler() | ||
let rt = tokio::runtime::Builder::new_multi_thread() | ||
.worker_threads(6) | ||
.build() | ||
.unwrap(); | ||
|
||
|
@@ -27,9 +26,8 @@ async fn task(s: Arc<Semaphore>) { | |
} | ||
|
||
fn uncontended_concurrent_multi(b: &mut Bencher) { | ||
let rt = tokio::runtime::Builder::new() | ||
.core_threads(6) | ||
.threaded_scheduler() | ||
let rt = tokio::runtime::Builder::new_multi_thread() | ||
.worker_threads(6) | ||
.build() | ||
.unwrap(); | ||
|
||
|
@@ -51,8 +49,8 @@ fn uncontended_concurrent_multi(b: &mut Bencher) { | |
} | ||
|
||
fn uncontended_concurrent_single(b: &mut Bencher) { | ||
let rt = tokio::runtime::Builder::new() | ||
.basic_scheduler() | ||
let rt = tokio::runtime::Builder::new_multi_thread() | ||
.worker_threads(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here is this valid? |
||
.build() | ||
.unwrap(); | ||
|
||
|
@@ -73,9 +71,8 @@ fn uncontended_concurrent_single(b: &mut Bencher) { | |
} | ||
|
||
fn contended_concurrent_multi(b: &mut Bencher) { | ||
let rt = tokio::runtime::Builder::new() | ||
.core_threads(6) | ||
.threaded_scheduler() | ||
let rt = tokio::runtime::Builder::new_multi_thread() | ||
.worker_threads(6) | ||
.build() | ||
.unwrap(); | ||
|
||
|
@@ -97,8 +94,7 @@ fn contended_concurrent_multi(b: &mut Bencher) { | |
} | ||
|
||
fn contended_concurrent_single(b: &mut Bencher) { | ||
let rt = tokio::runtime::Builder::new() | ||
.basic_scheduler() | ||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.build() | ||
.unwrap(); | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
use proc_macro::TokenStream; | ||
use quote::quote; | ||
use std::num::NonZeroUsize; | ||
|
||
#[derive(Clone, Copy, PartialEq)] | ||
enum Runtime { | ||
|
@@ -43,8 +42,8 @@ fn parse_knobs( | |
if rt_threaded { | ||
match &namevalue.lit { | ||
syn::Lit::Int(expr) => { | ||
let num = expr.base10_parse::<NonZeroUsize>().unwrap(); | ||
if num.get() > 1 { | ||
let num = expr.base10_parse::<usize>().unwrap(); | ||
if num > 1 { | ||
runtime = Some(Runtime::Threaded); | ||
} else { | ||
runtime = Some(Runtime::Basic); | ||
|
@@ -77,7 +76,7 @@ fn parse_knobs( | |
} | ||
"max_threads" => match &namevalue.lit { | ||
syn::Lit::Int(expr) => { | ||
let num = expr.base10_parse::<NonZeroUsize>().unwrap(); | ||
let num = expr.base10_parse::<usize>().unwrap(); | ||
|
||
if let Some(v) = core_threads { | ||
if num < v { | ||
|
@@ -128,17 +127,28 @@ fn parse_knobs( | |
} | ||
} | ||
|
||
let mut rt = quote! { tokio::runtime::Builder::new().basic_scheduler() }; | ||
let mut rt = quote! { tokio::runtime::Builder::new_current_thread() }; | ||
|
||
if rt_threaded && (runtime == Some(Runtime::Threaded) || (runtime.is_none() && !is_test)) { | ||
rt = quote! { #rt.threaded_scheduler() }; | ||
} | ||
if let Some(v) = core_threads.map(|v| v.get()) { | ||
rt = quote! { #rt.core_threads(#v) }; | ||
rt = quote! { #rt }; | ||
} | ||
if let Some(v) = max_threads.map(|v| v.get()) { | ||
rt = quote! { #rt.max_threads(#v) }; | ||
|
||
// if let Some(v) = core_threads { | ||
// rt = quote! { #rt.core_threads(#v) }; | ||
// } | ||
|
||
// if let Some(v) = max_threads { | ||
// rt = quote! { #rt.max_threads(#v) }; | ||
// } | ||
|
||
if is_test { | ||
rt = quote! { #rt.core_threads(0) }; | ||
} | ||
|
||
// if is_test && core_threads.is_none() { | ||
// rt = quote! { #rt.core_threads(0) }; | ||
// } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't really care if we merge this, likely going to be rewritten in a follow up PR anyways. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't include #2906, so yes, it will be rewritten by that PR if this is merged first. |
||
|
||
let header = { | ||
if is_test { | ||
quote! { | ||
|
@@ -262,14 +272,13 @@ pub(crate) mod old { | |
Runtime::Threaded | Runtime::Auto => quote! { | ||
#(#attrs)* | ||
#vis #sig { | ||
tokio::runtime::Runtime::new().unwrap().block_on(async { #body }) | ||
tokio::runtime::Runtime::new_multi_thread().unwrap().block_on(async { #body }) | ||
} | ||
}, | ||
Runtime::Basic => quote! { | ||
#(#attrs)* | ||
#vis #sig { | ||
tokio::runtime::Builder::new() | ||
.basic_scheduler() | ||
tokio::runtime::Builder::new_current_thread() | ||
.enable_all() | ||
.build() | ||
.unwrap() | ||
|
@@ -337,15 +346,14 @@ pub(crate) mod old { | |
#[::core::prelude::v1::test] | ||
#(#attrs)* | ||
#vis fn #name() #ret { | ||
tokio::runtime::Runtime::new().unwrap().block_on(async { #body }) | ||
tokio::runtime::Runtime::new_multi_thread().unwrap().block_on(async { #body }) | ||
} | ||
}, | ||
Runtime::Basic | Runtime::Auto => quote! { | ||
#[::core::prelude::v1::test] | ||
#(#attrs)* | ||
#vis fn #name() #ret { | ||
tokio::runtime::Builder::new() | ||
.basic_scheduler() | ||
tokio::runtime::Builder::new_current_thread() | ||
.enable_all() | ||
.build() | ||
.unwrap() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This to me doesn't make sense, why 0? I would imagine we should not allow that unless the multi thread runtime can be a current thread one?