mirror of
https://github.com/google/brotli.git
synced 2026-09-22 06:35:52 +00:00
How to create kBrotliDictionaryData[] by code? #390
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sisong on GitHub (Jul 4, 2021).
I want to optimize a libbriotli.so file size, it only support decompress; default .so file size is 168k .
if changed const kBrotliDictionaryData[] to:
static uint8_t kBrotliDictionaryData[122784];then I got .so file size is 48k !
( I need use compress level 11, so can't define BROTLI_EXTERNAL_DICTIONARY_DATA to remove it. )
Is it possible to create kBrotliDictionaryData[] by some init code (not too much)?
@eustas commented on GitHub (Jul 4, 2021):
There are several ways to do that. One of the best (size-wise) approaches is to decode dictionary with brotli using only the dictionary part that is already decoded. However, this would require some modification of decoder / API. In this case compressed dictionary size is 49829 bytes.
Other easy way is to decode dictionary using brotli without dictionary. You can find already prepared file for that: https://github.com/google/brotli/blob/master/c/common/dictionary.bin.br; size: 51687 bytes.
Best size with wide-spread software is reached with
7z a -m0=PPMd: 46536 bytes.Also I've experimented with custom encoder. My result is 45346 bytes. However there is additional extra for decoder. In my case it was written in Java (.jar size: 1217 bytes). It is likely, that it will have comparable size in other languages.
You should also consider compressing library with something like UPX. This will be zero-effort and might allow even better results, because not only dictionary data, but binary is compressed as well.
Hope, it helps.
@sisong commented on GitHub (Jul 4, 2021):
Thank you for your quick reply!
I know the way to compressed it or used UPX;
so, can't using code to generation it.