Skip to content

Streaming base64 #4944

Answered by Darksonn
LevitatingOrange asked this question in Q&A
Discussion options

You must be logged in to vote

The overhead you are seeing is probably entirely the fault of file IO being slow in async/await. Every single IO operation involves a spawn_blocking roundtrip, and if you are sending only 128 bytes per call, you have a lot of them.

Async/await is good for network IO, not so much for file IO.

There are various other inefficiencies (e.g. you can avoid a copy by using tokio::io::copy_buf instead), but I would think that this pales in comparison to the overhead involved with file IO. A buffered writer would probably help quite a lot, but only because it decreases the number of file operations by increasing the size of each one.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LevitatingOrange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants