Gentoo Archives: gentoo-amd64

From: Duncan <1i5t5.duncan@×××.net>
To: gentoo-amd64@l.g.o
Subject: [gentoo-amd64] Re: Managing CPU usage when doing emerges
Date: Tue, 19 May 2009 13:29:49
Message-Id: pan.2009.05.19.13.29.27@cox.net
In Reply to: Re: [gentoo-amd64] Managing CPU usage when doing emerges by Branko Badrljica
1 Branko Badrljica <brankob@××××××××××.com> posted
2 4A12AF80.8040705@××××××××××.com, excerpted below, on Tue, 19 May 2009
3 15:09:20 +0200:
4
5 > Which is more or less ext4 performance if files remain in RAM. When
6 > memory pressure increases, ext4 wil just start writing to the files,
7 > which can actually be faster than tmpfs <--> swap transfers...
8
9 You bring up a very interesting point. I wonder if anyone has
10 benchmarked both in-memory and to-disk operation of ext4 with extreme
11 write-out times and data=writeback, as compared to tmpfs, hitting swap
12 for disk.
13
14 Now let me be plain, I wouldn't trust valuable data I need to keep around
15 to ext4 yet, unless I was certain of my backups. (Of course if it's
16 valuable data you want to keep around, you have and have tested your
17 backups in any case, AND keep them updated to the point at which you'd be
18 comfortable losing data, whether that be a few minutes/hours worth or six
19 months worth, but there's a LOT of folks that simply do not have backups
20 at all, and ext4 isn't yet something I'd recommend to them unless they
21 don't care about losing the data at all.) Maybe by 2.6.31, if .30 ext4 is
22 demonstrated stable enough not to be still taking big tweaks in .31, but
23 that's not yet the case with .29 as .30 has some pretty big changes.
24
25 However, that's NOT what we're talking here AT ALL. Here, we're talking
26 specifically temporary data, intended to be wiped before reboot, such
27 that we don't care if it ever hits disk at all. For that, ext4 is
28 definitely MORE than acceptable at this point.
29
30 Here's the deal, tho. With tmpfs, since the devs know it's not intended
31 to hit disk /at/ /all/ unless as swap, there's whole sections of normal
32 filesystem code that simply don't apply at all. That's not a /lot/ of
33 overhead when we're talking writing to the slow disk anyway, but it's a
34 bit more significant when we're talking memory-speed operations. That,
35 and the flexibility of tmpfs to use swap when necessary, has
36 traditionally made it an extremely good choice for such temporary data.
37
38 If we stop right there, ext4 would still have higher overhead, even with
39 delayed write, and would thus be a characteristically worse choice.
40 HOWEVER, and a BIG HOWEVER it is, there's a a particular caveat with swap
41 where ext4 gets an extremely good mark, that may well turn the tables.
42
43 The problem with swap in general, and thus anything that ends up using
44 it, is that it has sort of been the ugly stepchild no one has bothered to
45 do a whole lot with. The attitude of the kernel devs has seemed to be
46 that with memory so cheap these days, there should be no reason to be
47 using swap under normal operating conditions anyway; that it's only an
48 extreme worst-case solution to exercise right before the OOM-killer goes
49 to work, and that as a result, any serious work optimizing it beyond sane
50 minimums is "wasted". This has of course been somewhat controversial,
51 particularly for users of older systems with < a gig of memory capacity,
52 total, and only a single disk, but the fact is, swap /has/ been a
53 somewhat ignored subsystem.
54
55 Obviously, ext4 is anything /but/ ignored. Thus, it might actually be
56 worth the (at least in theory) somewhat higher memory overhead if the
57 disk access is significantly more optimized than swap disk access is, and
58 as explained above, that's a reasonably likely case.
59
60 Of course, as you stated earlier in passing but no one has actually
61 fleshed out, this assumes anything BUT default ext4 writeout expiry
62 parameters. We're talking expiry times on the order of an hour, instead
63 of the default few seconds, thus keeping data in memory for the entire
64 emerge, so the whole working dir can be created, the sources unpacked to
65 it, the binaries compiled and whatever else needs done to the sources,
66 fake-installed, qmerged to the live filesystem, then the whole thing,
67 scratch files, sources, working dir, all of it, deleted, before the ext4
68 write-out expiry occurs, assuming no memory pressure to cause the
69 writeouts earlier.
70
71 But it's a valid question to raise and one I've seen no discussion of,
72 anywhere, certainly not in the LWN and HOnline coverage that's where I
73 get most of my kernel information from. Under that sort of explicit
74 temporary use only tweaking of the ext4 tuning knobs, exactly how /does/
75 it compare to tmpfs, both under memory-only scenarios and under memory-
76 pressure-therefore-swapped-or-written-out scenarios. Benchmarks are
77 definitely called for, as it's a very legitimate and unsettled question,
78 going on theory alone.
79
80 Of course, in a typical single-disk usage scenario, with both a swap and
81 this dedicated ext4 temp partition we're talking about, it would very
82 likely depend on the partition ordering, with whichever partition is
83 closest to the outside of the disk getting the better marks as the
84 physical disk I/O will be faster to it. But, for the benchmark the two
85 partitions could be swapped, and that compared against having the OTHER
86 one on a separate device, say swap on a different device when testing the
87 ext4 partition, just so it didn't interfere.
88
89 Another typical case-by-case factor would be what other data is read/
90 written and how close it is to the partition in question. (For our case,
91 the Gentoo tree and sources and system header, etc files, read, the
92 package database, live filesystem destinations, and binpkg location if
93 that feature is turned on, write, and ccache both r/w if it's on, are the
94 system data that would be accessed during the build.) That sort of thing
95 would have to be kept in mind and controlled for as well, in addition to
96 the usual effort at keeping unrelated process activity to a minimum
97 during the benchmark to avoid screwing the outcome.
98
99 Sounds interesting to think and read about, if someone has a link. But
100 honestly, I don't personally care enough about it to do the benchmarks or
101 even to spend time looking to see if there are any, myself.
102
103 So, does it sound like fun to anyone? For all I know someone's already
104 tested it. I haven't been following ext4 development close enough to
105 know for sure, if I didn't simply happen across it.
106
107 --
108 Duncan - List replies preferred. No HTML msgs.
109 "Every nonfree program has a lord, a master --
110 and if you use the program, he is your master." Richard Stallman

Replies

Subject Author
Re: [gentoo-amd64] Re: Managing CPU usage when doing emerges Richard Freeman <rich0@g.o>