Skip to content

Commit

Permalink
io: increase MAX_BUF from 16384 to 2MiB (#5397)
Browse files Browse the repository at this point in the history
  • Loading branch information
brxken128 authored Jan 27, 2023
1 parent c90757f commit fe2dcb9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tokio/src/fs/file/tests.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit fe2dcb9

Please sign in to comment.