]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: use bufferless zstd decompression
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 19 Sep 2024 12:14:58 +0000 (13:14 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 23 Sep 2024 14:53:48 +0000 (09:53 -0500)
commit72c0aa37fe0104f347242a652f3ab3683967bbf0
treefc624e891eb73ff0824022fe2595954f583bfe29
parent4f8a6a85c58770b3c4212780026215faab2f33a4
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>
libkmod/libkmod-file-zstd.c