Print output bit count#25
Open
GediminasMasaitis wants to merge 1 commit intoemmanuel-marty:masterfrom
Open
Conversation
b99f311 to
1ea4dc3
Compare
Author
|
Just right off-the-bat, using this patch, with adjusting the blackbox to parse the ouput bits, this saved 2 bytes in the main branch: GediminasMasaitis/4k-dot-c@b699655 |
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.
This PR adds reporting of the total bits used in the compressed stream, as well as how many bytes were used in the last byte.
The reasoning for this is that I have this project 4k.c, a chess engine made to be <4kb, for the TCEC 4K tournament https://wiki.chessdom.org/TCEC_4k_Rules. Source of my project: https://github.com/GediminasMasaitis/4k-dot-c It has a thing I call the "blackbox compressor" - if you look at the actual source file 4k.c, you will see that it has all sorts of macros ('G', 'H', 'S') which don't really do anything. They are markers for the blackbox.
How this blackbox works is - I marked every permutation that can be made in code, that doesn't drastically affect the output of the engine. Then I run makefile multiple thousands of times, seeing if the permutation of the "group" made gcc output a binary that is more compressible using apultra, and results in a smaller size.
The optimization I could do if this was in place is instead of checking the size of the binary after compression, I could check the bit size of the output. Which would just give 8x the resolution. Then, for example, if a permutation saves 2 bits it can be applied, then another one that saves 3 bits, and so on, and in the end, a whole byte of few may be saved.
Example of output after patch, the line added is "Compressed bits:":
This patch would likely me allow to optimize my binary better, but even without that, it's just nice info to have in the verbose output.
Let me know if you have further questions