# Decompression efficiency compared between tar.bz2 and tar.xz (LZMA)

**URL:** <https://discourse.mozilla.org/t/decompression-efficiency-compared-between-tar-bz2-and-tar-xz-lzma/137593>\
**Category:** Firefox Nightly\
**Created:** [December 2, 2024, 1:41pm UTC](https://discourse.mozilla.org/t/decompression-efficiency-compared-between-tar-bz2-and-tar-xz-lzma/137593 "2024-12-02T13:41:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![buhtz](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@buhtz](https://discourse.mozilla.org/u/buhtz)\
**Post date:** [December 2, 2024, 1:41pm UTC](https://discourse.mozilla.org/t/decompression-efficiency-compared-between-tar-bz2-and-tar-xz-lzma/137593/1 "2024-12-02T13:41:48Z")

</div>

This is an additional question to [this announcement](https://blog.nightly.mozilla.org/2024/11/28/announcing-faster-lighter-firefox-downloads-for-linux-with-tar-xz-packaging/) about Firefox switching from tar.bz2 to tar.xz (LZMA).

I congratulate on that decision in context of sustainable software development and climate change.

I would like to know if there is information or data available if the efficiency of the new decompression is better than with the old decompression. I know it doubles in speed. But what is about the used CPU cores? Does it doubles the speed on a single core level, too? Does the tar.xz (LZMA) decompression use 50% less of CPU time (and energy/CO2) compared to tar.bz2?

Thanks in advance  
Christian

---

<div class="post-metadata">

**Author:** ![hneiva](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/hneiva/32/66830_2.png) [@hneiva](https://discourse.mozilla.org/u/hneiva)\
**Post date:** [December 2, 2024, 8:08pm UTC](https://discourse.mozilla.org/t/decompression-efficiency-compared-between-tar-bz2-and-tar-xz-lzma/137593/2 "2024-12-02T20:08:23Z")

</div>

Hello @buhtz, thanks for your interest in our project to switch Linux builds to xz compression.

When assessing the performance for decompression we used a 2-core system, since the large majority of our user base will have 2 or more cores available on their computer, and only about 1% of users have single core CPUs.  
If you’d like to have a peek at what the user base looks like, the [Firefox Public Data Report](https://data.firefox.com/dashboard/hardware) has some good bits of info on it.

As you might have seen, this [comment](https://bugzilla.mozilla.org/show_bug.cgi?id=1710599#c17) lists the decompression assessment for 2 CPUs.

That being said, I ran a quick test on a single CPU VM and verified that it still does decompress 2x as fast with xz compared to bzip2.  
If you’d like to run your own tests, here is a quick snippet to get you started:

```bash
# Note: You may need sudo or root user for apt
# Install bzip2, xz, hyperfine (for benchmarking), curl (for downloading)
apt install bzip2 xz-utils hyperfine curl -y
# Download firefox
curl -O https://archive.mozilla.org/pub/firefox/releases/130.0/linux-x86_64/en-US/firefox-130.0.tar.bz2
# Create xz compressed from bz2
bzip2 --decompress -k --stdout firefox-130.0.tar.bz2 | xz -9 -e --lzma2 --stdout > firefox-130.0.tar.xz

# Test with hyperfine
hyperfine --runs 10 \
"xz -d -k --stdout firefox-130.0.tar.xz > /dev/null" \
"bzip2 -d -k --stdout firefox-130.0.tar.bz2 > /dev/null"

```

And here is my results on the single core VM:

```auto
$ hyperfine --runs 10 \
"xz -d -k --stdout firefox-130.0.tar.xz > /dev/null" \
"bzip2 -d -k --stdout firefox-130.0.tar.bz2 > /dev/null"
Benchmark 1: xz -d -k --stdout firefox-130.0.tar.xz > /dev/null
  Time (mean ± σ): 5.530 s ± 0.014 s [User: 5.443 s, System: 0.069 s]
  Range (min … max): 5.509 s … 5.558 s 10 runs
 
Benchmark 2: bzip2 -d -k --stdout firefox-130.0.tar.bz2 > /dev/null
  Time (mean ± σ): 11.487 s ± 0.135 s [User: 11.309 s, System: 0.142 s]
  Range (min … max): 11.396 s … 11.855 s 10 runs
 
Summary
  'xz -d -k --stdout firefox-130.0.tar.xz > /dev/null' ran
    2.08 ± 0.02 times faster than 'bzip2 -d -k --stdout firefox-130.0.tar.bz2 > /dev/null'

```

I hope this helps cover your concerns.

Best wishes,  
Heitor Neiva
