Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tokio-rs/tokio
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: tokio-1.32.1
Choose a base ref
...
head repository: tokio-rs/tokio
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: tokio-1.33.0
Choose a head ref
Loading
Showing with 2,290 additions and 1,022 deletions.
  1. +0 −1 .github/workflows/ci.yml
  2. +4 −3 README.md
  3. +1 −1 benches/Cargo.toml
  4. +55 −43 benches/copy.rs
  5. +56 −47 benches/fs.rs
  6. +40 −34 benches/rt_current_thread.rs
  7. +117 −104 benches/rt_multi_threaded.rs
  8. +17 −15 benches/signal.rs
  9. +47 −40 benches/spawn.rs
  10. +145 −123 benches/sync_mpsc.rs
  11. +19 −16 benches/sync_mpsc_oneshot.rs
  12. +47 −33 benches/sync_notify.rs
  13. +91 −70 benches/sync_rwlock.rs
  14. +106 −84 benches/sync_semaphore.rs
  15. +40 −19 benches/sync_watch.rs
  16. +10 −11 benches/time_now.rs
  17. +9 −9 tokio-macros/src/entry.rs
  18. +8 −10 tokio-stream/src/stream_ext/merge.rs
  19. +5 −7 tokio-stream/src/stream_map.rs
  20. +14 −0 tokio-test/CHANGELOG.md
  21. +2 −2 tokio-test/Cargo.toml
  22. +12 −12 tokio-test/src/macros.rs
  23. +28 −0 tokio-util/CHANGELOG.md
  24. +1 −1 tokio-util/Cargo.toml
  25. +2 −0 tokio-util/src/codec/lines_codec.rs
  26. +8 −0 tokio-util/src/io/copy_to_bytes.rs
  27. +19 −1 tokio-util/src/io/sink_writer.rs
  28. +20 −0 tokio-util/src/io/stream_reader.rs
  29. +15 −2 tokio-util/src/io/sync_bridge.rs
  30. +2 −16 tokio-util/src/sync/reusable_box.rs
  31. +12 −0 tokio-util/tests/io_sync_bridge.rs
  32. +44 −47 tokio-util/tests/length_delimited.rs
  33. +5 −2 tokio-util/tests/udp.rs
  34. +83 −0 tokio/CHANGELOG.md
  35. +5 −10 tokio/Cargo.toml
  36. +4 −3 tokio/README.md
  37. +111 −38 tokio/src/fs/file.rs
  38. +4 −4 tokio/src/fs/mocks.rs
  39. +35 −21 tokio/src/io/blocking.rs
  40. +35 −0 tokio/src/io/interest.rs
  41. +75 −0 tokio/src/io/util/mem.rs
  42. +2 −3 tokio/src/net/unix/pipe.rs
  43. +2 −2 tokio/src/net/unix/ucred.rs
  44. +4 −0 tokio/src/process/mod.rs
  45. +8 −8 tokio/src/runtime/context.rs
  46. +13 −6 tokio/src/runtime/handle.rs
  47. +3 −9 tokio/src/runtime/io/scheduled_io.rs
  48. +1 −1 tokio/src/runtime/metrics/runtime.rs
  49. +1 −0 tokio/src/runtime/runtime.rs
  50. +3 −9 tokio/src/runtime/task/core.rs
  51. +8 −0 tokio/src/runtime/task/mod.rs
  52. +41 −32 tokio/src/runtime/task/trace/mod.rs
  53. +23 −10 tokio/src/sync/batch_semaphore.rs
  54. +4 −1 tokio/src/sync/broadcast.rs
  55. +18 −21 tokio/src/sync/mod.rs
  56. +5 −1 tokio/src/sync/mpsc/bounded.rs
  57. +3 −3 tokio/src/sync/mpsc/chan.rs
  58. +13 −1 tokio/src/sync/mutex.rs
  59. +19 −15 tokio/src/sync/notify.rs
  60. +46 −0 tokio/src/sync/once_cell.rs
  61. +8 −0 tokio/src/sync/rwlock.rs
  62. +288 −10 tokio/src/sync/semaphore.rs
  63. +3 −3 tokio/src/sync/tests/loom_list.rs
  64. +180 −34 tokio/src/sync/watch.rs
  65. +1 −0 tokio/src/task/local.rs
  66. +4 −4 tokio/src/task/spawn.rs
  67. +8 −8 tokio/src/time/error.rs
  68. +4 −10 tokio/src/util/cacheline.rs
  69. +57 −0 tokio/tests/dump.rs
  70. +47 −0 tokio/tests/duplex_stream.rs
  71. +35 −0 tokio/tests/fs_file.rs
  72. +26 −1 tokio/tests/rt_threaded.rs
  73. +58 −0 tokio/tests/sync_watch.rs
  74. +1 −1 tokio/tests/time_sleep.rs
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -412,7 +412,6 @@ jobs:
- powerpc-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- arm-linux-androideabi
- mipsel-unknown-linux-musl
steps:
- uses: actions/checkout@v3
- name: Install Rust ${{ env.rust_stable }}
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml:

```toml
[dependencies]
tokio = { version = "1.32.0", features = ["full"] }
tokio = { version = "1.33.0", features = ["full"] }
```
Then, on your main.rs:

@@ -218,16 +218,17 @@ releases are:

* `1.20.x` - LTS release until September 2023. (MSRV 1.49)
* `1.25.x` - LTS release until March 2024. (MSRV 1.49)
* `1.32.x` - LTS release until September 2024 (MSRV 1.63)

Each LTS release will continue to receive backported fixes for at least a year.
If you wish to use a fixed minor release in your project, we recommend that you
use an LTS release.

To use a fixed minor version, you can specify the version with a tilde. For
example, to specify that you wish to use the newest `1.18.x` patch release, you
example, to specify that you wish to use the newest `1.25.x` patch release, you
can use the following dependency specification:
```text
tokio = { version = "~1.18", features = [...] }
tokio = { version = "~1.25", features = [...] }
```

### Previous LTS releases
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ test-util = ["tokio/test-util"]

[dependencies]
tokio = { version = "1.5.0", path = "../tokio", features = ["full"] }
bencher = "0.1.5"
criterion = "0.5.1"
rand = "0.8"
rand_chacha = "0.3"

98 changes: 55 additions & 43 deletions benches/copy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bencher::{benchmark_group, benchmark_main, Bencher};
use criterion::{criterion_group, criterion_main, Criterion};

use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha20Rng;
@@ -174,65 +174,77 @@ fn rt() -> tokio::runtime::Runtime {
.unwrap()
}

fn copy_mem_to_mem(b: &mut Bencher) {
fn copy_mem_to_mem(c: &mut Criterion) {
let rt = rt();

b.iter(|| {
let task = || async {
let mut source = repeat(0).take(SOURCE_SIZE);
let mut dest = Vec::new();
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})
c.bench_function("copy_mem_to_mem", |b| {
b.iter(|| {
let task = || async {
let mut source = repeat(0).take(SOURCE_SIZE);
let mut dest = Vec::new();
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})
});
}

fn copy_mem_to_slow_hdd(b: &mut Bencher) {
fn copy_mem_to_slow_hdd(c: &mut Criterion) {
let rt = rt();

b.iter(|| {
let task = || async {
let mut source = repeat(0).take(SOURCE_SIZE);
let mut dest = SlowHddWriter::new(WRITE_SERVICE_PERIOD, WRITE_BUFFER);
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})
c.bench_function("copy_mem_to_slow_hdd", |b| {
b.iter(|| {
let task = || async {
let mut source = repeat(0).take(SOURCE_SIZE);
let mut dest = SlowHddWriter::new(WRITE_SERVICE_PERIOD, WRITE_BUFFER);
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})
});
}

fn copy_chunk_to_mem(b: &mut Bencher) {
fn copy_chunk_to_mem(c: &mut Criterion) {
let rt = rt();
b.iter(|| {
let task = || async {
let mut source = ChunkReader::new(CHUNK_SIZE, READ_SERVICE_PERIOD).take(SOURCE_SIZE);
let mut dest = Vec::new();
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})

c.bench_function("copy_chunk_to_mem", |b| {
b.iter(|| {
let task = || async {
let mut source =
ChunkReader::new(CHUNK_SIZE, READ_SERVICE_PERIOD).take(SOURCE_SIZE);
let mut dest = Vec::new();
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})
});
}

fn copy_chunk_to_slow_hdd(b: &mut Bencher) {
fn copy_chunk_to_slow_hdd(c: &mut Criterion) {
let rt = rt();
b.iter(|| {
let task = || async {
let mut source = ChunkReader::new(CHUNK_SIZE, READ_SERVICE_PERIOD).take(SOURCE_SIZE);
let mut dest = SlowHddWriter::new(WRITE_SERVICE_PERIOD, WRITE_BUFFER);
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})

c.bench_function("copy_chunk_to_slow_hdd", |b| {
b.iter(|| {
let task = || async {
let mut source =
ChunkReader::new(CHUNK_SIZE, READ_SERVICE_PERIOD).take(SOURCE_SIZE);
let mut dest = SlowHddWriter::new(WRITE_SERVICE_PERIOD, WRITE_BUFFER);
copy(&mut source, &mut dest).await.unwrap();
};

rt.block_on(task());
})
});
}

benchmark_group!(
criterion_group!(
copy_bench,
copy_mem_to_mem,
copy_mem_to_slow_hdd,
copy_chunk_to_mem,
copy_chunk_to_slow_hdd,
);
benchmark_main!(copy_bench);
criterion_main!(copy_bench);
103 changes: 56 additions & 47 deletions benches/fs.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ use tokio::fs::File;
use tokio::io::AsyncReadExt;
use tokio_util::codec::{BytesCodec, FramedRead /*FramedWrite*/};

use bencher::{benchmark_group, benchmark_main, Bencher};
use criterion::{criterion_group, criterion_main, Criterion};

use std::fs::File as StdFile;
use std::io::Read as StdRead;
@@ -23,81 +23,90 @@ const BLOCK_COUNT: usize = 1_000;
const BUFFER_SIZE: usize = 4096;
const DEV_ZERO: &str = "/dev/zero";

fn async_read_codec(b: &mut Bencher) {
fn async_read_codec(c: &mut Criterion) {
let rt = rt();

b.iter(|| {
let task = || async {
let file = File::open(DEV_ZERO).await.unwrap();
let mut input_stream = FramedRead::with_capacity(file, BytesCodec::new(), BUFFER_SIZE);
c.bench_function("async_read_codec", |b| {
b.iter(|| {
let task = || async {
let file = File::open(DEV_ZERO).await.unwrap();
let mut input_stream =
FramedRead::with_capacity(file, BytesCodec::new(), BUFFER_SIZE);

for _i in 0..BLOCK_COUNT {
let _bytes = input_stream.next().await.unwrap();
}
};
for _i in 0..BLOCK_COUNT {
let _bytes = input_stream.next().await.unwrap();
}
};

rt.block_on(task());
rt.block_on(task());
})
});
}

fn async_read_buf(b: &mut Bencher) {
fn async_read_buf(c: &mut Criterion) {
let rt = rt();

b.iter(|| {
let task = || async {
let mut file = File::open(DEV_ZERO).await.unwrap();
let mut buffer = [0u8; BUFFER_SIZE];

for _i in 0..BLOCK_COUNT {
let count = file.read(&mut buffer).await.unwrap();
if count == 0 {
break;
c.bench_function("async_read_buf", |b| {
b.iter(|| {
let task = || async {
let mut file = File::open(DEV_ZERO).await.unwrap();
let mut buffer = [0u8; BUFFER_SIZE];

for _i in 0..BLOCK_COUNT {
let count = file.read(&mut buffer).await.unwrap();
if count == 0 {
break;
}
}
}
};
};

rt.block_on(task());
rt.block_on(task());
});
});
}

fn async_read_std_file(b: &mut Bencher) {
fn async_read_std_file(c: &mut Criterion) {
let rt = rt();

let task = || async {
let mut file = tokio::task::block_in_place(|| Box::pin(StdFile::open(DEV_ZERO).unwrap()));
c.bench_function("async_read_std_file", |b| {
b.iter(|| {
let task = || async {
let mut file =
tokio::task::block_in_place(|| Box::pin(StdFile::open(DEV_ZERO).unwrap()));

for _i in 0..BLOCK_COUNT {
let mut buffer = [0u8; BUFFER_SIZE];
let mut file_ref = file.as_mut();
for _i in 0..BLOCK_COUNT {
let mut buffer = [0u8; BUFFER_SIZE];
let mut file_ref = file.as_mut();

tokio::task::block_in_place(move || {
file_ref.read_exact(&mut buffer).unwrap();
});
}
};
tokio::task::block_in_place(move || {
file_ref.read_exact(&mut buffer).unwrap();
});
}
};

b.iter(|| {
rt.block_on(task());
rt.block_on(task());
});
});
}

fn sync_read(b: &mut Bencher) {
b.iter(|| {
let mut file = StdFile::open(DEV_ZERO).unwrap();
let mut buffer = [0u8; BUFFER_SIZE];
fn sync_read(c: &mut Criterion) {
c.bench_function("sync_read", |b| {
b.iter(|| {
let mut file = StdFile::open(DEV_ZERO).unwrap();
let mut buffer = [0u8; BUFFER_SIZE];

for _i in 0..BLOCK_COUNT {
file.read_exact(&mut buffer).unwrap();
}
for _i in 0..BLOCK_COUNT {
file.read_exact(&mut buffer).unwrap();
}
})
});
}

benchmark_group!(
criterion_group!(
file,
async_read_std_file,
async_read_buf,
async_read_codec,
sync_read
);

benchmark_main!(file);
criterion_main!(file);
Loading