Skip to content

Commit

Permalink
rt: Remove threaded_scheduler() and basic_scheduler() (#2876)
Browse files Browse the repository at this point in the history
Co-authored-by: Alice Ryhl <alice@ryhl.io>
Co-authored-by: Carl Lerche <me@carllerche.com>
  • Loading branch information
3 people committed Oct 12, 2020
1 parent 0893841 commit 8880222
Show file tree
Hide file tree
Showing 90 changed files with 1,469 additions and 1,687 deletions.
37 changes: 12 additions & 25 deletions benches/mpsc.rs
Expand Up @@ -4,6 +4,13 @@ use tokio::sync::mpsc;
type Medium = [usize; 64];
type Large = [Medium; 64];

fn rt() -> tokio::runtime::Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(6)
.build()
.unwrap()
}

fn create_1_medium(b: &mut Bencher) {
b.iter(|| {
black_box(&mpsc::channel::<Medium>(1));
Expand Down Expand Up @@ -43,11 +50,7 @@ fn send_large(b: &mut Bencher) {
}

fn contention_bounded(b: &mut Bencher) {
let rt = tokio::runtime::Builder::new()
.core_threads(6)
.threaded_scheduler()
.build()
.unwrap();
let rt = rt();

b.iter(|| {
rt.block_on(async move {
Expand All @@ -70,11 +73,7 @@ fn contention_bounded(b: &mut Bencher) {
}

fn contention_bounded_full(b: &mut Bencher) {
let rt = tokio::runtime::Builder::new()
.core_threads(6)
.threaded_scheduler()
.build()
.unwrap();
let rt = rt();

b.iter(|| {
rt.block_on(async move {
Expand All @@ -97,11 +96,7 @@ fn contention_bounded_full(b: &mut Bencher) {
}

fn contention_unbounded(b: &mut Bencher) {
let rt = tokio::runtime::Builder::new()
.core_threads(6)
.threaded_scheduler()
.build()
.unwrap();
let rt = rt();

b.iter(|| {
rt.block_on(async move {
Expand All @@ -124,11 +119,7 @@ fn contention_unbounded(b: &mut Bencher) {
}

fn uncontented_bounded(b: &mut Bencher) {
let rt = tokio::runtime::Builder::new()
.core_threads(6)
.threaded_scheduler()
.build()
.unwrap();
let rt = rt();

b.iter(|| {
rt.block_on(async move {
Expand All @@ -146,11 +137,7 @@ fn uncontented_bounded(b: &mut Bencher) {
}

fn uncontented_unbounded(b: &mut Bencher) {
let rt = tokio::runtime::Builder::new()
.core_threads(6)
.threaded_scheduler()
.build()
.unwrap();
let rt = rt();

b.iter(|| {
rt.block_on(async move {
Expand Down
5 changes: 2 additions & 3 deletions benches/scheduler.rs
Expand Up @@ -139,9 +139,8 @@ fn chained_spawn(b: &mut Bencher) {
}

fn rt() -> Runtime {
runtime::Builder::new()
.threaded_scheduler()
.core_threads(4)
runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable_all()
.build()
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions benches/signal.rs
Expand Up @@ -45,9 +45,9 @@ fn many_signals(bench: &mut Bencher) {
let num_signals = 10;
let (tx, mut rx) = mpsc::channel(num_signals);

let rt = runtime::Builder::new()
let rt = runtime::Builder::new_multi_thread()
// Intentionally single threaded to measure delays in propagating wakes
.basic_scheduler()
.worker_threads(0)
.enable_all()
.build()
.unwrap();
Expand Down
14 changes: 4 additions & 10 deletions benches/spawn.rs
Expand Up @@ -10,8 +10,7 @@ async fn work() -> usize {
}

fn basic_scheduler_local_spawn(bench: &mut Bencher) {
let runtime = tokio::runtime::Builder::new()
.basic_scheduler()
let runtime = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
runtime.block_on(async {
Expand All @@ -23,8 +22,7 @@ fn basic_scheduler_local_spawn(bench: &mut Bencher) {
}

fn threaded_scheduler_local_spawn(bench: &mut Bencher) {
let runtime = tokio::runtime::Builder::new()
.threaded_scheduler()
let runtime = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
runtime.block_on(async {
Expand All @@ -36,8 +34,7 @@ fn threaded_scheduler_local_spawn(bench: &mut Bencher) {
}

fn basic_scheduler_remote_spawn(bench: &mut Bencher) {
let runtime = tokio::runtime::Builder::new()
.basic_scheduler()
let runtime = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();

Expand All @@ -48,10 +45,7 @@ fn basic_scheduler_remote_spawn(bench: &mut Bencher) {
}

fn threaded_scheduler_remote_spawn(bench: &mut Bencher) {
let runtime = tokio::runtime::Builder::new()
.threaded_scheduler()
.build()
.unwrap();
let runtime = tokio::runtime::Builder::new_multi_thread().build().unwrap();

bench.iter(|| {
let h = runtime.spawn(work());
Expand Down
21 changes: 8 additions & 13 deletions benches/sync_rwlock.rs
Expand Up @@ -3,9 +3,8 @@ use std::sync::Arc;
use tokio::{sync::RwLock, task};

fn read_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();

Expand All @@ -22,9 +21,8 @@ fn read_uncontended(b: &mut Bencher) {
}

fn read_concurrent_uncontended_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();

Expand All @@ -51,8 +49,7 @@ fn read_concurrent_uncontended_multi(b: &mut Bencher) {
}

fn read_concurrent_uncontended(b: &mut Bencher) {
let rt = tokio::runtime::Builder::new()
.basic_scheduler()
let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();

Expand All @@ -78,9 +75,8 @@ fn read_concurrent_uncontended(b: &mut Bencher) {
}

fn read_concurrent_contended_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();

Expand Down Expand Up @@ -108,8 +104,7 @@ fn read_concurrent_contended_multi(b: &mut Bencher) {
}

fn read_concurrent_contended(b: &mut Bencher) {
let rt = tokio::runtime::Builder::new()
.basic_scheduler()
let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();

Expand Down
22 changes: 9 additions & 13 deletions benches/sync_semaphore.rs
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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)
.build()
.unwrap();

Expand All @@ -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();

Expand All @@ -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();

Expand Down
1 change: 1 addition & 0 deletions tests-build/Cargo.toml
Expand Up @@ -7,6 +7,7 @@ publish = false

[features]
full = ["tokio/full"]
rt-core = ["tokio/rt-core", "tokio/macros"]

[dependencies]
tokio = { path = "../tokio", optional = true }
Expand Down
6 changes: 6 additions & 0 deletions tests-build/tests/fail/macros_core_no_default.rs
@@ -0,0 +1,6 @@
use tests_build::tokio;

#[tokio::main]
async fn my_fn() {}

fn main() {}
7 changes: 7 additions & 0 deletions tests-build/tests/fail/macros_core_no_default.stderr
@@ -0,0 +1,7 @@
error: The default runtime flavor is `multi_thread`, but the `rt-threaded` feature is disabled.
--> $DIR/macros_core_no_default.rs:3:1
|
3 | #[tokio::main]
| ^^^^^^^^^^^^^^
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 2 additions & 2 deletions tests-build/tests/fail/macros_invalid_input.stderr
Expand Up @@ -4,7 +4,7 @@ error: the async keyword is missing from the function declaration
4 | fn main_is_not_async() {}
| ^^

error: Unknown attribute foo is specified; expected `basic_scheduler` or `threaded_scheduler`
error: Unknown attribute foo is specified; expected one of: `flavor`, `worker_threads`
--> $DIR/macros_invalid_input.rs:6:15
|
6 | #[tokio::main(foo)]
Expand All @@ -28,7 +28,7 @@ error: the test function cannot accept arguments
16 | async fn test_fn_has_args(_x: u8) {}
| ^^^^^^

error: Unknown attribute foo is specified; expected `basic_scheduler` or `threaded_scheduler`
error: Unknown attribute foo is specified; expected one of: `flavor`, `worker_threads`
--> $DIR/macros_invalid_input.rs:18:15
|
18 | #[tokio::test(foo)]
Expand Down
5 changes: 4 additions & 1 deletion tests-build/tests/macros.rs
@@ -1,9 +1,12 @@
#[test]
fn compile_fail() {
fn compile_fail_full() {
let t = trybuild::TestCases::new();

#[cfg(feature = "full")]
t.compile_fail("tests/fail/macros_invalid_input.rs");

#[cfg(all(feature = "rt-core", not(feature = "full")))]
t.compile_fail("tests/fail/macros_core_no_default.rs");

drop(t);
}
21 changes: 9 additions & 12 deletions tests-integration/tests/macros_main.rs
@@ -1,4 +1,4 @@
#![cfg(feature = "macros")]
#![cfg(all(feature = "macros", feature = "rt-core"))]

#[tokio::main]
async fn basic_main() -> usize {
Expand All @@ -10,18 +10,15 @@ async fn generic_fun<T: Default>() -> T {
T::default()
}

#[cfg(feature = "rt-core")]
mod spawn {
#[tokio::main]
async fn spawning() -> usize {
let join = tokio::spawn(async { 1 });
join.await.unwrap()
}
#[tokio::main]
async fn spawning() -> usize {
let join = tokio::spawn(async { 1 });
join.await.unwrap()
}

#[test]
fn main_with_spawn() {
assert_eq!(1, spawning());
}
#[test]
fn main_with_spawn() {
assert_eq!(1, spawning());
}

#[test]
Expand Down
32 changes: 0 additions & 32 deletions tests-integration/tests/rt_shell.rs

This file was deleted.

0 comments on commit 8880222

Please sign in to comment.