1 |
Frank Peters <frank.peters@×××××××.net> posted |
2 |
20090708095104.39a8a53e.frank.peters@×××××××.net, excerpted below, on |
3 |
Wed, 08 Jul 2009 09:51:04 -0400: |
4 |
|
5 |
> However, I am not clear on how tmpfs will fail. If the tmpfs mount |
6 |
> becomes filled or exceeds the file limit, since it is essentially just |
7 |
> another disk partition shouldn't it produce a "No more space left on |
8 |
> device" error? Or is the system designed to extend the tmpfs through |
9 |
> swapping? The latter option doesn't seem right, but everyone still |
10 |
> refers to such behavior. |
11 |
|
12 |
tmpfs is specifically /not/ pinned in real-memory, and only gets the "no |
13 |
space left on device" error when it maxes out. (Note that the tmpfs |
14 |
default max side if not specified is half of real memory, the default max |
15 |
inodes are half of the memory page-count, which @ 4KB pages, means 256/MB |
16 |
or 262,144/gig.) |
17 |
|
18 |
So yes, tmpfs swaps just fine, because it's not pinned memory and running |
19 |
out of real memory is not no-space-on-device, as long as there's swap. |
20 |
|
21 |
For purposes of memory tracking, BTW, (unswapped) tmpfs is reported as |
22 |
cache, tho in some ways it really behaves more like (dirty) app memory in |
23 |
that it can't be simply dropped as the disk-read-cache can (since for |
24 |
cache the data is already on disk and can simply be read back from there |
25 |
if it's needed), but must be actually written out to swap, like dirty app |
26 |
memory. |
27 |
|
28 |
But regardless, pointing portage's working dir at tmpfs is still |
29 |
generally faster than having it on a normal disk filesystem, because the |
30 |
worst-case for tmpfs, is the normal-case for a normal disk filesystem -- |
31 |
that it actually has to write the stuff to disk for a bit, before reading |
32 |
it back in and ultimately deleting it. |
33 |
|
34 |
Of course, the same basic effect could be had by pointing portage at an |
35 |
ext4fs, configured with huge (several gig) max write buffers and long |
36 |
(like an hour) sync timeouts. Except even then ext4 wouldn't be quite as |
37 |
good, because there's shortcuts the kernel can take with the explicitly |
38 |
temporary data of a tmpfs that it can't take with ext4. That's the |
39 |
theory, anyway. It'd be interesting to benchmark it. Oh, and if the |
40 |
system /does/ crash in the middle of something, with tmpfs it's all |
41 |
"magically" cleaned up, while with ext4, whatever files had been written |
42 |
to disk would have to be cleaned up after the reboot. So even if the |
43 |
benchmarks don't quite live up to the theory, avoiding that cleanup |
44 |
hassle is very likely worth it. |
45 |
|
46 |
-- |
47 |
Duncan - List replies preferred. No HTML msgs. |
48 |
"Every nonfree program has a lord, a master -- |
49 |
and if you use the program, he is your master." Richard Stallman |