Today's magic fix: Fast Konsole redraws with nvidia

There is something magical about hacking on things without having much clue about them. It almost feels like a treasure hunt, with mysterious traps all along the way and an elusive treasure maybe at the end. Today's treasure is KDE4's Konsole (preferably not) being awfully slow with some fonts. Specifically, as irony would dictate, the rule could be almost said that the better suited font for Konsole the slower the text rendering is, whereas if the font breaks the text layout completely or hurts to look at, the speed is just fine.

Profiling showed only that the CPU time was all spent in the X server in the nvidia driver, which is really not that helpful with something that is closed-source. It only meant that Qt was feeding to X something that the driver didn't like much. Eventually, I tracked it down to one XRenderCompositeText32() call in Qt (which, in a retrospect, wasn't really a very obscure hint - if there's something slow with drawing, suspecting XRender is always a worthwhile guess).

That showed where the treasure was, but now there was the part of getting it. Not that easy if the knowledge about font rendering doesn't go much further than knowing it's drawing text. Especially when it turned out that disabling the XRender path in the code resulted in some fonts being shifted one pixel down (and only some of them, so that it wouldn't be too simple).

But anyway, to make the story short, for those who want a share in the treasure, the patch is in the Qt bugtracker, waiting for somebody with more knowledge to answer the questions for which I don't know the answers. And home:lllunak:branches:KDE:Qt and home:llunak:branches:KDE:Qt:STABLE repositories have the 4.6/4.5 Qt packages with the patch added.


Thank you. I'm glad someone works with this :)

By pascal_a at Sun, 01/10/2010 - 23:57

Don't you have to assign copyright to Nokia or some similar bullsh*t?

By kamikazow at Mon, 01/11/2010 - 01:13

While I can't speak for Nokia, I'd reject the patch if I was them: to work around crappy performance of a proprietary driver, you're disabling acceleration for all drivers and probably regressing performance for everybody else. This bug needs to be fixed by NVidia in their driver. They really need to optimize their XRender implementation in many places, this is just one of them. But sadly, they only really care about OpenGL, because that's what the popular benchmarks test. The joys of proprietary drivers… They're not a sustainable solution and should just die!

By Kevin Kofler at Mon, 01/11/2010 - 08:49

FWIW, the performance problem seems to have disappeared for me with nVidia's latest beta driver, which features a lot of XRender work. At least I can now use the Terminus font again comfortably.

By eike hein at Mon, 01/11/2010 - 10:59

Using a lot konsole for work and fun, with a nvidia card and their drivers. please please please, don't remove optimizations everybody benefit from just for those crappy closed blobs.

Have someone tested removing this test just some rows after the place you made the diff?

2419 && elt.nchars < 253 // don't draw more than 253 characters as some X servers

2420 // hang with it

what's the result? which X servers are affected? old or just a different arch?

By vivo75 at Mon, 01/11/2010 - 16:38