tokio icon indicating copy to clipboard operation
tokio copied to clipboard

Document performance considerations tokio::fs

Open Darksonn opened this issue 5 years ago • 5 comments

All file operations are currently spawned on a thread pool with spawn_blocking which is rather expensive. We should document these performance considerations a lot better than we are doing now.

Refs: #1976, #1844

Darksonn avatar Jul 25 '20 10:07 Darksonn

Is it possible to use block_in_place in their implementation? I suppose there's still some value in using tokio-fs, as it might get io_uring support in some nebulous future.

lnicola avatar Jul 25 '20 10:07 lnicola

Using block_in_place is a massive footgun and will break any code that uses things such as select!, join! or join_all.

Darksonn avatar Jul 25 '20 10:07 Darksonn

We likely want to create a section on the website for this. I am happy to contribute to this one.

LucioFranco avatar Jul 27 '20 16:07 LucioFranco

I opened an issue on the website repository too.

Darksonn avatar Jul 27 '20 16:07 Darksonn

It seems like this issue is no longer relevant (i think?), as the docs for fs mention that blocking tasks are spawned for the operations

Lol3rrr avatar Sep 11 '23 20:09 Lol3rrr

Using block_in_place is a massive footgun and will break any code that uses things such as select!, join! or join_all.

What about having another API that specifically uses block_in_place, that users can use if they chose to, and that way we will both prevent having a breaking-change that breaks other uses, and both possibly let users benefit from performance improvements

PaulDotSH avatar Jul 16 '24 23:07 PaulDotSH

That seems like a thing you can trivially do yourself with block_in_place and std::fs::File.

sfackler avatar Jul 17 '24 00:07 sfackler

Closing as fixed by #6467.

Tokio will not encourage use of block_in_place by providing such APIs.

Darksonn avatar Jul 17 '24 10:07 Darksonn