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

add new method for io::copy that take buffer size #3722

Open
cssivision opened this issue Apr 23, 2021 · 5 comments
Open

add new method for io::copy that take buffer size #3722

cssivision opened this issue Apr 23, 2021 · 5 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-io Module: tokio/io

Comments

@cssivision
Copy link
Contributor

cssivision commented Apr 23, 2021

as discussing in #3572, add a new issue to trace it.

currently io::copy take 2k bytes buffer, there isn't any way of making the buffer bigger now. maybe we can add a new method to take byffer size as input.

@cssivision cssivision added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Apr 23, 2021
@cssivision cssivision changed the title extend io::copy to take buffer size add new method for io::copy that take buffer size Apr 23, 2021
@Darksonn Darksonn added the M-io Module: tokio/io label Apr 23, 2021
@dyxushuai
Copy link

In addition, maybe the buffer can be inited by MaybeUninit for some performance issues

@taiki-e
Copy link
Member

taiki-e commented Apr 30, 2021

How is this different from copy_buf + BufReader?
When I look at #3726's implementation, I feel it does the equivalent thing.

let mut reader = BufReader::with_capacity(size, reader);
copy_buf(&mut reader, &mut writer).await?;

@Darksonn
Copy link
Contributor

Huh, that's an interesting point. It could even make sense to entirely replace the implementation to use that. I'll have to think about this.

@Darksonn
Copy link
Contributor

Darksonn commented Apr 30, 2021

As far as I can tell, using BufReader like this would leave #3694 open, and it doesn't seem like we can fix that issue while also using that implementation unless we add a new method to AsyncBufRead.

@Hanaasagi
Copy link

When I use copy_bidirectional function, I find that the buf_size is 8k and cannot be adjusted. 👀

impl CopyBuffer {
pub(super) fn new() -> Self {
Self {
read_done: false,
need_flush: false,
pos: 0,
cap: 0,
amt: 0,
buf: vec![0; super::DEFAULT_BUF_SIZE].into_boxed_slice(),
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-io Module: tokio/io
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants