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

io: increase MAX_BUF from 16384 to 2MiB #5397

Merged
merged 2 commits into from Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions tokio/src/fs/file/tests.rs
Expand Up @@ -231,12 +231,12 @@ fn flush_while_idle() {
#[cfg_attr(miri, ignore)] // takes a really long time with miri
fn read_with_buffer_larger_than_max() {
// Chunks
let chunk_a = 16 * 1024;
let chunk_a = crate::io::blocking::MAX_BUF;
let chunk_b = chunk_a * 2;
let chunk_c = chunk_a * 3;
let chunk_d = chunk_a * 4;

assert_eq!(chunk_d / 1024, 64);
assert_eq!(chunk_d / 1024 / 1024, 8);

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

assert_eq!(chunk_d / 1024, 64);
assert_eq!(chunk_d / 1024 / 1024, 8);

let mut data = vec![];
for i in 0..(chunk_d - 1) {
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/blocking.rs
Expand Up @@ -26,7 +26,7 @@ pub(crate) struct Buf {
pos: usize,
}

pub(crate) const MAX_BUF: usize = 16 * 1024;
pub(crate) const MAX_BUF: usize = 2 * 1024 * 1024;

#[derive(Debug)]
enum State<T> {
Expand Down
3 changes: 1 addition & 2 deletions tokio/src/io/stdio_common.rs
Expand Up @@ -108,14 +108,13 @@ where
#[cfg(test)]
#[cfg(not(loom))]
mod tests {
use crate::io::blocking::MAX_BUF;
use crate::io::AsyncWriteExt;
use std::io;
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;

const MAX_BUF: usize = 16 * 1024;

struct TextMockWriter;

impl crate::io::AsyncWrite for TextMockWriter {
Expand Down