Saturday, September 22, 2007

KWin improvements

I first wanted to blog about KWin changes after returning from aKademy but then I never got to doing it. After that I've thought something like "once I'll complete this feature, I'll blog" a few times but then another interesting thing came up...
But finally, here's a summary of cool stuff that has happened in recent months:

One of the most interesting things is compositing settings autodetection. KWin now tries to detect your video driver and it's version and if it's good enough then compositing will be enabled by default. ATM it'll be enabled for NVidia drivers >= 96.39 and for Intel >= 20061017. If you know which settings work for another card/driver then please report it to kwin mailing list or post a comment here.

When you enable compositing yourself or change some of its settings, you'll get a confirmation dialog which will revert back to previous, hopefully working settings if you won't respond in 10 seconds (it's similar to the one you get when changing resolution. In fact there's plan to use exactly the same dialog). ATM it's a bit unreliable in that KWin sometimes crashes when reloading it's settings but hopefully it'll be fixed soon.

Speaking of KWin crashes, we're planning to make KWin restart itself in such cases (just like Plasma or KRunner) and eventually turn off compositing so that you'd always have a usable window manager, even when compositing has some problems.

Then there's the not-so-new-anymore compositing config module where you can turn on compositing and effects. Since a few days ago it also includes the entire list of effects so there's no separate "Window effects" config module for that anymore.

One of the biggest usability complaints - effect shortcuts aren't listed anywhere - is also starting to get solved. I added shortcuts to PresentWindows config module. I'm still not sure if all effects should have a config module just to show the shortcuts or if it would be better to just list the shortcut in effect's description (e.g. "Shows all desktops side by side when Ctrl+F8 is pressed"... or just "Shows all desktops side by side (Ctrl+F8)"). We've still got a little time to figure it out.

There are a few new effects as well. Invert and Sharpen effects were added during aKademy and Looking Glass - a fancier-looking magnifier - a little after it.

Old effects have received some polishing. PresentWindows and BoxSwitch both show window captions and icons. Shadows are nice and round (and unfortunately a bit slow). Some animations are faster, making KWin feel snappier.

I'm not posting any videos this time but if all goes well, you should see one in beta3's announcement.

Sunday, September 2, 2007

Iconcache benchmarking results

In the last three days I've been fixing some last bugs in KPixmapCache, benchmarking it and analyzing the results. Here they are.

It's going to be a long post, so the short story is: the cache reduces KDE startup time by about 1 second (~ 9%), depending on how many and which applications are autostarted. Startup time of individual applications is somewhat reduced as well, but the exact numbers depend on the application (more specifically, on how many icons they use).

I benchmarked KDE startup on two computers: my desktop and laptop.
Desktop is custom built with AMD Athlon 2800+, 1Gb memory and SATA hard drive.
Laptop is Dell Inspiron 6400, with Intel Core Duo T2350 with 2Gb of memory.
Operating system on both computers is Kubuntu Feisty, with all updates.
KDE was pretty much 4.0 beta2, I updated SVN at 29/08 about 1400 UTC.
I used a bit customized Bootchart and kpc-stats patch for benchmarking.

For numerical data I used two things: first, CPU time which is amount of time that system was not idle, gotten from /proc/uptime.
Second, startup time reported by kpc-stats which is time elapsed from when the first KPixmapCache object is created (by kded4 at the very beginning of the KDE session) until when the last icon is found or inserted to the cache (at which point all applications should be started). This can be thought of as a perceived startup time, it shows how long it takes until KDE is ready for use.
I tested with both default KDE startup (referred to as bare KDE) which starts only Plasma, Kicker, KWin, KTip (and background programs) as well as "full KDE" which also starts Konqueror, KBounce, KMPlot and Dolphin and is meant to simulate full KDE session where many programs are started and/or restored.
Every case was ran 3 or 4 times and average time was used. Disk caches were dropped before each run.

The numbers:
CPU time: Bare KDE on desktop computer: 9985 vs 8933 ms, win is 1052 ms or 11,8%. On laptop 6717 vs 6088 ms, win is 630 ms / 10,3%.
Full KDE: desktop - 20636 vs 19525 ms, win is 1111 ms / 5,7%. On laptop - 9722 vs 8968 ms, win: 755 ms / 8,4%.
Startup time: Bare KDE on desktop - 13810 vs 12572 ms, win is 1237 ms / 9,8%. On laptop - 9889 vs 9075 ms, win: 814 ms / 9,0%.
Full KDE: desktop - 24905 vs 23690 ms, win: 1215 ms / 5,1%. Laptop - 13138 vs 11965 ms, win: 1174 ms / 9,8%.

Some bootchart images:

Bare KDE startup on desktop, without (left) and with (right) iconcache.


Full KDE startup on laptop, without and with iconcache.

You can see from the numbers that the icon cache gives almost 10% improvement. Another interesting observation is that improvement in full KDE session isn't much bigger than in bare KDE. On desktop the improvement is pretty much the same, only in laptop is it a bit bigger with full session. Possible reason is that laptop's CPU is faster and thus I/O becomes bigger bottleneck, especially as it's HDD is also slower (5400 vs 7200 rpm).
Most of the 1-second improvement probably comes from the fact that icon theme initialization, which scans all icon dirs, can be skipped when icon cache is present because needed info is already stored in the iconcache header.
You can visually see the improvement when flipping between bootchart image pairs. On with-iconcache images, the later part of the graph has shifted about 1-1.5 seconds forward. You can also see there that the 1-second improvement comes from kded process which is where the expensive icontheme initialization takes place.

I didn't benchmark the applications again since I have already done so earlier (and the numbers shouldn't be really different) and because it was more painful to do than benchmarking full KDE.
Only exception was Dolphin which was the first app I tried to benchmark (after that one I didn't bother with the rest) and which showed a 400ms (11.4 vs 11.0 sec) improvement in cpu time and 1.5 sec (12.6 vs 11.1 sec) improvement in startup time. This fits with my earlier benchmarks quite well. Also note that the earlier benchmarks were all done on the laptop while this one was done on desktop, that's why the absolute times are so different.

Last but not least, keep in mind that absolute performance improvements aren't the only advantage the icon cache brings. It also makes some things possible which would have been way too slow without it. Also there's the generic pixmap cache which is already being used in quite a few games to speed up rendering of game elements and background from SVGs.

And finally, since this is quite likely my last GSoC-related post, I'd like to thank my mentors and the whole KDE community for helping and supporting me as well as Google for organizing the SoC and supporting open-source development.
Keep up the great work everyone! :-)