EmilDohne / PhotoshopAPI

A modern and performant C++20 read/write parser of Photoshop Files (*.psd and *.psb) with fully fledged Python bindings hosted on PyPi
https://photoshopapi.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
94 stars 9 forks source link

67 investigate switching out zlib ng for libdeflate #72

Closed EmilDohne closed 3 months ago

EmilDohne commented 3 months ago

This turned out to be quite a large PR as I took this moment to refactor a lot of the compression code and optimize the way the PhotoshopAPI internally compresses and decompresses data by reusing a swap buffer rather than reallocating buffers only to discard them away later.

Additionally we now use libdeflate rather than zlib_ng for compression and decompression as this allows for much greater decompression speeds. We also added memory-mapped files for read operations as this provided significant improvement in read performance.

Overall the speedups are:

While 32-bit reads did get slightly slower with our benchmark data we did see speedups in all other cases which justifies this change. I will look into equalizing 32-bit read speeds in the future