Poor GTK + (GTKSharp) performance on Windows

In my Mono (C #) project, which should be cross-platform, I use GTK for the user interface. However, I noticed that on my Archlinux netbook, performance is very fast, so events like mouse hovering and redrawing widgets, etc., are very fast.

Compared to windows (7) on dual-core processors, the performance is really very weak. What puzzles me.

Am I doing something wrong that justifies this difference in performance between the OS?

How can I do to optimize GTK on Windows? Its really bad to take 0.5 seconds for a hover event to start, while its almost immediately on a weak Linux netbook.

My code is here for the GUI layer: http://code.google.com/p/subsynct/source/browse/branches/dev/subsync#subsync/GUI

Thanks!

+3
source share
2 answers

The real problem is using the GTK graphics library. Cairo. You are correct that GTK works much better on Linux and other operating systems than Windows. This suggests that, in fact, the problem is not really related to the entire Cairo library. It is located in the Win32 backend in Cairo. According to Backend-Info at Cairo Docs; Cairo uses xlib and, in some cases, Cairo-GL (I think, configure OpenGL) to work on Linux and other platforms. Although on Windows it uses Win32 GDI , which is, after all, a bit slow and outdated (not to mention all the software).

However, even this does not fully account for the poor performance of Gtk on Windows. Another problem, maybe, instead of using custom widgets, Gtk prefers to make its own widgets , which look almost the same on all platforms. However, on Windows, it also tries to emulate native widgets using LibWimpa> to further increase the look. This additional step for Windows only may also take into account performance overhead. To verify this, try deleting (or renaming) libwimp.dll in the GIMP directory. After that, GIMP works much faster (although it looks a bit unnatural).

There are other smaller factors that may or may not affect the performance of Gtk on Windows, for example, the fact that GTK has additional runtime, for example, 12-15 additional dlls compared to other tools that have as 1-2 . Dynamically linking all Gtk runtimes can significantly increase startup time. There is also the fact that Gtk uses many other libraries, such as Glib , Pango , and, of course, Cairo . Writing glue code for these libraries also adds a lot of overhead, and sometimes even additional libraries like Gdk .

To optimize Gtk, you can try changing the backend in Cairo (complex, unreasonable and requires a ton of glue code) or stop using libWimp (this will make Gtk less native). But overall, I think GTK is not so slow. I never had to use any optimizations. Although I used WinApi in the past too.

+5
source

I would suggest that performance problems are in Cairo. I suggest you use gtkparasite on Linux to see where and when parts of your application are redrawn and optimized.

You can also use the free CLR Profiler from MS for Windows to find hot spots in your application.

+2
source

Source: https://habr.com/ru/post/1205240/


All Articles