https://github.com/likema/zstd-hook
Hook zstd for setting compression level and compression threads
https://github.com/likema/zstd-hook
Last synced: 8 months ago
JSON representation
Hook zstd for setting compression level and compression threads
- Host: GitHub
- URL: https://github.com/likema/zstd-hook
- Owner: likema
- License: lgpl-2.1
- Created: 2022-10-08T14:08:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-08T14:22:32.000Z (over 3 years ago)
- Last Synced: 2024-12-31T09:23:53.761Z (over 1 year ago)
- Language: C
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hook zstd for setting compression level and compression threads
A shared library to hook `ZSTD_CCtx* ZSTD_createCCtx(void)` for setting compression level and compression threads.
For `qemu-img` (>= **6.0**) or the similar programs without setting zstd compression level and compression threads options.
See also: [How to change zstd level for qcow2 image?](https://stackoverflow.com/questions/72562226/how-to-change-zstd-level-for-qcow2-image)
## Building
```shell
cd zstd-hook
cmake -DCMAKE_BUILD_TYPE=Release
make
```
## Usage
Set the following environment variables:
* `ZSTD_CLEVEL` : the zstd compression level between `1` and `22`
* `ZSTD_NBTHREADS` : the zstd compression threads
* `LD_PRELOAD` : the hook library `libzstdhook.so`
* `LD_LIBRARY_PATH` : the directory for the hook library `libzstdhook.so`
For examples, hook `qemu-img` (>= **6.0**) converting source image to zstd compressed `qcow2` image by compression level `22` and the **maximum** compression threads on Ubuntu 22.04:
```shell
cd zstd-hook
LD_LIBRARY_PATH=. LD_PRELOAD=libzstdhook.so \
ZSTD_CLEVEL=22 ZSTD_NBTHREADS=`grep -c '^processor' /proc/cpuinfo` \
qemu-img convert -c -o compression_type=zstd -O qcow2
```