APT cacher NG - nonas/debian-clang GitHub Wiki

While working on clang-FTBFS bugs, I run quite a lot sbuild: at minimum twice on each package when everything goes fine. (unlike on xgks… which I will beat tomorrow)

That is:

  • a first run to see if the package still fails to build
  • a second one to test my patch
  • and sometimes new errors come up (yeah xgks, I'm looking at you!)

Some package may have a lot of dependencies (in package number or in package size). For instance, ygraph needed 130 MB of archive from Debian mirrors. So I looked for a way to reduce the load on the mirrors and I discovered APT-cacher-NG (Homepage, Debian Package). The daemon acts as a cache proxy for APT. The installation is pretty straightforward:

On the server side (i.e. my workstation running testing):

  • aptitude install apt-cacher-ng
  • configure it in /etc/apt-cacher-ng/acng.conf. Namely you need to set the cache folder and the BindAddress and Port. Mine looks like this (the file is self-explanatory):
CacheDir: /mnt/ito/cache/apt-cacher-ng/
Port:9999
BindAddress: localhost 192.168.0.11

On the client side (i.e. in the sbuild chroot):

  • in /etc/apt/apt.conf.d create a file (for example 90-apt-cacher-ng) with the following:
 Acquire::http {
        Proxy "http://localhost:9999";
        };

And that's it! When sbuild needs packages, they are downloaded as usual and cached by APT-cacher-NG. When a previously downloaded package is requested during the next sbuild run, the local copy is served :-) Seeing the following is great:

Fetched 17.0 MB in 0s (57.2 MB/s)

Here is the cache efficiency after a few runs on xgks:

  • Requests:
    • Hits: 514 (90.81%)
    • Misses: 52 (9.19%)
    • Total: 566
  • Data:
    • Hits: 243.17 MiB (92.03%)
    • Misses: 21.05 MiB (7.97%)
    • Total: 264.22 MiB