icecream(7)

๐Ÿ“ฆ
version 1.4.0 ยท 2 versions
, in epel 10, epel 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

๐Ÿ’… icecream โ€” a distributed compile system ๐Ÿ’…

okay bestie, welcome to icecream(7) โ€” yes that's the section number, she's a miscellaneous girlie, we don't gatekeep. this is the whole vibe guide to the icecream distributed compile system, and by the end you're gonna be scheduling compile jobs like it's nothing. periodt. ๐Ÿฆโœจ


๐Ÿ“ NAME ๐Ÿ“

icecream โ€” a distributed compile system. that's it, that's the name, she's literally the distributed compile system. slay.


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so. icecream is a distributed compile system for C and C++. highkey iconic.

icecream is created by SUSE and is based on ideas and code by distcc. and like distcc, it takes compile jobs from your build and distributes them to remote machines, which lets you do a parallel build on several machines you've got. the way that works? chef's kiss.

but here's the plot twist โ€” unlike distcc, icecream uses a central server that schedules the compile jobs to the fastest free server, which makes her dynamic. that's the main character energy right there. ๐Ÿ’…

this advantage pays off mostly for shared computers โ€” because if you are the only user on X machines, you have full control over them anyway, so likeโ€ฆ you didn't need her. but in a shared setup? she ate.


๐Ÿฆ‹ HOW TO USE ICECREAM ๐Ÿฆ‹

okay so you need two things, and you need them both:

  • One machine that runs the scheduler (icecc-scheduler -d)
  • Many machines that run the daemon (iceccd -d)

if you want to compile using icecream, make sure $prefix/lib/icecc/bin is the first entry in your path, e.g. type:

export PATH=/usr/lib/icecc/bin:$PATH
hint: put this in ~/.bashrc or /etc/profile to not have to type it in everytime. future you will thank you, fr fr. ๐Ÿซถ

then you just compile with make -j num, where num is the amount of jobs you want to compile in parallel. do not exaggerate. too large numbers can overload your machine or the compile cluster and make the build in fact slower. ๐Ÿ˜ญ not the self-own.

Warning โš ๏ธ Never use icecream in untrusted environments. Run the daemons and the scheduler as unpriviliged user in such networks if you have to! But you will have to rely on homogeneous networks then (see below). no cap, this one's important โ€” don't be out here being everyone's free compute, bestie. ๐Ÿ’€

if you want an overview of your icecream compile cluster, or if you just want funny stats, you might want to run icemon. she's giving dashboard, she's giving nosy bestie watching your build go. ๐Ÿ‘‘


๐Ÿงš USING ICECREAM IN HETEROGENEOUS ENVIRONMENTS ๐Ÿงš

so if you are running icecream daemons in the same icecream network but on machines with incompatible compiler versions, icecream needs to send your build environment to remote machines. it's basically packing a little suitcase for your compiler.

note: they all must be running as root if compiled without libcap-ng support. in the future icecream might gain the ability to know when machines cannot accept a different environment, but for now it is all or nothing. ๐Ÿ™ˆ

under normal circumstances this is handled transparently by the icecream daemon, which will prepare a tarball with the environment when needed. this is the recommended way, because the daemon will also automatically update the tarball whenever your compiler changes. automatic = slay, no notes. โœจ

if you want to handle this manually for some reason, you have to tell icecream which environment you are using:

  1. use icecc --build-native to create an archive file containing all the files necessary to setup the compiler environment.
  2. the file will have a random unique name like ddaea39ca1a7c88522b185eca04da2d8.tar.bz2 per default.
  3. rename it to something more expressive for your convenience, e.g. i386-3.3.1.tar.bz2.
  4. set ICECC_VERSION=filename_of_archive_containing_your_environment in the shell environment where you start the compile jobs.

then the file will be transferred to the daemons where your compile jobs run and installed to a chroot environment for executing the compile jobs in the environment fitting to the environment of the client. this requires that the icecream daemon runs as root. ๐Ÿ‘‘


๐ŸŒˆ CROSS-COMPILING USING ICECREAM ๐ŸŒˆ

SUSE got quite some good machines not having a processor from Intel or AMD, so icecream is pretty good at using cross-compiler environments โ€” similar to the above way of spreading compilers. iconic problem-solving tbh.

there the ICECC_VERSION variable looks like:

<native_filename>(,<platform>:<cross_compiler_filename>)*

for example like this:

/work/9.1-i386.tar.bz2,ia64:/work/9.1-cross-ia64.tar.bz2

how to package such a cross compiler is pretty straightforward if you look at what is inside the tarballs generated by icecc --build-native. peek inside, copy the vibe. ๐ŸŽ€


๐Ÿ’œ CROSS-COMPILING FOR EMBEDDED TARGETS USING ICECREAM ๐Ÿ’œ

when building for embedded targets like ARM, often you will have a toolchain that runs on your host and produces code for the target. in these situations you can exploit the power of icecream as well. bestie she's flexible like that. ๐Ÿงš

first step โ€” create symlinks from where icecc is to the name of your cross compilers (e.g. arm-linux-g++ and arm-linux-gcc). make sure that these symlinks are in the path and before the path of your toolchain, and with $ICECC_CC and $ICECC_CXX you need to tell icecream which compilers to use for preprocessing and local compiling. e.g. set it to:

ICECC_CC=arm-linux-gcc
ICECC_CXX=arm-linux-g++

as the next step you need to create a .tar.bz2 of your cross compiler โ€” check the result of build-native to see what needs to be present. ๐Ÿ”

finally one needs to set ICECC_VERSION and point it to the .tar.bz2 you have created. when you start compiling your toolchain will be used. she's locked in, she's ready. ๐Ÿ’…

Note ๐Ÿ“Œ With ICECC_VERSION you point out on which platforms your toolchain runs, you do not indicate for which target code will be generated. read that twice, iykyk. this is the classic mix-up and we don't do that here.

๐ŸŽ€ CROSS-COMPILING FOR MULTIPLE TARGETS IN THE SAME ENVIRONMENT USING ICECREAM ๐ŸŽ€

when working with toolchains for multiple targets, icecream can be configured to support multiple toolchains in the same environment. multitasking queen. ๐Ÿ‘‘

multiple toolchains can be configured by appending =<target> to the tarball filename in the ICECC_VERSION variable. where the <target> is the cross compiler prefix. there the ICECC_VERSION variable will look like:

<native_filename>(,<platform>:<cross_compiler_filename>=<target>)*

below an example of how to configure icecream to use two toolchains โ€” /work/toolchain1/bin/arm-eabi-[gcc,g++] and /work/toolchain2/bin/arm-linux-androideabi-[gcc,g++] โ€” for the same host architecture:

  • Create symbolic links with the cross compilers names (e.g. arm-eabi-[gcc,g++] and arm-linux-androideabi-[gcc,g++]) pointing to where the icecc binary is. Make sure these symbolic links are in the $PATH and before the path of the toolchains.
  • Create a tarball file for each toolchain that you want to use with icecream. The icecc-create-env script can be used to create the tarball file for each toolchain, for example: icecc-create-env /work/toolchain1/bin/arm-eabi-gcc icecc-create-env /work/toolchain2/bin/arm-linux-androideabi-gcc.
  • Set ICECC_VERSION to point to the native tarball file and for each tarball file created to the toolchains (e.g ICECC_VERSION=/work/i386-native.tar.gz,/work/arm-eabi-toolchain1.tar.gz=arm-eabi,/work/arm-linux-androideabi-toolchain2.tar.gz=arm-linux-androideabi).

with these steps, icecream will use:

  • /work/arm-eabi-toolchain1.tar.gz to cross compilers with the prefix arm-eabi (e.g. arm-eabi-gcc and arm-eabi-g++) ๐Ÿ“
  • /work/arm-linux-androideabi-toolchain2.tar.gz to cross compilers with the prefix arm-linux-androideabi (e.g. arm-linux-androideabi-gcc and arm-linux-androideabi-g++) ๐Ÿฆ‹
  • /work/i386-native.tar.gz to compilers without prefix โ€” the native compilers ๐Ÿ’œ

she's organized, she's got range, she's doing all three at once. we love a multi-talented icon. โœจ


๐Ÿ”ฅ HOW TO COMBINE ICECREAM WITH ccache ๐Ÿ”ฅ

the easiest way to use ccache with icecream is to set CCACHE_PREFIX to icecc (the actual icecream client wrapper):

export CCACHE_PREFIX=icecc

this will make ccache prefix any compilation command it needs to do with icecc, making it use icecream for the compilation (but not for preprocessing alone). tag team, dream team. ๐Ÿค

to actually use ccache, the mechanism is the same like with using icecream alone. since ccache does not provide any symlinks in /opt/ccache/bin, you can create them manually:

mkdir /opt/ccache/bin
ln -s /usr/bin/ccache /opt/ccache/bin/gcc
ln -s /usr/bin/ccache /opt/ccache/bin/g++

and then compile with:

export PATH=/opt/ccache/bin:$PATH
note however that ccache is not really worth the trouble if you are not recompiling your project three times a day from scratch โ€” it adds quite some overhead in comparing the preprocessor output and uses quite some disc space, and I found a cache hit of 18% a bit too few, so I disabled it again. ๐Ÿ˜ญ the manpage author said "I tried it and gave up" and honestly? relatable. ๐Ÿ’€

โญ DEBUG OUTPUT โญ

you can use the environment variable ICECC_DEBUG to control if icecream gives debug output or not. set it to debug to get debug output. the other possible values are:

  • error
  • warning
  • info

(the -v option for daemon and scheduler raise the level per -v on the command line โ€” so use -vvv for full debug). yes bestie, more v's = more lore. go off with the -vvv. ๐Ÿซถ


๐ŸŒŸ AVOIDING OLD HOSTS ๐ŸŒŸ

it is possible that compilation on some hosts fails because they are too old โ€” typically the kernel on the remote host is too old for the glibc from the local host. grandma machine can't sit with us. ๐Ÿ˜ญ

recent icecream versions should automatically detect this and avoid such hosts when compilation would fail. she's self-aware, she's got taste.

if some hosts are running old icecream versions and it is not possible to upgrade them for some reason, use:

export ICECC_IGNORE_UNVERIFIED=1

problem solved, moving on. ๐Ÿ’…


๐Ÿ’€ SOME NUMBERS ๐Ÿ’€

numbers of my test case (some STL C++ genetic algorithm) โ€” because we love receipts:

  • g++ on my machine: 1.6s
  • g++ on fast machine: 1.1s
  • icecream using my machine as remote machine: 1.9s
  • icecream using fast machine: 1.8s

the icecream overhead is quite huge as you might notice ๐Ÿ˜ญ โ€” but the compiler cannot interleave preprocessing with compilation, and the file needs to be read/written once more and in between the file is transferred. so like, it's not her fault, it's the physics of the whole thing.

but even if the other computer is faster, using g++ on my local machine is faster. and if you are (for whatever reason) alone in your network at some point, you lose all advantages of distributed compiling and only add the overhead. ๐Ÿ™ˆ awkward.

so icecream got a special case for local compilations (the same special meaning that localhost got within $DISTCC_HOSTS). this makes compiling on my machine using icecream down to 1.7s โ€” the overhead is actually less than 0.1s in average. she fixed it. she ate. ๐Ÿ”ฅ

as the scheduler is aware of that meaning, it will prefer your own computer if it is free and got not less than 70% of the fastest available computer. loyalty!! ๐Ÿซถ

keep in mind, that this affects only the first compile job โ€” the second one is distributed anyway. so if I had to compile two of my files, I would get:

  • g++ -j1 on my machine: 3.2s
  • g++ -j1 on the fast machine: 2.2s
  • using icecream -j2 on my machine: max(1.7,1.8)=1.8s
  • (using icecream -j2 on the other machine: max(1.1,1.8)=1.8s)

the math is a bit tricky and depends a lot on the current state of the compilation network, but make sure you are not blindly assuming make -j2 halves your compilation time. ๐Ÿ“‰ she said don't be delusional. ngl that's the theme of the whole page. ๐Ÿ’œ

๐ŸŒˆ WHAT IS THE BEST ENVIRONMENT FOR ICECREAM ๐ŸŒˆ

Okay bestie, real talk โ€” for most of your requirements, icecream is not special. Like, at all. It genuinely does not matter which distributed compile system you're using: if your nodes are connected through less than or equal to 10MBit, you will not be having fun. Periodt. ๐Ÿ’€

The good news? icecream compresses input and output files (using lzo), so you can calc with ~1MBit per compile job โ€” which lowkey means more than make -j10 will not be possible without delays. Do the math, bestie, it's mathing. ๐Ÿงฎโœจ

Remember: more machines are only good if you can use massive parallelization.

But you will for sure get the best result if your submitting machine (the one you called g++ on) is fast enough to feed the others. Especially if your project consists of many easy to compile files โ€” the preprocessing and file I/O will be job enough to need a quick machine. The submitting machine is the main character here, honestly. ๐Ÿ‘‘

And the scheduler? She will try to give you the fastest machines available, so even if you add old machines, they will be used only in exceptional situations. But still you can have bad luck โ€” the scheduler does not know how long a job will take before it started. So if you have 3 machines and two quick to compile and one long to compile source file, you are not safe from a choice where everyone has to wait on the slow machine. Keep that in mind. ๐Ÿ˜ญ Not the slow machine holding up the whole group chat.


๐Ÿ”ฅ NETWORK SETUP FOR ICECREAM (FIREWALLS) ๐Ÿ”ฅ

A short overview of the ports icecream requires โ€” screenshot this, fr fr:

  • TCP/10245 on the daemon computers (required) ๐Ÿซถ
  • TCP/8765 for the the scheduler computer (required) ๐Ÿ‘‘
  • TCP/8766 for the telnet interface to the scheduler (optional) ๐ŸŒธ
  • UDP/8765 for broadcast to find the scheduler (optional) ๐Ÿฆ‹

If the monitor cannot find the scheduler, use:

ICECC_SCHEDULER=host icemon

That's the whole hack, no cap. ๐Ÿ’…


โœจ SEE ALSO โœจ

Go read those too, iykyk. ๐Ÿ“š๐Ÿ’–


๐ŸŽ€ ICECREAM AUTHORS ๐ŸŽ€

These iconic humans made it happen, show some respect:

  • Stephan Kulow <coolo@suse.de>
  • Michael Matz <matz@suse.de>
  • Cornelius Schumacher <cschum@suse.de>
  • ...and various other contributors. ๐Ÿซถ

That's the whole vibe, bestie โ€” icecream(7), dated April 21th, 2005 (yes, "21th", we don't fix it, we respect the original ๐Ÿ’€), and that's a wrap on part 2. Now go compile something iconic. ๐Ÿ’…โœจ๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from