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
Feature request: build only compressor #77
Comments
Hi Konstantin That's a pretty good idea. I feel we should wait for v0.4 do look into this issue. |
With the release of 0.4.x serie, it becomes possible to target this objective. Zstd code is now more clearly separated between compression and decompression. So, what's missing now is primarily the lack of compression / decompression separation within There are mainly 2 ways to achieve this :
The second option currently looks the more promising to me. |
+1 for static |
There is also a need to define what kind of objective to target.
Speaking of static library : how does it work today ? From https://en.wikipedia.org/wiki/Static_library :
|
Here are some facts that I know about ELF linking:
|
So, if you place compression and decompression functions into different source files, make static library from it, and refenece only, e.g., decompression function from executable, compression functions won't be linked in. If they are not in different files, -ffunction-sections is required when building static library, and -Wl,--gc-sections when linking executable. |
So dead code elimination from static library is in theory possible, in practice not obvious, with various complexities and limitations in the way. OK. So now let's suppose that it's possible to build 2 static libraries dedicated for compression and decompression. Note that, within the compression one, there are multiple methods possibles, depending on compression level. That means I expect the compression library to remain "relatively big". Here is btw current object file sizes, compiled using
I suspect the request to remove decompression code is tied to reducing final code size. According to above measures, it will indeed reduce code size, but by no more than 30 % (including parts of |
Currently I'm interested only in size of zstd application. I'm planning to use it for real-time compression of coredumps and related info on embedded system to transmit over network, and this data will never be decompressed on that device. I don't have strict size requirements, so 30% would be fine. I just wanted not to bring unnecessarily bloat into firmware. |
When you say "application", you mean the |
Yep |
OK. It's a more defined objective, but also quite more work. On top of separating library functions, it will be necessary to modify program files. |
I thought something like annulen@777033b would be enough to exclude decompressor from zstd cli. Am I wrong? |
I've re-target the objective to "reduce size of According to current experiment, the proposed change at annulen/zstd@777033b will probably not be enough. I've experimented with removing non essential capabilities, starting with the integrated benchmark suite. Just removing any mention of benchmark from I'm starting to lean the binary along these principles. I suspect I'll have something to propose by tomorrow. |
There is a new update in "dev" branch : 28e7cef It proposes a new build option for Tested on Linux x64 with gcc 4.8.4, the resulting binary is 107KiB, down from 270KiB (default). It still do both compression and decompression, but as stated earlier, separating both will take quite some more time. So I figured this solution could be a good stop gap. |
Thanks! |
Here are files sizes on MIPS (stripped):
|
Looks good to me, in line with x64 experience. Is the target size good enough for you ? |
Yep! More numbers if you are interested:
|
Sounds good, your path seems able to reduce size even further, even though the public symbols are still present in compiled object files. Hey, better grab the gain .... |
Latest development release allow compilation of compression / decompression separately. |
v0.6.1 makes it possible to compile only the compressor or only the decompressor |
how is it supposed to work?
this is using checkout 83543a7 |
To be fixed |
@bittorf It's already fixed at "dev" branch: |
Fixed by @inikep in |
Could you add #define to optionally disable compilation of decompression code? Thanks.
The text was updated successfully, but these errors were encountered: