Files
wiki/Compiling_on_RAM.md

2.0 KiB

title, description, published, date, tags, editor, dateCreated
title description published date tags editor dateCreated
Compiling on RAM Short guide on how to mount a tmpfs cache and set it as a compiling environment for great speed gain when compiling, at the expense of RAM. true 2022-04-30T20:10:26.153Z gentoo, performance markdown 2021-09-02T07:39:15.029Z

Compiling on RAM using tmpfs

When using compilation heavy systems (erhm, Gentoo), everyday compiling can be drastically sped up on capable systems by compiling on tmpfs, which is basically a file system on the RAM. Since RAM is dozens of times faster than even the fastest consumer SSDs, this is a great improvement for compile times, at the cost of memory.

See these pages on enabling compile on tmpfs for Gentoo and Arch Linux. Arch Linux tweaks probably work for Gentoo as well, and perhaps FreeBSD - needs to be tested.

Possible issue - not enough space

Note: this shouldn't really happen anymore on Takahe as I've excluded core scoundrels as per the wiki page. {.is-warning}

Since tmpfs sits on the RAM, large package may fail to compile (or refuse to try beforehand). While the Gentoo wiki Describes a Gentoo-specific solution (Which did not work), there are two easier, universal fixes:

  • Temporarily increase tmpfs memory by running mount -o remount,size=[new size-in-G] /path/to/tmpfs/mount
  • Temporarily unmount tmpfs by running umount /path/to/tmpfs/mount, obviously losing performance benefits.

ZRAM

Since compiling on tmpfs (and in general) eats up large amounts of memory, and Linuxes (and maybe BSDs - haven't gotten there) do not play nice with low memory, setting up ZRAM (Arch Linux and the rest of them,Gentoo) is a great match when compiling on tmpfs.