1 |
On 2017-05-24 08:00, Kai Krakow wrote: |
2 |
|
3 |
> While I have no benchmarks and use the systemd default of tmpfs for |
4 |
> /tmp, I also put /var/tmp/portage on tmpfs, automounted through |
5 |
> systemd so it is cleaned up when no longer used (by unmounting). |
6 |
> |
7 |
> What can I say? It works so much faster: Building packages is a lot |
8 |
> faster most of the time, even if you'd expect gcc uses a lot of |
9 |
> memory. |
10 |
> |
11 |
> Well, why might that be? First, tmpfs is backed by swap space, that |
12 |
> means, you need a swap partition of course. Swap is a lot simpler than |
13 |
> file systems, so swapping out unused temporary files is fast and is a |
14 |
> good thing. Also, unused memory sitting around may be swapped out |
15 |
> early. Why would you want inactive memory resident? So this is also a |
16 |
> good thing. Portage can use memory much more efficient by this. |
17 |
> |
18 |
> Applying this reasoning over to /tmp should no explain why it works so |
19 |
> well and why you may want it. |
20 |
> |
21 |
> BTW: I also use zswap, so tmpfs sits in front of a compressed |
22 |
> write-back cache before being written out to swap compressed. This |
23 |
> should generally be much more efficient (performance-wise) than |
24 |
> putting /tmp on zram. |
25 |
> |
26 |
> I configured tmpfs for portage to use up to 30GB of space, which is |
27 |
> almost twice the RAM I have. And it works because tmpfs is not |
28 |
> required to be resident all the time: Inactive parts will be swapped |
29 |
> out. The kernel handles this much similar to the page cache, with the |
30 |
> difference that your files aren't backed by your normal file system |
31 |
> but by swap. And swap has a lot lower IO overhead. |
32 |
> |
33 |
> Overall, having less IO overhead (and less head movement for portage |
34 |
> builds) is a very very efficient thing to do. GCC constantly needs all |
35 |
> sorts of files from your installation (libs for linking, header files, |
36 |
> etc), and writes a lot of transient files which are needed once later |
37 |
> and then discarded. There's no point in putting it on a non-transient |
38 |
> file system. |
39 |
> |
40 |
> I use the following measures to get more performance out of this |
41 |
> setup: |
42 |
> |
43 |
> * I have three swap partitions spread across three HDDs |
44 |
> * I have a lot of swap space (60 GB) to have space for tmpfs |
45 |
> * I have bcache in front of my HDD filesystem |
46 |
> * I have a relatively big SSD dedicated to bcache |
47 |
> |
48 |
> My best recommendation is to separate swap and filesystem devices. |
49 |
> While I didn't do it that way, I still separate them through bcache |
50 |
> and thus decouple fs access and swap access although they are on the |
51 |
> same physical devices. My bcache is big enough that most accesses |
52 |
> would go to the SSD only. I enabled write-back to have that effect |
53 |
> also for write access. |
54 |
> |
55 |
> If you cannot physically split swap from fs, a tmpfs setup for portage |
56 |
> may not be recommended (except you have a lot of memory, like 16GB or |
57 |
> above). But YMMV. |
58 |
> |
59 |
> Still, I recommend it for /tmp, especially if your system is on SSD. |
60 |
|
61 |
All interesting points, and you convinced me to at least give tmpfs a |
62 |
try on the desktop. |
63 |
|
64 |
My laptop is different, though. It doesn't have that much RAM by |
65 |
comparison (4G) and it _only_ has a SSD. Builds have been slow :( I am |
66 |
afraid to mess with it lest I increase the wear on the SSD. |
67 |
|
68 |
> Unix semantics suggest that /tmp is not expected to survive reboots |
69 |
> anyways (in contrast, /var/tmp is expected to survive reboots), so |
70 |
> tmpfs is a logical consequence to use for /tmp. |
71 |
|
72 |
/tmp is wiped by the bootmisc init job anyway. |
73 |
|
74 |
-- |
75 |
Please *no* private Cc: on mailing lists and newsgroups |
76 |
Personal signed mail: please _encrypt_ and sign |
77 |
Don't clear-text sign: |
78 |
http://primate.net/~itz/blog/the-problem-with-gpg-signatures.html |