You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Awful performance due to reading bytes 1 at a time #819
I'm using fabric to send a stream of binary data (can be GBs in size). The invoke code reads the data 1 byte at a time. This seems to result in an upload speed maxing out at 10KB/s, which would take days to upload the necessary data.
Perhaps there can be a way to customise the chunk size for reading?
I easily achieved over 2MB/s after changing that number (atleast 200x improvement, probably more if I had a faster internet connection):
--- a/invoke/runners.py+++ b/invoke/runners.py@@ -790,13 +790,13 @@ class Runner(object):
# read instead of once per session, which could be costly (?).
bytes_ = None
if ready_for_reading(input_):
- bytes_ = input_.read(bytes_to_read(input_))+ bytes_ = input_.read(2**20)
# Decode if it appears to be binary-type. (From real terminal
# streams, usually yes; from file-like objects, often no.)
Sorry, mixing up issues. #915 solves #818. This is a separate issue (encountered in the same application I developed). I haven't proposed a solution to this yet, though the obvious thing is to add a chunk_size parameter somewhere.
I'm not sure #915 is quite the same issue, I'm also having performance issues with reading stdin and it's unrelated to encoding, the issue is just that bytes_to_read always returns 1...
I was able to work around that by using a custom reader which ignores the size argument and returns 10MiB at a time, not a clean solution but good enough for now.
It's not related, I already mentioned that. @bitprophet was mixing up conversations.
I was able to work around that by using a custom reader which ignores the size argument and returns 10MiB at a time, not a clean solution but good enough for now.
Currently, I just have a bunch of patches locally over these libraries in order to make them usable..
Activity
bitprophet commentedon May 12, 2023
See #915 where we are discussing solutions to this.
Dreamsorcerer commentedon May 12, 2023
Sorry, mixing up issues. #915 solves #818. This is a separate issue (encountered in the same application I developed). I haven't proposed a solution to this yet, though the obvious thing is to add a chunk_size parameter somewhere.
pgimalac commentedon Jul 3, 2025
I'm not sure #915 is quite the same issue, I'm also having performance issues with reading stdin and it's unrelated to encoding, the issue is just that
bytes_to_readalways returns 1...I was able to work around that by using a custom reader which ignores the size argument and returns 10MiB at a time, not a clean solution but good enough for now.
Dreamsorcerer commentedon Jul 3, 2025
It's not related, I already mentioned that. @bitprophet was mixing up conversations.
Currently, I just have a bunch of patches locally over these libraries in order to make them usable..