I know this is a niche use case, but I use the 7zip binaries for a comic/manga reading app.
For certain features (For example, scroll-based reading), I need to know image dimensions in advance in order to allocate/reserve layout space. Currently, I extract all images from the compressed archive and then read their dimensions, which can be slow in some cases.
For certain image formats (Such as PNG, JXL, JPG, etc.), it is only necessary to read the first x bytes of the file to obtain the dimensions, so it wouldn't really be necessary to fully extract them. This could also be used for other header parsing use cases.
I tried using an LLM to make this changes to test performance differences (Modified version of 7zip https://github.com/ollm/7zip), but I'm not sure how correct these changes are, since I don't have C/C++ knowledge.
Below is the performance difference between extracting only the first bytes versus extracting the full image to disk. The improvement is more noticeable when the archive has no compression, and when the images are larger. The tests were run on an NVMe drive and executed twice to ensure disk read/write speed did not significantly affect the results. It is possible that the difference would be different on HDDs.
Thank you for your incredible work.
Compressed folder:
Scanning the drive:
1 folder, 137 files, 1389970597 bytes (1326 MiB), (Approx 10 MiB per image)
Extract all
time ./7zz x -oimages-out -y images-r-0.zip
Executed in 1.65 secs fish external
Extract first 64 bits (Modified version)
time ./7zz x -so -slb64 -snf'<<<FILE:{name}>>>' images-r-0.zip
Executed in 528.19 millis fish external
Extract all
time ./7zz x -oimages-out -y images-r-9.zip
Executed in 4.80 secs fish external
Extract first 64 bits (Modified version)
time ./7zz x -so -slb64 -snf'<<<FILE:{name}>>>' images-r-9.zip
Executed in 3.50 secs fish external
Extract all
time ./7zz x -oimages-out -y images-m0.rar
Executed in 2.00 secs fish external
Extract first 64 bits (Modified version)
time ./7zz x -so -slb64 -snf'<<<FILE:{name}>>>' images-m0.rar
Executed in 594.84 millis fish external
Extract all
time ./7zz x -oimages-out -y images-m5.rar
Executed in 6.35 secs fish external
Extract first 64 bits (Modified version)
time ./7zz x -so -slb64 -snf'<<<FILE:{name}>>>' images-m5.rar
Executed in 5.15 secs fish external
Extract all
time ./7zz x -oimages-out -y images-mx-0.7z
Executed in 1.73 secs fish external
Extract first 64 bits (Modified version)
time ./7zz x -so -slb64 -snf'<<<FILE:{name}>>>' images-mx-0.7z
Executed in 547.63 millis fish external
Extract all
time ./7zz x -oimages-out -y images-mx-9.7z
Executed in 14.16 secs fish external
Extract first 64 bits (Modified version)
time ./7zz x -so -slb64 -snf'<<<FILE:{name}>>>' images-mx-9.7z
Executed in 13.26 secs fish external