Before we move onto simplifying async files in Rust, it's important to learn in which areas the current implementations need improvement. This might surprise you... 1/9
-
-
Perhaps most surprisingly, async-std/tokio files are *always* slower than std files. They don't improve performance at all, quite the opposite - their only utility is in that they move blocking file I/O onto a dedicated thread pool. But you can also do that yourself anyway. 6/9
Show this thread -
If you do want fast async files, consider using rio by
@sadisticsystems instead. That is really the only way! 7/9 https://github.com/spacejam/rio https://docs.rs/rioShow this thread -
My advice is to avoid async files in Rust altogether because they're inefficient and full of pitfalls (unless you use rio). Use them only in situations when you know what you're doing, if ever. Things might get different in the future, but that is what I advise *today*. 8/9
Show this thread -
If you want to read or write files inside async programs, spawn a blocking task using async_std::task::spawn_blocking() or tokio::task::spawn_blocking() and do synchronous I/O in there. That's the only easy, efficient, and reliable way of doing file I/O today. 9/9pic.twitter.com/Fwg1rCd368
Show this thread
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.