And… of course this is a click-bait title, This will only speedup the compress time when packaging the package, not the whole build time ๐๏ธ.
One night in a peaceful Telegram group, a member starts complaining about aur packages install is too slow, and the xz
process is only consuming one core. This leads to a meaningful discussion about how aur works and how to speed up the build, but I’ll skip the first part by now, if you are interested, just follow Makepkg page on Arch Wiki.
In short, aur is using makepkg to build the package and then install it with pacman, and there is a /etc/makepkg.conf
we can tweak to make it works better.
zstd
Another thing pop up in the discussion is zstd, pacman switches to zstd from xz on Friday, Dec 27, 2019, and claims it had a 1300% speedup. Since we can also use it in makepkg now, so it’s a great time to switch.
Just change one line in /etc/makepkg.conf
to make it use zstd.
- PKGEXT='.pkg.tar.xz' + PKGEXT='.pkg.tar.zst'
Multithread
The main complain is xz
is only using one thread when there are 8/16 available. It’s because the commands is not setup to use multi-thread by default. we can change it as documented in the Makepkg wiki page.
This change can change zstd to use multi-thread (similar to xz
).
- COMPRESSZST=(zstd -c -z -q -) + COMPRESSZST=(zstd -c -z -q - --threads=0)
Use tmpfs
If you have spare memory, you can also use it for speed up build. This is also documented in the Makepkg wiki page.
Just uncomment one line in /etc/makepkg.conf
- #BUILDDIR=/tmp/makepkg + BUILDDIR=/tmp/makepkg
Conclusion
These steps should give you a 1000%+ speedup with aur package compressing(according to Robin Broda). I have so many times starring at aur package install stuck at Compressing Package
step, but never thought of how to optimize it. #TodayILearned
History
- 2020-04-30 add title explanation.