Repository navigation
Faster downloads: 2 KB base64 chunks (#133) - #180
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Downloading a file from a board was 4 to 6 times slower than uploading it. Each 256-byte chunk of a download costs one round trip with a printed reply, and on CircuitPython a reply costs far more than a silent write, so 80 round trips for 20 KB dominated. Chunk size was the lever; the reply was also up to 4x the data as
reprof binary.This reads in 2048-byte chunks and has the board send each chunk as base64 (
binascii), checked with a strict character pattern and the existing length check. A board withoutbinasciikeeps the old 256-bytereprpath, and a board that raisesMemoryErrorgets the chunk halved down to 256.Measured on an ESP32-S3 running CircuitPython 11 over USB serial (COM17), same board and transport,
mpftp put/cp --no-verify, whole command including about 5 s of start-up, files compared with cmp afterwards:A 20 KB
cpwith the default verify, which reads the file a second time on this board, went from 130 s to 67 s.Tests:
python -m unittest cli.tests.test_read_file_checked(new cases for chunk count, no-binascii fallback, small heap and base64 noise).Closes #133.