Skip to content
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

Merged
merged 43 commits into from Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f3b8d88
rt: Remove `threaded_scheduler()` and `basic_scheduler()`
LucioFranco Sep 23, 2020
692b418
Fix docs
LucioFranco Sep 25, 2020
1db81a9
Rewrite tokio-macros to new argument format
Darksonn Oct 3, 2020
1ecd3bc
Update tests
Darksonn Oct 3, 2020
ccd426d
Rename to current_thread/threaded and remove max_threads
Darksonn Oct 5, 2020
019945f
Use match in build
Darksonn Oct 6, 2020
8c2b54a
Fix tests
Darksonn Oct 7, 2020
a1ae97c
rustfmt
Darksonn Oct 7, 2020
430993d
clippy
Darksonn Oct 7, 2020
10a2735
Try to fix doctests
Darksonn Oct 7, 2020
0775bd4
test_fail as main -> test
Darksonn Oct 7, 2020
9c22b85
Add `new_multi_thread`/`new_current_thread`/`new_single_thread`
LucioFranco Oct 7, 2020
45c4977
Add runtime builders
LucioFranco Oct 7, 2020
2178252
remove shell runtime
LucioFranco Oct 7, 2020
97717ac
Remove shell runtime test
Darksonn Oct 7, 2020
0a8c401
more feature flag mess
LucioFranco Oct 9, 2020
1f747ca
Merge remote-tracking branch 'origin/master' into lucio/refactor-runt…
carllerche Oct 9, 2020
5c9e72d
fix feature flags
carllerche Oct 9, 2020
53f28e2
remove stray blocking cfgs
carllerche Oct 9, 2020
456af82
fix tests
carllerche Oct 9, 2020
fabd58e
fix feature combo
carllerche Oct 9, 2020
559cf99
fix windows
carllerche Oct 9, 2020
8b78067
fix build
carllerche Oct 10, 2020
b982350
fix docs
carllerche Oct 10, 2020
112cf71
fix docs hopefully
carllerche Oct 10, 2020
f9a22e6
fix loom build
carllerche Oct 10, 2020
3270ce5
fix tokio-util
carllerche Oct 10, 2020
3b1eb17
Merge remote-tracking branch 'origin/macro-new-builder' into lucio/re…
carllerche Oct 12, 2020
61421e7
fix macro doc examples
carllerche Oct 12, 2020
130beed
fix bad type
carllerche Oct 12, 2020
2c9acd1
Update tokio/src/io/driver/mod.rs
carllerche Oct 12, 2020
bc77b12
tests + rename num_workers
carllerche Oct 12, 2020
55ba939
Merge branch 'lucio/refactor-runtime-builder' of https://github.com/t…
carllerche Oct 12, 2020
9003409
tweak ff
carllerche Oct 12, 2020
f8bb6a0
fix a test
carllerche Oct 12, 2020
f10eedf
fix doc links
carllerche Oct 12, 2020
5c5f205
try to fix CI
carllerche Oct 12, 2020
fb155dd
tweak multi-threaded flavor
carllerche Oct 12, 2020
5a94b7e
fix doc test
carllerche Oct 12, 2020
22f5237
update error message
carllerche Oct 12, 2020
e3f2f86
Apply suggestions from code review
LucioFranco Oct 12, 2020
3ad8f3b
address comments
LucioFranco Oct 12, 2020
5829241
Merge branch 'master' of github.com:tokio-rs/tokio into lucio/refacto…
LucioFranco Oct 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Copy link
Member Author

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?

.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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here is this valid?

.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.