1 |
Hi, |
2 |
|
3 |
On Wed, 24 May 2017 05:34:09 -0400 Rich Freeman wrote: |
4 |
> On Wed, May 24, 2017 at 1:16 AM, Ian Zimmerman <itz@×××××××.net> wrote: |
5 |
> > |
6 |
> > I have long been in the camp that thinks tmpfs for /tmp has no |
7 |
> > advantages (and may have disadvantages) over a normal filesystem like |
8 |
> > ext3, because the files there are normally so small that they will stay |
9 |
> > in the page cache 100% of the time. |
10 |
> > |
11 |
> |
12 |
> The file being in the page cache only speeds up reads of the file. On |
13 |
> a conventional filesystem the file will still be forced to be |
14 |
> committed to disk within 30 seconds, or whatever you've set your max |
15 |
> writeback delay to. That means guaranteed disk write IO. If the |
16 |
> drive is mostly idle it will have no impact on performance, but if the |
17 |
> disk is fairly busy then it will, especially for spinning disks. For |
18 |
> an SSD /tmp would be a source of erase cycles (which also have |
19 |
> performance implications, but there it is more of a wear issue). When |
20 |
> the file is removed that would also generate write IO. |
21 |
> |
22 |
> The flip side is that on most systems /tmp probably doesn't get THAT much IO. |
23 |
> |
24 |
> On Gentoo doing your builds in tmpfs definitely has a large |
25 |
> performance impact, because there are a lot of files created during |
26 |
> the build process that are sizable but which don't end up getting |
27 |
> installed (object files mostly). Plus you have the extraction of the |
28 |
> source itself. For a typical build that is many MB of data being |
29 |
> extracted and then deleted after maybe a minute, which is a lot of |
30 |
> useless IO, especially when the actual install is probably creating a |
31 |
> fairly sizable IO queue on its own. |
32 |
> |
33 |
> To avoid a reply, I'll also note that tmpfs does NOT require swap to |
34 |
> work. It does of course require plenty of memory, and as with any |
35 |
> situation where lots of memory is required swap may be useful, but it |
36 |
> is not a requirement. |
37 |
> |
38 |
> Others have mentioned zram. I've used it, but unless something has |
39 |
> changed one of its limitations is that it can't give up memory. That |
40 |
> is less of an issue if you're using swap since it can be swapped out |
41 |
> if idle. However, if you're not using swap then you're potentially |
42 |
> giving up a chunk of RAM to do it, though less RAM than a tmpfs if it |
43 |
> is full most of the time (which I doubt is typically the case). |
44 |
|
45 |
For similar needs I found zswap the most suitable, it's so much |
46 |
better than zram: |
47 |
|
48 |
- smaller CPU overhead: not every i/o is being compressed, e.g. if |
49 |
there is sill enough RAM available it is used without compression |
50 |
overhead as usual, but if memory is not enough, swapped out pages |
51 |
are being compressed instead of swapping out to disk; |
52 |
|
53 |
- no size limitation: if zswap pool is full, data is being pulled |
54 |
to swap, the same happens with non-compressible pages; |
55 |
|
56 |
- pool size and compression type can be dynamically adjusted, I |
57 |
prefer z3fold. |
58 |
|
59 |
So I have normal tmpfs on /tmp (and /var/tmp on hosts with lots or |
60 |
RAM), but both tmpfs and running daemons/apps can benefit from |
61 |
compressed memory for rarely used pages while enjoing full RAM |
62 |
speed for frequently accessed ones. |
63 |
|
64 |
Best regards, |
65 |
Andrew Savchenko |