Linux desktop performance: newbie edition

Discussion in 'all things UNIX' started by Gullible Jones, Jan 4, 2014.

Thread Status:
Not open for further replies.
  1. Gullible Jones

    Gullible Jones Registered Member

    May 16, 2013
    [Disclaimer: I am not a Linux expert. The following is not guaranteed to be true. If there are errors, please help me correct them; I'd appreciate it. Thx.]

    There's a lot of stuff on the Internet about improving Linux desktop performance. Much of it caters to new Linux users. Most of it (including a lot of the stuff that I wrote in years past :) ) is bunk. Performance is a complex problem for which there are no easy fixes, on the desktop as on the server.

    In very general terms, though, the major ways to improve performance on a fully functional system are:

    1. More powerful hardware

    2. Better code

    3. Less code

    #1 is not always possible (or desirable) and #2 is mostly outside the domain of end users, so I'll focus on #3.

    This is not just a matter of CPU cycles. More stuff running means
    - More context switches on the CPU (from switching between different processes)
    - More cache misses (because what you want in the CPU caches is more likely to get pushed out of them by something else)
    - More disk I/O (from logging, memory paging, reading config files and libraries, and whatever else)

    Having a lot of code running in the background can therefore reduce a desktop's performance, even if CPU usage is not high.

    The good news is, the most effective methods of tackling this are neither difficult nor obscure. They are, in rough order of efficacy and preference:

    1. Use lighter applications. For instance, decline Firefox in favor of Chrome (or some other Webkit based browser) if possible. I use Midori on my netbook, and the difference between it and Firefox is pretty stark.

    Another example: file management. PCManFM (from LXDE) or Thunar (from Xfce) can work as standalone file managers, without the rest of their respective desktop environments. There's no reason you can't use PCManFM, for instance, on a Gnome desktop if Nautilus (the Gnome file manager) is too slow.

    2. Use a lighter desktop. The window manager (and panels, and desktop manager, etc.) are also code, sometimes rather a lot of it.

    On desktops you can get away with using very lightweight window managers without compromising usability much. Openbox is probably the most popular of these; it's fast, simple to use, and most distributions automatically generate a launcher menu for it. Fluxbox is also popular, and has more features (e.g. a toolbar at the bottom with a clock and icon tray).

    Pretty much any light window manager can be used with all the applications available on a full desktop (Unity, KDE, or Gnome). Things may not look as pretty, but they will probably be a bit faster.

    On laptops it can be harder for novices to use a standalone window manager, mostly due to lack of convenient power and network management. Fortunately, LXDE lets you use Openbox with desktop icons and a WinXP-style panel. If LXDE doesn't provide enough features, you can use Xfce,

    3. Use lighter application themes. The default themes tend to be beautiful but very heavy on most distributions.

    For GTK2, anything with fewer curves and/or gradients is probably good (because less math is involved for the computer). The flatter and squarer it is, the better. Themes like Mist and Redmond are the fastest on GTK2.

    For Qt, I would recommend the Plastique, Cleanlooks, or Win9x theme engines (all of which are built into the Qt graphical toolkit). Win9x is probably the fastest, but all of them are much more responsive than Oxygen.

    NB: Be careful about installing themes from unknown sources. A third-party theme for GTK should be an archive, to be unpacked to the .themes folder in your home directory. It should not be a .deb, .rpm, or .tgz package, and should absolutely not require root privileges to install. Malware can be and has been distributed in packages masquerading as GTK themes.

    4. Use lighter window manager themes. This is mostly a problem with KDE, where some of the prettier themes for KWin are hugely resource intensive. The Oxygen window theme (and Plastique too, in recent KDE versions) is very slow. Themes like Laptop and Win9x are not so pretty, but much more friendly to weak graphics cards.

    (You can also use Openbox as a KDE window manager. Just install it, open the KDE control center, go to Preferred Applications -> Window Manager, and select Openbox as the default WM.)


    And before anyone jumps on me for simlplifying things: no, that's definitely not all. These are just some very general recommendations for Linux novices. As I said earlier, performance is a complex problem.

    Also, the above assumes (again) that your Linux system is functioning properly. You can't always assume that! Hardware issues (e.g. dying hard disks) and software issues (e.g. configuration errors) can both manifest as performance problems. If your Linux desktop/laptop is just a little sluggish, my post may apply. If on the other hand it is completely unusable, and not obviously underpowered, then there is probably something wrong with it!

    And one final note: Linux can run on some surprisingly slow hardware. The lower limit right now is probably a Pentium II with 192 MB of RAM. I know this because I ran Linux on such a machine a couple years back:

    And it worked well enough for browsing and word processing. Try that with Windows 7. :p

    In conclusion:
    - Desktop feature creep reduces performance
    - Needless eyecandy reduces performance
    - If a program performs badly, see if a less featureful program is adequate for your needs
    - Don't bother with obscure tweaks, they're useless at the best of times

    Alright that's enough. :) Hope this post was helpful.
  2. mirimir

    mirimir Registered Member

    Oct 1, 2011
    Thanks :)

    I have one key addition. If performance suddenly degrades, swap usage is one of the first things to check. That's especially so for RAM-starved VMs.
  3. Gullible Jones

    Gullible Jones Registered Member

    May 16, 2013
    Yes... With some caveats.

    - Your system may swap without serious loss of performance. If the time between paging something out of RAM and reading it back in is usually long, then you won't notice. If on the other hand it's paging stuff out and then reading it right back in (aka thrashing, usually due to low memory conditions) then you will definitely notice.

    - Lowering swappiness may be useful under some weird workloads, but in most cases this is what will happen:
    1. Your computer will be faster for a while.
    2. Firefox or whatever starts eating memory.
    3. Suddenly you hit a giant brick wall of swapping, and everything locks up.

    - Don't run without swap if possible. If you do so your system will be less stable, and you will probably notice performance degradation under load (because idle proceses can't be paged out effectively).

    If you are routinely getting system lockups due to excessive swapping, you should figure out what's swapping and whether you actually need it. If it's something you definitely need, you should probably file a bug report. If you really have no other recourse, you could probably get away with using a smaller swap space... But relying on the OOM killer to save you is probably a really bad idea. Even with oom_kill_allocating_task=1 (because maybe, just maybe, the allocation that triggers it won't come from the memory hog).

    In summary: try to avoid OOM conditions, because once they occur there's not much you can do. IMO anyway.
  4. Mrkvonic

    Mrkvonic Linux Systems Expert

    May 9, 2005
    Hardware is your best bet :)
  5. Gullible Jones

    Gullible Jones Registered Member

    May 16, 2013
    Well yes, but it's not always an option. (e.g. if you're trying to resuscitate an old laptop, and don't want to spend money on it.)
  6. NGRhodes

    NGRhodes Registered Member

    Jun 23, 2003
    Don't forget simply disabling stuff also works :)
    Ubuntu, you can use CCM to turn of various features in Compiz, KDE allows turning off of many (all ?) effects.
    Most addition services like indexing (nepromuk/unity scopes service) can also be disabled.

    When comparing options, you need to do like for like comparision of the features you need/use/want, its okay saying XFCE is lighterweight option than Gnome, but it you also get a lot less features and if useful things are added back in that you need (for example keyring and graphical sudo), a fully functioning network manager, the differences can quickly become less significant.

    Another thing to consider is the shared libraries your system uses and trying to reduce them.
    If you are using a GTK based desktop, QT apps add bit of overhead, but some KDE apps cause loads of additional overhead (I noted Kate uses an additonal 100meg ram on a GTK based desktop).
    Similarly if you say use VLC, which uses FFMPEG based decoding, but then you use Empathy on the same system, which depends on telepathy which uses the gstreamer libs you can have 2 different sets of media playing libs installed and running at the same time.

    Cheers, Nick.
Thread Status:
Not open for further replies.