-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Base64: performance tuning #9215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Remove unused ReadSeek trait and rely solely on Read for inputs - Stream stdin directly instead of buffering into memory - Simplify fast decode/encode capability detection to be format-only - Always use padded base64 alphabet for consistent SIMD-based handling
- Replace explicit lifetime parameter with anonymous lifetime to reduce noise - Keeps semantics unchanged while aligning with modern Rust idioms
- Introduce READ_BUFFER_MAX to limit read buffer size during encoding - Clamp buffer size to avoid excessively large allocations while preserving behavior
- Add missing semicolons on USimpleError returns for consistent style - Reformat encode_to_vec_deque call to improve readability without logic changes
- Add "hellohello" to ignored words to prevent false positives - Keeps spell-checker from flagging known test data in base_common.rs
|
i wonder how we could check that in the CI to make sure we don't regress |
|
GNU testsuite comparison: |
|
sorry, small conflict |
- Clarify trait alias comment for ReadSeek in English - Refine padding detection doc to describe scanning including trailing whitespace
CodSpeed Performance ReportMerging #9215 will degrade performances by 5.77%Comparing Summary
Benchmarks breakdown
Footnotes
|
|
GNU testsuite comparison: |
Summary
Reworked base_common streaming so base64/basenc no longer slurp stdin into RAM; both encoder/decoder now read from any Read stream with bounded buffers, keep line-wrapping support, and reuse the SIMD wrapper.
Tightened the Base64SimdWrapper integration and added regression tests that cover streaming encode/decode behaviors plus chunked readers.
Fixed Clippy’s elidable lifetime warning and ensured Base58 handling no longer triggers gigantic buffer allocations.
Testing
cargo test -p uu_base32
cargo test -p uu_base64
cargo test -p uu_basenc
/usr/bin/time -l sh -c "cat benchmarks/bench_500mb.bin | /usr/bin/base64 > /dev/null" → max RSS 1.85 MB
/usr/bin/time -l sh -c "cat benchmarks/bench_500mb.bin | ./target/release/base64 > /dev/null" → max RSS 2.38 MB
/usr/bin/time -l sh -c "cat benchmarks/bench_500mb.b64 | /usr/bin/base64 -D > /dev/null" → max RSS 1.85 MB
/usr/bin/time -l sh -c "cat benchmarks/bench_500mb.b64 | ./target/release/base64 -d > /dev/null" → max RSS 2.33 MB