Skip to content

Conversation

@mattsu2020
Copy link
Contributor

@mattsu2020 mattsu2020 commented Dec 1, 2025

Summary

basenc: Stream base32/base64 I/O to honor bounded-memory test
The GNU bounded-memory implementation exceeded memory limits when handling all inputs. Using BufReader with chunked encoding/decoding, we consistently kept the working set under 8KiB. During errors, we flush partial outputs to match GNU's behavior.

Modified the test for bounded-memory.sh in GNU coreutils to pass.

related
#9127

@mattsu2020 mattsu2020 marked this pull request as draft December 1, 2025 11:37
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 1, 2025

CodSpeed Performance Report

Merging #9536 will degrade performances by 2.88%

Comparing mattsu2020:basenc_bounded-memory (d5cc32b) with main (92d7792)

Summary

❌ 2 regressions
✅ 125 untouched
⏩ 6 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
b64_decode_synthetic 168.4 µs 173.5 µs -2.88%
b64_decode_ignore_garbage_synthetic 166.5 µs 171.3 µs -2.83%

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@mattsu2020 mattsu2020 marked this pull request as ready for review December 1, 2025 11:50
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is no longer failing!

@sylvestre sylvestre requested a review from RenjiSann December 5, 2025 21:06
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is no longer failing!

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is no longer failing!

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is no longer failing!

@RenjiSann
Copy link
Collaborator

Congrats! The gnu test tests/basenc/bounded-memory is no longer failing!

Kudos !

A few remarks however:

  • Could you squash your commits in 1-2 meaningful changes ?
  • Can you say a few words about what why the test was failing, and what you did ? You can also put the explanation in the commit message for future reference.

GNU basenc bounded-memory failed because the Rust impl buffered entire input
and exceeded the vmem limit. Stream base32/base64 via BufReader and chunked
encode/decode so the working set stays around 8 KiB. Keep base58 buffered to
preserve its big-integer semantics. Flush already-decoded bytes before
returning errors to match GNU output.
@mattsu2020 mattsu2020 force-pushed the basenc_bounded-memory branch from 645bd1e to d5cc32b Compare December 9, 2025 23:27
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is no longer failing!

@RenjiSann
Copy link
Collaborator

Ok, I like this !

I looked at the benchmark regression, and it seems that the problem come from the new handle_input implementation which makes to many calls to memset, I guess that could come either from lines 789-791 or line 555 in your patch.

We can merge this as is, because it's not trivial to avoid memsets in Rust and this MR was about fixing a GNU test anyway, but I think we should keep track of this with an issue

@mattsu2020 tell me if you'd rather want this to be addressed in another PR.

Anyway, thank you for your contribution !

@mattsu2020
Copy link
Contributor Author

@mattsu2020 tell me if you'd rather want this to be addressed in another PR.

I believe it would be more appropriate to address this matter in a separate pull request. Merging it would likely make handling it more difficult.

@RenjiSann
Copy link
Collaborator

@mattsu2020 I created the issue: #9621

@RenjiSann RenjiSann merged commit c085cd1 into uutils:main Dec 10, 2025
126 of 127 checks passed
@mattsu2020 mattsu2020 deleted the basenc_bounded-memory branch December 10, 2025 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants