pvizeli / securetar

Secure Tarfile library
Apache License 2.0
6 stars 2 forks source link

Use non-streaming mode and default compression level 6 #22

Closed agners closed 11 months ago

agners commented 1 year ago

The streaming mode (using | before the compression) seems to be quite a bit slower. This restricts the input to a file, but which is typically the case.

The compression level of 6 is the default and significantly increases performance with similar compression ratio.

In a test using Home Assistant Supervisor's Backup functionality backup time decreased from 4min 21s to 3min 33s without streaming mode, and further down to 2min 32s with compression level set to 6. The compression level 6 increased only by 1MB (at 632.8MB to 633.8MB), altough about 90% of data were not compressable data (JPEG). But also other comparision benchmark only report marginal difference in compression ratio.

agners commented 1 year ago

Currently we can only apply this optimization for non-encryption mode.

In Python 3.12, tarfile will support compression levels in streaming mode as well, which should bump speed at least a bit. https://docs.python.org/3/library/tarfile.html