sambaiz / puppeteer-lambda-starter-kit

Starter Kit for running Headless-Chrome by Puppeteer on AWS Lambda.
MIT License
580 stars 82 forks source link

Compression Algorithms #2

Open alixaxel opened 7 years ago

alixaxel commented 7 years ago

In a effort to reduce the file size of the bundled headless_shell I was testing different algorithms:

File                Algorithm   Level   Bytes       MiB         %           Decompression
-----------------------------------------------------------------------------------------
headless_shell      -           -       136964856   130.62      -           -
headless_shell.gz   Gzip        1       51662087    49.27       62.28%      1.035s
headless_shell.gz   Gzip        2       50438352    48.10       63.17%      1.016s
headless_shell.gz   Gzip        3       49428459    47.14       63.91%      0.968s
headless_shell.gz   Gzip        4       47873978    45.66       65.05%      0.950s
headless_shell.gz   Gzip        5       46929422    44.76       65.74%      0.938s
headless_shell.gz   Gzip        6       46522529    44.37       66.03%      0.919s
headless_shell.gz   Gzip        7       46406406    44.26       66.12%      0.917s
headless_shell.gz   Gzip        8       46297917    44.15       66.20%      0.916s
headless_shell.gz   Gzip        9       46270972    44.13       66.22%      0.968s
headless_shell.gz   Zopfli      5       45089855    43.00       67.08%      0.931s
headless_shell.gz   Zopfli      10      45089161    43.00       67.08%      0.919s
headless_shell.gz   Zopfli      15      45086375    43.00       67.08%      0.919s
headless_shell.gz   Zopfli      20      45085868    43.00       67.08%      0.919s
headless_shell.gz   Zopfli      25      45085640    43.00       67.08%      0.929s
headless_shell.gz   Zopfli      30      45085003    43.00       67.08%      0.925s
headless_shell.gz   Zopfli      40      45084328    43.00       67.08%      0.921s
headless_shell.gz   Zopfli      50      45084098    43.00       67.08%      0.935s
headless_shell.br   Brotli      0       55401211    52.83       59.55%      0.778s
headless_shell.br   Brotli      1       54429523    51.91       60.26%      0.757s
headless_shell.br   Brotli      2       46436126    44.28       66.10%      0.659s
headless_shell.br   Brotli      3       46122033    43.99       66.33%      0.616s
headless_shell.br   Brotli      4       45050239    42.96       67.11%      0.692s
headless_shell.br   Brotli      5       40813510    38.92       70.20%      0.598s
headless_shell.br   Brotli      6       40116951    38.26       70.71%      0.601s
headless_shell.br   Brotli      7       39302281    37.48       71.30%      0.615s
headless_shell.br   Brotli      8       39038303    37.23       71.50%      0.668s
headless_shell.br   Brotli      9       38853994    37.05       71.63%      0.673s
headless_shell.br   Brotli      10      36090087    34.42       73.65%      0.765s
headless_shell.br   Brotli      11      34820408    33.21       74.58%      0.712s

Right now, the bundled version appears to be compressed with gzip level 6 at 44.37 MiB.

By switching to the gzip-compatible Zopfli we could shave an extra 1.37 MiB. On the other hand, gzip-incompatible Brotli would save us an extra 11.16 MiB!

Kikobeats commented 6 years ago

awesome benchmark, how do you do that?

alixaxel commented 6 years ago

@Kikobeats Do what exactly?

Kikobeats commented 6 years ago

If you used a programmatic way to do that, like a script for benchmarking

alixaxel commented 6 years ago

Just a simple bash script I wrote for it.

XBeg9 commented 6 years ago

@alixaxel do you have it somewhere uploaded? (gzip-incompatible Brotli)

alixaxel commented 6 years ago

@XBeg9 only on the puppeteer slack channel