Skip to content

Commit fe2dcb9

Browse files
authored
io: increase MAX_BUF from 16384 to 2MiB (#5397)
1 parent c90757f commit fe2dcb9

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

tokio/src/fs/file/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ fn flush_while_idle() {
231231
#[cfg_attr(miri, ignore)] // takes a really long time with miri
232232
fn read_with_buffer_larger_than_max() {
233233
// Chunks
234-
let chunk_a = 16 * 1024;
234+
let chunk_a = crate::io::blocking::MAX_BUF;
235235
let chunk_b = chunk_a * 2;
236236
let chunk_c = chunk_a * 3;
237237
let chunk_d = chunk_a * 4;
238238

239-
assert_eq!(chunk_d / 1024, 64);
239+
assert_eq!(chunk_d / 1024 / 1024, 8);
240240

241241
let mut data = vec![];
242242
for i in 0..(chunk_d - 1) {
@@ -303,12 +303,12 @@ fn read_with_buffer_larger_than_max() {
303303
#[cfg_attr(miri, ignore)] // takes a really long time with miri
304304
fn write_with_buffer_larger_than_max() {
305305
// Chunks
306-
let chunk_a = 16 * 1024;
306+
let chunk_a = crate::io::blocking::MAX_BUF;
307307
let chunk_b = chunk_a * 2;
308308
let chunk_c = chunk_a * 3;
309309
let chunk_d = chunk_a * 4;
310310

311-
assert_eq!(chunk_d / 1024, 64);
311+
assert_eq!(chunk_d / 1024 / 1024, 8);
312312

313313
let mut data = vec![];
314314
for i in 0..(chunk_d - 1) {

tokio/src/io/blocking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) struct Buf {
2626
pos: usize,
2727
}
2828

29-
pub(crate) const MAX_BUF: usize = 16 * 1024;
29+
pub(crate) const MAX_BUF: usize = 2 * 1024 * 1024;
3030

3131
#[derive(Debug)]
3232
enum State<T> {

tokio/src/io/stdio_common.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,13 @@ where
108108
#[cfg(test)]
109109
#[cfg(not(loom))]
110110
mod tests {
111+
use crate::io::blocking::MAX_BUF;
111112
use crate::io::AsyncWriteExt;
112113
use std::io;
113114
use std::pin::Pin;
114115
use std::task::Context;
115116
use std::task::Poll;
116117

117-
const MAX_BUF: usize = 16 * 1024;
118-
119118
struct TextMockWriter;
120119

121120
impl crate::io::AsyncWrite for TextMockWriter {

0 commit comments

Comments
 (0)