1 |
On Tue, Feb 2, 2010 at 3:36 AM, Duncan <1i5t5.duncan@×××.net> wrote: |
2 |
> Mark Knecht posted on Mon, 01 Feb 2010 06:42:24 -0800 as excerpted: |
3 |
> |
4 |
>> On the new machine I've set it up as dual-head which is working nicely |
5 |
>> for all the basic stuff, and in general pretty nicely for running |
6 |
>> VMWare/WinXP on the second screen for most of the day. I have a few |
7 |
>> issues, like the mouse can become __very__ laggy in VMWare at times |
8 |
>> but other than that all the basics are there and working well enough |
9 |
>> to get some work done. I'm using XFCE4 at the moment. |
10 |
> |
11 |
> I wouldn't do vmware as it's servantware, and thus don't know a /whole/ |
12 |
> lot about it, but here's a bit of general wisdom on lagginess/latency |
13 |
> issues. Was it you that did a bunch of sound related stuff? If so, you |
14 |
> likely know (and have it set as appropriate) some of this already. |
15 |
> |
16 |
> First, what's your kernel tick time set for, 100, 250, 300, 1000 ticks per |
17 |
> second? Obviously higher ticks will help with latency, but it negatively |
18 |
> affects thruput. Also note that with SMP (multiple CPUs/cores), each one |
19 |
> ticks at that, so you can often turn down the ticks a notch or two from |
20 |
> what you'd normally have to run, if you're running SMP. |
21 |
> |
22 |
> Second, what's your kernel preemption choice? No-preemption/server, |
23 |
> voluntary-preemption/desktop, or full-preemption/low-latency-desktop? |
24 |
> Again, there's a trade-off between latency and thruput. If you're worried |
25 |
> about mouse lagginess, server isn't appropriate, but you can choose from |
26 |
> the other two. |
27 |
> |
28 |
> Third, there's additional low-latency kernel patches available... I'll |
29 |
> leave that alone as I run vanilla kernel. |
30 |
> |
31 |
> Fourth, there's I/O scheduling. Due to the way I/O works, often, the |
32 |
> kernel stops doing much of whatever else it was doing when it's handling |
33 |
> I/O. What I/O scheduler are you running, and have you noted the disk |
34 |
> activity LEDs blinking furiously (or conversely, no disk activity at all) |
35 |
> during your latency? How's your memory situation? How far into swap do |
36 |
> you typically run? Do you run /tmp and/or /var/tmp on tmpfs? |
37 |
> Particularly when you're emerging stuff in the background, having |
38 |
> PORTAGE_TMPDIR pointed at a tmpfs can make a pretty big difference, both |
39 |
> in emerge speed, and in system responsiveness, because there's much less |
40 |
> I/O that way. That's assuming, of course, that you have at least a couple |
41 |
> gigs of memory and aren't already starved for memory with your typical |
42 |
> application load. |
43 |
> |
44 |
> Fifth, priority. Have you tried either higher priority for the vmware |
45 |
> stuff or lower priority for other things, portage, anything else that may |
46 |
> be hogging CPU? (For portage, I like to set PORTAGE_NICENESS=19, which |
47 |
> automatically sets scheduler batch mode for it as well. The priority is |
48 |
> as low as possible so it doesn't interfere with other things to the extent |
49 |
> possible, while the batch mode means it gets longer timeslices, too, thus |
50 |
> making it more efficient with what it does get.) |
51 |
> |
52 |
> The above, save for priority, is mostly kernel related, so should have an |
53 |
> effect regardless of whether your vmware vm is mostly kernel or userland |
54 |
> implementation. The below is mostly for userland so won't work as well if |
55 |
> vmware is mostly kernel. I don't know. |
56 |
> |
57 |
> Sixth, are you using user-group or control-group (aka cgroup) kernel |
58 |
> scheduling, or not, and how do you have it configured? The kernel options |
59 |
> are under general setup. Cgroup scheduling gets rather complicated, but |
60 |
> user-group scheduling is reasonably easy to configure, and it can make a |
61 |
> **BIG** difference on a highly loaded system. Thus, I'd suggest user- |
62 |
> group scheduling. |
63 |
> |
64 |
> To enable user-group scheduling, enable Group CPU scheduler, and |
65 |
> (normally) Group scheduling for SCHED_OTHER, which is everything OTHER |
66 |
> than real-time threads. I leave the scheduling for SCHED_RR/FIFO off, as |
67 |
> unless you know what you are doing and have specific reason to mess with |
68 |
> real-time scheduling, it's best NOT to mess with it, because it's a VERY |
69 |
> easy way to seriously screw your system! |
70 |
> |
71 |
> Again, you probably do NOT want to mess with control group support, unless |
72 |
> you have specific needs beyond what user-group scheduling will do for you, |
73 |
> because that gets quite complicated. Therefore, leave that option off, |
74 |
> and under Basis for grouping tasks, make sure it says "(user id)". |
75 |
> That'll be the only option unless you have control group support enabled. |
76 |
> |
77 |
> Now, how do you use it? Simple. For each user currently running at least |
78 |
> one application, there's a /sys dir with the user id number (not name, |
79 |
> number, you need to know the number), /sys/kernel/uids/<uid>. In this |
80 |
> directory, there's a file, cpu_share. |
81 |
> |
82 |
> The contents of this file is the relative CPU share the user will get, |
83 |
> compared to other users, when the system is under load and thus has to |
84 |
> ration CPU time. The default share for all users save for root is 1024. |
85 |
> Root's default share is double that, 2048. |
86 |
> |
87 |
> So here's how it works. With user-group scheduling enabled, instead of |
88 |
> priority alone determining scheduling, now priority and user determine |
89 |
> scheduling. Once the system is under load so it matters, no user can take |
90 |
> more than their share, regardless of what priority their apps are running |
91 |
> at. If you want a particular user to get more time, double its share. If |
92 |
> you want to restrict a user, half its share. Just keep in mind that root |
93 |
> has a 2048 share by default, so it's wise to be a bit cautious about |
94 |
> increasing too many users up to that or beyond unless you boost root as |
95 |
> well, just to be sure. Various system housekeeping threads, kernel |
96 |
> threads, etc, use time from the root share, so you want to be a bit |
97 |
> careful about increasing other users above it, or the housekeeping |
98 |
> threads, disk syncs, etc, might not have the time to run that they need. |
99 |
> However, increasing just one single user to say 4096 shouldn't starve root |
100 |
> too badly even if that user gets a runaway app, as root will still be |
101 |
> getting half that time, as long as everything else remains at 1024 or |
102 |
> below. But obviously, you won't want to put say the portage user at 4096! |
103 |
> |
104 |
> I routinely bump my normal user to 2048 along with root, when I'm running |
105 |
> emerges, etc. This is with FEATURES="userfetch userpriv usersync" among |
106 |
> others, so portage is spending most of its time as the portage user, thus |
107 |
> with its default 1024 share. Boosting my normal user to 2048 thus ensures |
108 |
> that it (along with root) gets twice the time that the portage user does, |
109 |
> but even should one of my normal user apps go into runaway, root still |
110 |
> gets nearly half the CPU (more precisely, just under 40%, since root and |
111 |
> my normal user would each be getting double the portage user, with other |
112 |
> users not taking much as they'd not be in runaway, so root and the normal |
113 |
> user would get nearly 40% each, while portage would get nearly 20%, with |
114 |
> perhaps the other non-runaway users taking a percent or two, thus the |
115 |
> "nearly") if it needs it, which should be plenty to login as root and kill |
116 |
> something, if I have to, or to shut down the system in an orderly way, or |
117 |
> do whatever else I'd need to do. |
118 |
> |
119 |
> Even if I were to run my normal user at 4096 and it would have a runaway, |
120 |
> it would get 4 shares, portage would get one, and root would get two, so |
121 |
> even then, root would get nearly 2/7 or about 28% share, with the runaway |
122 |
> user getting double that or about 56% and portage getting about 14%. Even |
123 |
> 28% share for root should be enough, so that's reasonably safe. However, |
124 |
> I'd be extremely cautious about going over 4096, or increasing a second |
125 |
> user's share to that too, unless I increased root's share as well. |
126 |
> |
127 |
> That's actually simplifying it some, tho, as the above assumes all the CPU |
128 |
> hogs are running at normal 0 priority/niceness. But as I mentioned, I |
129 |
> have PORTAGE_NICENESS=19, so it's running at idle priority, which would |
130 |
> lower its claim to the portage user share dramatically. Basically, at |
131 |
> idle priority, it'd get very little share if there was another run away |
132 |
> (normal priority) process, as ANY user. (The scheduler /does/ normally |
133 |
> give /every/ process at least one timeslice per scheduling period, even at |
134 |
> idle priority, to prevent priority inversion situations in case of lock |
135 |
> contention and the like.) So the above percentage scenarios would be more |
136 |
> like 48/48/1/3 (root/user/portage/other) in the 2048/2048/1024s case, and |
137 |
> 32/65/1/2 in the 2048/4096/1024s case. Basically, the portage user, even |
138 |
> tho it's using all the CPU it can get, would still fall into the noise |
139 |
> range along with other users, because it's running at idle priority, and |
140 |
> root would thus get close to half or close to a third of the CPU, with the |
141 |
> normal user at equal share or double share of root, respectively. |
142 |
> |
143 |
> I've had very good results using that setup. Just for curiosity' sake, I |
144 |
> tried running ridiculous numbers of make jobs, to see how the system |
145 |
> handled it. With this setup (PORTAGE_NICENESS=19, portage user at 1024 |
146 |
> share, root at 2048, and normal user at either 1024 or 2048), I can |
147 |
> increase make jobs without limit and still keep a reasonably usable |
148 |
> system, as long as the memory stays under control. This is MUCH more so |
149 |
> than simply running PORTAGE_NICENESS=19 but without per-user scheduling |
150 |
> enabled. In practice, therefore, the limit on make jobs is no longer CPU |
151 |
> scheduling, but the amount of memory each job uses. I set my number of |
152 |
> make jobs so that I don't go into swap much, if at all, even with |
153 |
> PORTAGE_TMPDIR pointed at tmpfs. Because swapping is I/O, and I/O, due to |
154 |
> the way the hardware works, increases latency, sometimes unacceptably. |
155 |
> |
156 |
> Actually, my biggest thread test has been compiling the kernel, since it's |
157 |
> so easily parallellizable, to a load average of several hundred if you let |
158 |
> it, without using gigs and gigs of memory (yes it takes some, but nowhere |
159 |
> near what a typical compile would take at that number of parallel jobs) to |
160 |
> do it. I do my kernel compiles as yet another user (what I call my |
161 |
> "admin" user), so like portage, it gets the default 1024 share. But I |
162 |
> don't set niceness so it's running at normal 0 priority and taking its |
163 |
> full share against other 0 priority users. Compiling the kernel, I can |
164 |
> easily run over a hundred parallel make jobs without seriously stressing |
165 |
> the system. But even there, with user scheduling enabled and at normal |
166 |
> priority so the kernel compile is taking all the share it can, the memory |
167 |
> requirements are the bottleneck, not the actual jobs or load average, |
168 |
> because the kernel per-user scheduling is doing its job, giving my other |
169 |
> non-hog users and root the share they need to continue running normally. |
170 |
> |
171 |
> So assuming vmware is running in userspace and thus affected by priority |
172 |
> and user-groups, I'd definitely recommend setting up user-groups and |
173 |
> fiddling with its share, as well as that of the rest of the system, along |
174 |
> with the other steps above. |
175 |
> |
176 |
> The one caveat with user-group scheduling, is that the |
177 |
> /sys/kernel/uids/<uid> directories are created and destroyed dynamically, |
178 |
> as apps run and terminate as those users. It's thus not (easily) possible |
179 |
> to set a static policy, whereby a particular UID /always/ gets a specific |
180 |
> non-default share. There was a writeup I read back when the feature was |
181 |
> first introduced, that was supposed to explain how to set up an automatic |
182 |
> handler such that every time a particular UID appeared, it'd write a |
183 |
> particular value to its cpu_share file, but as best I could tell, the |
184 |
> writeup was already out of date, as the scripts that were supposed to be |
185 |
> called automatically according to the writeup, were never called. The |
186 |
> kernel hotplugging (and/or udev, or whatever was handling it) had changed |
187 |
> out from under the documentation, even as the feature was going thru the |
188 |
> process of getting the peer approval necessary to be added to the mainline |
189 |
> kernel. So I've never had an automatic policy setup to do it. It could |
190 |
> certainly be done using a file-watch (fnotify/dnotify, etc, or polling of |
191 |
> some sort), without relying on the hotplugging mechanism that was supposed |
192 |
> to work that I could never get to work, but I've not bothered. I've |
193 |
> simply created scripts to echo the desired numbers into the desired files |
194 |
> when I invoke them, and run them manually when I need to. That has worked |
195 |
> well enough for my needs. |
196 |
> |
197 |
> (Now you see why I'm not going into cgroups? user-group scheduling is |
198 |
> actually quite simple. Imagine the length of the post if I was trying to |
199 |
> explain cgroups!) |
200 |
> |
201 |
>> The one place where I've been a bit disappointed is when the VGA |
202 |
>> drivers need to switch resolutions to play a game like Tux Racer then |
203 |
>> instead of two desktops I'm seeing one desktop duplicated on both |
204 |
>> monitors. Is this normal or is there some general way to control this? |
205 |
>> I'd really like the game on one monitor and just have the other stay |
206 |
>> black. |
207 |
> |
208 |
> The problem here is that most resolution switchers simply assume a single |
209 |
> monitor. Before the X RandR extension, there was really no standard way |
210 |
> to reliably handle multiple monitor setups (xinerama, merged-framebuffer, |
211 |
> and proprietary or semi-proprietary methods like that used by the nvidia |
212 |
> and frglx drivers, were all in use at various times by various hardware/ |
213 |
> drivers, and for all I know there were others as well), so assuming a |
214 |
> single monitor was pretty much the best they could do. |
215 |
> |
216 |
> RandR has solved the standardization problem, but few games have upgraded |
217 |
> to it, in part because it's apparently "rocket science" to properly |
218 |
> program it. The xrandr CLI client works, but all too often, the X |
219 |
> environment tools are simply broken. KDE for example has had a tool |
220 |
> that's supposed to handle multiple monitors, changing resolutions, etc, |
221 |
> for some time, but on all three sets of hardware and drivers I've tried it |
222 |
> on, both the kde3 version and the kde4 version thru 4.3.4, it has screwed |
223 |
> things up royally if you're using more than one monitor. Only xorg's own |
224 |
> xrandr gets it right, and that's a CLI client, with a slew of options to |
225 |
> read about and try to master, before you can properly run it. I've |
226 |
> scripted a solution here using it, hard-coding some of the options I don't |
227 |
> change into the script (could be a config file) thus making my script |
228 |
> simple enough to run from the command line (or invoke from a menu entry) |
229 |
> without having to remember all the complicated syntax, but that's not |
230 |
> going to work for the CLI-phobic. And if the X environments can't get it |
231 |
> working correctly for many users even with the documentation and the |
232 |
> xrandr code to follow, what are the games folks supposed to do? So they |
233 |
> simply continue to assume only a single monitor... and screw things up for |
234 |
> those of us with more than one, at least if we prefer to run them in other |
235 |
> than clone mode. |
236 |
> |
237 |
> Because that's what's happening. When the games, etc, trigger the old |
238 |
> single-monitor resolution change API, it causes xorg to switch to clone |
239 |
> mode, running all monitors at the same resolution, showing the same thing. |
240 |
> |
241 |
> FWIW, the solution I've found, as I mentioned, is a script setup to invoke |
242 |
> my preferred resolutions, in my preferred non-clone modes, retaining my |
243 |
> preferred "stacked" monitor orientation, by invoking xrandr with the |
244 |
> appropriate parameters to do so. |
245 |
> |
246 |
> Thus I use my script (which uses xrandr) to set the resolution I want, and |
247 |
> set the game not to change resolution -- to run in a window or whatever, |
248 |
> instead. I run kde, and with kwin's per-app and per-window config |
249 |
> options, I set it up to always put the windows for specific games at |
250 |
> specific locations, sometimes without window borders etc. Between that |
251 |
> and triggering the resolution settings I want with my xrandr script, I can |
252 |
> get the game running in a window, but that window set to exactly the size |
253 |
> and at exactly the location of the monitor I want it to run on, while the |
254 |
> other monitor continues at its configured size and showing the desktop or |
255 |
> apps it normally shows. |
256 |
> |
257 |
> "Works for me!" =:^) |
258 |
> |
259 |
>> More disturbing is when I exit the game I'm left with both desktops |
260 |
>> displaying the same things and neither is exactly my original first or |
261 |
>> second desktop but rather a combination of the two which is fairly |
262 |
>> strange. (Desktop #1 icons with Desktop #2 wallpaper) |
263 |
> |
264 |
> Both desktops (monitors, I assume, that's quite different from virtual |
265 |
> desktops, which is how I'd normally use the term "desktop") displaying the |
266 |
> same thing is simply clone mode. You can try using your X environment |
267 |
> resolution tool (if xfce has such a thing, kde does and I think gnome |
268 |
> does) to switch back to what you want, but as I said, don't be surprised |
269 |
> if it doesn't work as expected, because they've really had problems |
270 |
> getting the things working right. xrandr gets it right, and you'd /think/ |
271 |
> they could if /nothing/ else read its code and use similar tricks, it /is/ |
272 |
> open source, after all, but kde certainly hasn't gotten it right, at least |
273 |
> not for many drivers and hardware, and from what I've read, gnome's |
274 |
> version isn't a lot better. |
275 |
> |
276 |
> But, if you're up for a bit of reading, you can figure out how xrandr |
277 |
> works well enough to get it to do what you want. Here's an example, |
278 |
> actually the debug output of the script I run, showing the xrandr command |
279 |
> as it's setup and invoked by the script (all one command line): |
280 |
> |
281 |
> xrandr --verbose --fb 1920x2400 --output DVI-0 --mode 1920x1200 --panning |
282 |
> 1920x1200+0+0/1920x1200+0+0/20/20/20/20 --output DVI-1 --mode 1920x1200 -- |
283 |
> panning 1920x1200+0+1200/1920x1200+0+1200/20/20/20/20 |
284 |
> |
285 |
> That results in: |
286 |
> |
287 |
> 1) an overall framebuffer resolution of 1920x2400 |
288 |
> |
289 |
> 2) output DVI-0 being set to resolution 1920x1200, with its top-left |
290 |
> corner at position 0,0. |
291 |
> |
292 |
> 3) output DVI-1 being set to a similar resolution (I have two of the same |
293 |
> model of monitor, 1920x1200 native resolution), but with its top-left |
294 |
> corner at position 0,1200, thus, directly under DVI-0. |
295 |
> |
296 |
> The panning mode stuff (except for the positioning bit) wouldn't be |
297 |
> necessary here as there's no panning to do, but those are the script |
298 |
> defaults. For use of panning mode, see this one: |
299 |
> |
300 |
> xrandr --verbose --fb 1920x2400 --output DVI-0 --mode 1280x800 --panning |
301 |
> 1920x1200+0+0/1920x1200+0+0/20/20/20/20 --output DVI-1 --mode 1280x800 -- |
302 |
> panning 1920x1200+0+1200/1920x1200+0+1200/20/20/20/20 |
303 |
> |
304 |
> This keeps the same overall framebuffer size and output orientation |
305 |
> (stacked), but the outputs are both run at 1280x800, with the panning |
306 |
> domain set for each one such that as the mouse gets to 20 px from any edge |
307 |
> of the 1280x800 viewport, it moves the viewport within the corresponding |
308 |
> 1920x1200 panning domain. |
309 |
> |
310 |
> Here's one with different resolutions, and with panning when the mouse |
311 |
> reaches the edge itself (instead of 20 px in) on the lower resolution and |
312 |
> position one (DVI-1), so I can run a game there, without it trying to pan |
313 |
> out as near the edge. I then put the viewport over the game and let the |
314 |
> game grab the mouse, so I can then play the game without having to worry |
315 |
> about panning. If I need to, I can have it "ungrab" the mouse, and have |
316 |
> panning again on the lower one, or move to the "fixed" upper one and do |
317 |
> stuff there. |
318 |
> |
319 |
> xrandr --verbose --fb 1920x2400 --output DVI-0 --mode 1920x1200 --panning |
320 |
> 1920x1200+0+0/1920x1200+0+0/20/20/20/20 --output DVI-1 --mode 960x600 |
321 |
> --panning 1920x1200+0+1200/1920x1200+0+1200/ |
322 |
> |
323 |
> When I'm finished with the game, or if I want to run normal resolution and |
324 |
> do something else for a bit, I just run that first command again, and it |
325 |
> returns me to normal mode as set by that first command. |
326 |
> |
327 |
> Unfortunately, kde4 still has a few bugs with multiple monitors, |
328 |
> especially when switching resolutions. As mentioned, the kde4 resolution |
329 |
> switcher itself is entirely screwed up as all it can handle is clone mode |
330 |
> (there's no way to set separate non-identical top-left corners for each |
331 |
> monitor), but there's bugs with the plasma desktop as well. If I do |
332 |
> happen to select clone mode, or disable one of the monitors using xrandr, |
333 |
> upon return to normal mode, plasma-desktop is screwed up. I can fix it |
334 |
> without restarting X/kde, but it's a hassle to do so, and somewhat trial |
335 |
> and error, zooming in and out the various plasma "activities", until I get |
336 |
> it setup correctly once again. Hopefully, 4.4 has improved that as well. |
337 |
> I read it has. We'll see... |
338 |
> |
339 |
>> I'm wondering if other environments handle this better. XFCE is |
340 |
>> pretty lightweight, which I like. I'd gone away from Gnome because of |
341 |
>> the time spent maintaining it on Gentoo but on this machine it probably |
342 |
>> wouldn't be all the bad. Not sure I want KDE but I'm curious as to |
343 |
>> whether anything solves this problem? |
344 |
> |
345 |
> Well... kde 3 worked reasonably well in this regard (except its resolution |
346 |
> switcher wasn't much good either, I used X's ctrl-alt-numplus/numminus |
347 |
> zooming while it worked, then developed the xrandr scripts I still use |
348 |
> today when x switched to randr based switching and the numplus/numminus |
349 |
> zooming didn't work any more, but the desktop at least stayed put), but as |
350 |
> you can tell, I'm rather frustrated with kde4. |
351 |
> |
352 |
> But definitely try xrandr. It's a pain to learn as it's all CLI options |
353 |
> not point and click, but it's remarkably good at doing what it does, once |
354 |
> you know how to run it, and possibly hack up a script or several to take |
355 |
> the complexity out of it. |
356 |
> |
357 |
>> Logging out of XCFE and then running startx gets everything back |
358 |
>> the way I want, and I don't think I'll play Linux games much, but I'm |
359 |
>> curious as to how well other environments handle this. |
360 |
> |
361 |
> As explained, the base problem is that games assume single monitor, which |
362 |
> X construes as a command to go into clone mode. The solution is to use an |
363 |
> external app (such as the xrandr invoking scripts I use) to set the |
364 |
> resolutions you want, and don't invoke the games' options to change |
365 |
> resolution or whatever, just have them run in a window. Then match the |
366 |
> window size to your desired resolution (enforcing it using your window |
367 |
> manager, if that's more convenient or necessary), and invoke the script |
368 |
> (or other external to the game resolution switcher app) changing the |
369 |
> resolution right before you run the game. |
370 |
> |
371 |
> Alternatively, since we're talking about a script already, you could set |
372 |
> it up so the script runs xrandr to change the resolution as desired, then |
373 |
> runs the game, then when the game is done, changes the resolution back. |
374 |
> |
375 |
> -- |
376 |
> Duncan - List replies preferred. No HTML msgs. |
377 |
> "Every nonfree program has a lord, a master -- |
378 |
> and if you use the program, he is your master." Richard Stallman |
379 |
|
380 |
Duncan, |
381 |
I don't think the word 'Thanks' can express my thoughts as I scan |
382 |
through everything you've written here. It will probably take me weeks |
383 |
to digest this and gain any real understand. That said I had played a |
384 |
bit with xrandr before I set up my xorg.conf file. I'll investigate |
385 |
your scripts more fully and see if I can figure out how that might |
386 |
work for me. There's just too much there for me to respond more at |
387 |
this moment. |
388 |
|
389 |
Cheers, |
390 |
Mark |