libkmod: use bufferless zstd decompression
Unlike the other two decompressions, zstd supports streaming bufferless
mode. Meaning we don't need to read and realloc in a loop.
Some strace numbers:
$ strace -e read ./before/depmod -o /tmp/throaway | wc -l
35265
$ strace -e fstat ./before/depmod -o /tmp/throaway | wc -l
1110
$ strace -e read ./after/depmod -o /tmp/throaway | wc -l
5677
$ strace -e fstat ./after/depmod -o /tmp/throaway | wc -l
6642
.. and valgrind total heap usage statistics:
before:
1,039,426 allocs, 1,039,426 frees, 3,679,232,922 bytes allocated
after:
1,020,643 allocs, 1,020,643 frees, 1,157,922,357 bytes allocated
The actual runtime is within the error margin.
v2:
- use ZSTD_decompress(), which allocates ZSTD_DCtx internally
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/142
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>