Tokio: File operations don't use the whole buffer

Created on 17 Dec 2019  路  2Comments  路  Source: tokio-rs/tokio

tokio 0.2.4, see https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/io/blocking.rs#L29.

There's an unexpected 16 KB limit for IO operations, e.g. this will print 16384. It seems intended, but it's somewhat confusing.

async fn run() -> Result<(), std::io::Error> {
    let mut file = File::open("x.mkv").await?;
    let mut buf = [0u8; 32768];
    let size = file.read(&mut buf).await?;
    println!("{}", size);
    Ok(())
}
A-tokio C-bug E-help-wanted E-medium M-fs T-performance

Most helpful comment

Looking at your original issue, I think we can support better performance by working directly with Bytes. In that case, we can avoid the copying and instead send the bytes handle to the remote thread.

All 2 comments

Looking at your original issue, I think we can support better performance by working directly with Bytes. In that case, we can avoid the copying and instead send the bytes handle to the remote thread.

I鈥檇 like to work on this. Some guidance would be appreciated.
Especially around

I think we can support better performance by working directly with Bytes

Was this page helpful?
0 / 5 - 0 ratings