-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Input reuse on base64 #8587
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
Input reuse on base64 #8587
Conversation
|
we are now faster: #8578 |
|
but your change might still be relevant |
609c66b to
990ed64
Compare
|
GNU testsuite comparison: |
990ed64 to
1c9cd9b
Compare
|
GNU testsuite comparison: |
2c9c60a to
d8cd01f
Compare
|
GNU testsuite comparison: |
d8cd01f to
e20f520
Compare
|
Did some testing after rebasing on the current master. The file I used is 4.9 GB large, so this should give some ok results. For encoding we have:
For decoding:
Since this patch removes a double reading anyways, it might be still useful. I think another follow-up could be (but I'm not an expert, so take these words with a grain of salt) reading the file in parts and just later detecting if we have some padding, if possible. Almost certainly the computation time will increase, but then memory usage would be much lower. |
|
Could you please run hyperfine with gnu, without the patch and with ? |
|
GNU testsuite comparison: |
|
Here. I put decode and encode together (my bad), but you can get the relative values easily from there anyways.
PS: I will fix now the code quality checks. |
|
please copy and paste the export, not the table as it is harder |
3b4318c to
ecbe3e7
Compare
|
Hi, I'm missing something, but is there any preferred export format? Because I only find md, asciidoc, csv, json and orgmode... |
|
GNU testsuite comparison: |
|
same #8579 as in this PR |
ecbe3e7 to
349aee3
Compare
|
Ok, then, I have them saved: |
|
please add the last line, it is the summary that matters |
|
GNU testsuite comparison: |
|
Sure: |
i guess "base64" is the GNU implementation I think you should two different runs as you are benchmarking two very different things |
|
Yes, it is the GNU implementation. I will make another one only for decode (for encoding it's already there). Edit: sorry for the delay, but this will have to wait a bit. Right now, to satisfy some of the coding style constraints, I have introduced a performance regression. I will get back to it tomorrow. Edit 2: found out what was the problem, incidentally it also decreased the memory footprint with respect to my previous modifications. |
349aee3 to
61b6b13
Compare
|
GNU testsuite comparison: |
ae85bb7 to
e243bd7
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
It is strange that tests are not passing now... nothing changed from yesterday, except the removal of an import due to it not being used and the rebase to the current master... Also, testing locally only shows some errors in |
|
@ThePseudo the errors are unrelated to your PR, they also appear in other PRs. |
|
@cakebaker thanks! It makes sense now :') |
Base64: the function has_padding reads the file and then discards it. The functions fast_encode and fast_decode re-read the file, providing significant delay in larger files. This commit also reduces the amount of computation done inside the fast_decode function. In the next commit there will be the fix for the fast_decode function Signed-off-by: Andrea Calabrese <[email protected]>
This is the follow-up commit to the improvement of fast_encode and the reuse of the read file. What is written there is still valid. Signed-off-by: Andrea Calabrese <[email protected]>
e243bd7 to
f953cce
Compare
|
GNU testsuite comparison: |
|
I think I will not edit the change anymore, so I think it can be time for a review before a possible merge, if anyone is ok with it. |
|
could you please rerun the benchmark on the last version ? |
|
Sure! For encoding: For decoding: It might not be significantly faster, but it uses only one read of the file. I will prepare also another patch to enable streaming instead of reading the file from the beginning, but it may take a bit of time, so I'll open another PR. |
|
@ThePseudo when you share benchmark, please be a bit more explicit |
|
nice, on my system: and |
base64 turns out to be much slower than GNU coreutils base64.
One of the issues is that the file on which to perform base64 is read twice. This PR improves on this by reading the file once and using iterators over the file Vec to encode/decode files.