26 lines
2.0 KiB
Markdown
26 lines
2.0 KiB
Markdown
---
|
|
title: Compiling on RAM
|
|
description: 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.
|
|
published: true
|
|
date: 2022-04-30T20:10:26.153Z
|
|
tags: gentoo, performance
|
|
editor: markdown
|
|
dateCreated: 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](https://wiki.gentoo.org/wiki/Portage_TMPDIR_on_tmpfs) and [Arch Linux](https://wiki.archlinux.org/title/Makepkg#Improving_compile_times). 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](https://wiki.gentoo.org/wiki/Portage_TMPDIR_on_tmpfs#Per-package_choices_at_compile_time) (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](https://wiki.archlinux.org/title/Improving_performance#Zram_or_zswap),[Gentoo](https://wiki.gentoo.org/wiki/Zram)) is a great match when compiling on `tmpfs`. |