18 April 2010

Optimized Build GLib Gives Boost?

I've been optimizing some GTK-related library in my Gimpscape installer without having actually benchmarked them. Today I found interesting demo called "mv-scalability-demo" from goocanvas (canvas based on cairo) which really squeeze your CPU alot, the program draw hundred thousands of simple box with text inside it into ultra-huge canvas. Visually, nothing complex from its GUI though.

GLib is the underlying library of GTK and some other too, so its reasonable that optimizing it will enable other library to gain the benefit too. In my build I try to limit my setting as far as Pentium 3 compatible (mmx+sse enabled).

The result:
vanila glib binary :  4.6s
Os+p3(mtune) :  4s
O3+p3(mtune)+fastmath* :  3.5s
O2+mmx+sse :  3.2s
Os+mmx+sse :  3.4s
*) not significant
GLib version 2.23.5
CPU E2160 1.8Ghz OC'ed @ 3Ghz
RAM: 2GB

Times are averaged from 3x benchmarks. Now something odd there!, I though that setting march/mtune as pentium3 is the same as add mmmx + msse yet its yield strikingly different. O3 is considered to be the most intense optimisation but not safe, as in my test it crashed on Python GObject binding. The best and safest setting is O2 which give us not so large binary size yet very fast indeed (30% faster).

In this case optimizing GTK didn't give much effect probably due to demo's simple interface. Strangely enough, though goocanvas use cairo as rendering engine optimizing cairo also didn't give apparent advantage anyhow.

No comments:

Post a Comment