In my Mono (C#) project that is meant to be cross-platform, I am using the GTK for the UI. However one thing I noticed is, on my netbook in Archlinux, the performance is really speedy, so events such as mouse hover, and redrawing of widgets, etc, are really fast.
Compared to windows (7) on dual core CPUs, the performance is really really weak. Which perplexes me.
Am I doing something wrong that is warranting this difference in performance between OSes?
What are some ways I can do to optimize GTK on Windows? Its really bad to take around 0.5 secs for a hover event to kick in whereas its almost immediate on a weak(er) netbook with Linux.
My code is here for the GUI layer: http://code.google.com/p/subsynct/source/browse/branches/dev/subsync#subsync/GUI
Thanks!
The real problem is with the Graphics Library GTK uses. Cairo. You are right in saying that GTK performs a lot better on Linux and other Operating Systems as compared to Windows. That suggests that in fact the problem isn't actually with the entire Cairo Library. It is in the Win32 backend of Cairo. According to the Backend-Info in Cairo Docs; Cairo uses xlib and in some cases cairo-gl (think customized OpenGL) to work with on Linux and other platforms. While on Windows it uses Win32 GDI which, after all is a bit slow and outdated (not to mention completely software rendered).
Still, even this doesn't account completely for the poor performance of Gtk on Windows. Another problem may be that instead of using native Widgets, Gtk prefers to draw it's own widgets which look the almost the same on all platforms. However on Windows it also tries to emulate the native widgets using LibWimp to further increase native look and feel. This extra Windows-only step may also account for performance overhead. To see this for youself, try deleting (or renaming) libwimp.dll in the GIMP directory. GIMP runs a lot faster after that (though looked a little non-native).
There are also other smaller factors that may or may not affect Gtk's performance on Windows, like the fact that GTK has an extra runtime with like 12-15 extra dll's compared to other toolkits which have like 1-2. Dynamically Linking the entire Gtk Runtime may greatly increase startup time. There is also the fact that Gtk uses a lot of other libraries like Glib , Pango , and of course , Cairo . Writing glue code for these libraries also adds a lot of overhead , and sometimes even an extra library like Gdk .
To optimise Gtk you may try changing the backend of Cairo (difficult , unreccomended and requires another ton of glue code) or stop using libWimp (this will make Gtk look less native). But overall I think GTK is not that slow. I've never personally needed to use any optimizations. Even though I used WinApi in the past too.
I would guess that the performance problems are in Cairo. I suggest you use gtkparasite in Linux to see where and when parts of your app are being redrawn and optimize that.
You could also use the free CLR Profiler from MS on Windows to find the hotspots in your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With