A small tip if you compile from AUR!
Just discovered this while browsing the wiki today.
You can install ccache and configure makepkg to speedup compilation times greatly!
-
sudo pacman -S ccache
-
sudo nano
/etc/makepkg.confand uncomment ccache from this line:
BUILDENV=(fakeroot !distcc color ccache check !sign)
- uncomment and edit the
MAKEFLAGSto reflect your CPU threads, for example an 8 threads (4 cores) Skylake CPU:
MAKEFLAGS="-j8"
- Add this to your
.bashrcto enable for command line compilations:
export PATH="/usr/lib/ccache/bin/:$PATH"
I went from 1 hour full kernel compilation to 17 minutes!
About this post
- Posted
- Archived
- Score
- 153 · 100% up
- Kind
- Text
- ID
- 6vez44
47 comments
You can also change PKGEXT=".pkg.tar.gz" to PKGEXT=".pkg.tar"
in your /etc/makepkg.conf
For smaller packages this is the longest part of installing a package from the AUR. The files will of course be bigger then.
I've found this helps a ton with larger packages as well, like chrome and icon themes. It's been more than an 10x speedup in some cases where there isn't a ton of compilation.
Yes, you're totally right. It makes a very big difference with big packages too, especially with binary packages!
.tar.lzo is a nice compromise so packages still compress extremely fast, but won't take up that much space for easily compressed content.
Good tip. Maybe i'll use it on a PC with a smaller SSD.
Or just set that when you make the package.
Sure you can do that too. Here is the relevant part in the Arch Wiki.
I set it in the makepkg.conf because i have a lot of space on my SSD and my /home is on my HDD and i want it for every package anyway.
Here it is in script form
Looks like you can also speed up compression by changing the number of threads used for compression
Arch Wiki
What does ccache do? Obviously, your ~8x speedup is due to using 8 (virtual) threads. -j8 is the first thing I do on a fresh Arch(/Manjaro). The other is to remove 64bit from the mkfs.ext4 format options. (Windows 10 is an asshole.)
https://wiki.archlinux.org/index.php/Ccache
It's for quicker compile times for programms you compile frequently and/or take a long time to compile.
The first time you will compile a programm it will take a little longer, but after that it can reuse compiled code that hasn't changed in my limited unterstanding.
Nope, it only helps on recompile. The length of compile doesn't matter at all to ccache.
But, as an end user, you compile AUR packages only once. So ccache actually hurt performance here.
Makes sense. I was redditing on the bus, and I didn't look it up before commenting. :-/
but with a proper makefile it already does this.
What does Windows 10 have to do with ext4 64bit?
When you dual boot alongside Windows, the 64bit flag will cause it to misidentify the partition and mangle it. On reboot, Arch will drop to shell an you need to fsck before it will continue.
It's a compiler cache.
Isn't it cpu threads + 1 so a skylake i7 should be using -j9? At least that's what's recommended by Gentoo and they should know since they compile everything.
MAKEFLAGS="-j$(( $(nproc) + 1 ))";)Just use
MAKEFLAGS=-jsee:Ncpu+1 is great if you don't want to do anything else on your computer while it's compiling, otherwise you and the compiler are just going to be fighting over CPU time
niceFTW!The number is for number of threads. I think the idea is that by making one more, you can get a little extra performance while another thread is waiting on I/O. I just use 8, but I'm also not OP.
The general recommendation is to use number_of_threads or number_of_threads+1. The difference between the two should be negligable in practice
Honestly hyperthreading is at a stage that you could use the number of the cores your CPU has and the result would be the same (not including other factors)
Get 32GB of ram and set your build folder to /tmp in makepkg.conf.
Isn't /tmp the default build folder?
From man:
idk what the default for new installs is now (aka is tmp a regular partition or tmpfs) but the point is to compile on a tmpfs partition and have enough ram so it never has to use swap
You do not have 512GB RAM?
I always do the build on ram so ccache doesn't help much. If there are many differences between versions, there are many misses makeing the building last even longer. Maybe I can try syncing the cache with a cache folder in ram but this is too much trouble for a kernel compile.
Even if you build in RAM, ccache will help by saving cpu cycles.
How do you build on ram? Is that connected to setting the build directory to
/tmpat all?I guess you can also do it this way or configure your aur helper to do it.
Personally I use cower, it downloads the files of the package and puts them in a folder in which you can build it. Before I download the package I go to the /tmp directory.
Maybe webkit will compile in less than a few hours now
Deleted before we saved it.
Here's two snippets that you can use in a script or paste to the shell to change /etc/makepkg.conf to reflect your recommendations, so then all you would need to do is add that one line to your bashrc/zshrc
BUILDENV:
MAKEFLAGS: