gstreamer + cairo == awesome

For the last few days, I’ve been listening to the gstreamer devs get excited about cairo, simply because it is awesome! Well actually because over the last couple of years the drivers have developed sufficiently that the abstraction offered by cairo solves several of the problems that the gstreamer developers have had to previously hacked around. This means that they get to dump all of their multi-threaded decoding and rendering problems on us, which makes them very happy.

In return for the extra work, we promise to make it fast as well. At the base we will be [eventually] including a jit into pixman, so that we can generate optimised code at runtime for the more obscure colorspace conversions without bloating the library by compiling thousands upon thousands of pre-computed, even hand-rolled, fast paths. But pixman is not the interface we want to present to applications, so we have an abstraction layer over that which allows applications to target GPUs, DSPs or the CPU with nary a care in the word – this is cairo. From the discussions we had, it emerged that to resolve many of the locking issues and general thread-safety concerns within gstreamer, required exposing some of the support cairo uses internally to reach its own thread-safety guarantees. However, not all backends are created equal and we will also need to fixes to the underlying libraries. For X11, this means we need to switch to xcb and for GL we need a new GLX extension to permit more efficient multi-threading.

Beyond that Benjamin is pressing for an aggressive timeline, cairo-1.10 in January so that we can make the next round of stable distributions. As my current development branch has over 40k lines of changes, with much more work required, this is quite a challenging schedule. Compared to that adding the extra interfaces and fixing the inevitable bugs is a tiny amount of work!

Just an update incorporating suggestions into the presentation of the graphs – the principal change being to trim outliers from the relative performance graph. Let me know what you think.
cairo-perf-chart-absolute
cairo-perf-chart-relative

[graphs uploaded outside of wordpess to avoid rescaling]

As nobody appreciated the relative factors as a performance metric, here are the absolute times for tiny.
cairo-perf-chart
cairo-perf-chart-relative

image xlib xvfb gl drm
evolution 69.9 74.8 186.4 146.3 103.6
firefox-planet-gnome 217.5 170.8 295.1 359.9 100.1
firefox-talos-gfx 342.1 193.5 305.1 645.3 48.9
firefox-talos-svg 375.3 684.8 621.1 709.7 876.1
gnome-system-monitor 39.6 149.6 64.5 348.8 19.3
gvim 167.8 90.5 295.9 262.0 148.9
poppler 41.5 69.8 50.4 138.9 14.4
swfdec-giant-steps 20.7 25.2 28.1 54.7 13.3
swfdec-youtube 41.3 39.5 52.4 46.0 11.8
vim 97.5 115.6 93.9 160.3 20.8

Times are in seconds.

[image] 1.9.2-564-g1b24626.image.tiny
[xlib] 1.9.2-564-g1b24626.xlib.tiny
[xvfb] 1.9.2-564-g1b24626.xvfb.tiny
[gl] 1.9.2-564-g1b24626.gl.tiny
[drm] 1.9.2-564-g1b24626.drm.tiny

My first hands-on with an i965. Running from a live image as I haven’t got a spare hard-drive to dual-boot yet. Aside from that and that cairo-drm on an i965 is completely unaccelerated (so the overhead of this backend is entirely down to buffer management). Caveat lector.
cairo-perf-chart

image drm xlib
evolution 0.0 -497.9 -594.1
firefox-planet-gnome 0.0 -157.0 -98.7
firefox-talos-gfx 0.0 -6.1 -139.7
firefox-talos-svg 0.0 -12.0 -105.4
gnome-system-monitor 0.0 -7.9 -9.4
gnome-terminal-vim 0.0 -11.2 -579.6
gvim 0.0 -658.0 -583.7
poppler 0.0 -0.2 -579.0
swfdec-giant-steps 0.0 -13.1 -169.3
swfdec-youtube 0.0 -4.5 -39.1

[image] 1.9.2-457-g3bc00af.image.karmic-alpha4
[drm] 1.9.2-457-g3bc00af.drm.karmic-alpha4
[xlib] 1.9.2-457-g3bc00af.xlib.karmic-alpha4

Hmm, I think there is room for improvement here.

Or, “why we don’t use glitz anymore”. Adding a cairo-glitz run on tiny (an i915):
cairo-perf-chart

image xlib drm gl glitz
epiphany-20090810 0.0 -106.5 -19.8 -235.8 -741.1
evolution-20090607 0.0 -100.3 -130.6 -440.6 -4150.4
evolution-20090618 0.0 -61.9 -69.4 -380.3
firefox-20090601 0.0 -103.5
firefox-periodic-table 0.0 -92.3 20.6 -228.6 -927.3
firefox-talos-gfx-20090702 0.0 8.3 381.6 -207.1 -230.5
firefox-world-map 0.0 -186.2 27.0 -51.1 -259.6
gnome-terminal-20090601 0.0 -29.7 207.9 -287.3 -262.0
gnome-terminal-20090728 0.0 60.0 406.7 -70.5 -129.4
poppler-20090811 0.0 -70.2 132.4 -344.2 -322.4
poppler-bug-12266 0.0 -101.6 59.0 -146.5
swfdec-fill-rate 0.0 -112.9 36.3 30.1
swfdec-fill-rate-2xaa 0.0 -69.3 345.1 45.7 -5498.1
swfdec-fill-rate-4xaa 0.0 -244.4 0.6 -3.2
swfdec-giant-steps 0.0 -41.7 -66.6 -260.8 -275.6
swfdec-youtube 0.0 12.1 192.9 7.6 -81.4

[image] 1.9.2-505-g2e9cad3.tiny
[xlib] 1.9.2-505-g2e9cad3.xlib.tiny
[drm] 1.9.2-525-g8c7de80.drm.tiny
[gl] 1.9.2-525-g8c7de80.gl.tiny
[glitz] 1.9.2-564-g1b24626.glitz.tiny

And some performance results for a really old machine, this must be almost 5 years old. ;-)
cairo-perf-chart

image xlib
evolution 0.0 -179.1
firefox-planet-gnome 0.0 -67.9
firefox-talos-gfx 0.0 9.1
firefox-talos-svg 0.0 -376.1
gnome-system-monitor 0.0 -112.3
gvim 0.0 140.1
poppler 0.0 -84.3
swfdec-giant-steps 0.0 -151.3
swfdec-youtube 0.0 -88.6
vim 0.0 -12.1

[image] 1.9.2-560-g221285f.image.inspired
[xlib] 1.9.2-560-g221285f.xlib.inspired

Another snapshot of performance this time from minime (a G4 mini-mac with a Radeon 200 GPU):
cairo-perf-chart

image xlib gl
epiphany-20090810 0.0 -94.1 -1777.1
evolution-20090607 0.0 -704.5 -4270.2
evolution-20090618 0.0 -146.2 -3470.6
firefox-20090601 0.0 -142.3 -1326.4
firefox-periodic-table 0.0 -26.2 -819.2
firefox-talos-gfx-20090702 0.0 32.7 -358.7
firefox-talos-svg-20090702 0.0 -49.7 -280.5
firefox-world-map 0.0 -107.9 -1138.3
gnome-terminal-20090601 0.0 20.9 -1374.8
gnome-terminal-20090728 0.0 39.8 -1941.1
poppler-20090811 0.0 -10.7 -1192.6
poppler-bug-12266 0.0 -30.3 -416.5
swfdec-fill-rate 0.0 -50.2 -843.3
swfdec-fill-rate-2xaa 0.0 -45.7 -1569.2
swfdec-fill-rate-4xaa 0.0 -84.0 -1724.1
swfdec-giant-steps 0.0 -18.3 -3232.6
swfdec-youtube 0.0 -14.0 -1100.5

[image] 1.9.2-507-g0136989.image.minime
[xlib] 1.9.2-507-g0136989.xlib.minime
[gl] 1.9.2-507-g0136989.gl.minime

Oh dear, the performance is truly dire.

This time comparing different backends using the ‘fast’ wip/stroke-to-path branch:
cairo-perf-chart

image xlib drm gl
epiphany-20090810 0.0 -106.5 -19.8 -235.8
evolution-20090607 0.0 -100.3 -130.6 -440.6
evolution-20090618 0.0 -61.9 -69.4 -380.3
firefox-20090601 0.0 -103.5
firefox-periodic-table 0.0 -92.3 20.6 -228.6
firefox-talos-gfx-20090702 0.0 8.3 381.6 -207.1
firefox-world-map 0.0 -186.2 27.0 -51.1
gnome-terminal-20090601 0.0 -29.7 207.9 -287.3
gnome-terminal-20090728 0.0 60.0 406.7 -70.5
poppler-20090811 0.0 -70.2 132.4 -344.2
poppler-bug-12266 0.0 -101.6 59.0
swfdec-fill-rate 0.0 -112.9 36.3 30.1
swfdec-fill-rate-2xaa 0.0 -69.3 345.1 45.7
swfdec-fill-rate-4xaa 0.0 -244.4 0.6 -3.2
swfdec-giant-steps 0.0 -41.7 -66.6 -260.8
swfdec-youtube 0.0 12.1 192.9 7.6

[image] 1.9.2-505-g2e9cad3.tiny
[xlib] 1.9.2-505-g2e9cad3.xlib.tiny
[drm] 1.9.2-525-g8c7de80.drm.tiny
[gl] 1.9.2-525-g8c7de80.gl.tiny

As always there is more work to do.

This time I’m comparing the performance of cairo-xlib using the latest intel-gfx drivers for i915. The big news here is that the use of server-side gradients causes a performance regression as opposed to their presumed benefits. In contrast tot the previous table, this show performance as a percentage speedup relative to the first result (in this case normally 1.8.8). This makes the regressions much clearer.

cairo-perf-chart

epiphany-20090810 0.0 5.5 -18.4
evolution-20090607 0.0 6.3 4.6
evolution-20090618 0.0 4.0
firefox-20090601 0.0 1.6 -21.5
firefox-periodic-table 0.0 -15.9 -12.6
firefox-talos-gfx-20090702 0.0 1.8 0.3
firefox-world-map 0.0 3.6 16.5
gnome-terminal-20090601 0.0 7.0 7.2
gnome-terminal-20090728 0.0 2.1 0.3
poppler-20090811 0.0 1.5 1.6
poppler-bug-12266 0.0 -0.9 1256.8
swfdec-fill-rate 0.0 -0.4 0.9
swfdec-fill-rate-2xaa 0.0 -0.1 11.1
swfdec-fill-rate-4xaa 0.0 -1.3 3.3
swfdec-giant-steps 0.0 7.8 11.3
swfdec-youtube 0.0 -3.5 -15.3

[0] 1.8.8.xlib.tiny
[1] 1.9.2.xlib.tiny
[2] 1.9.2-505-g2e9cad3.xlib.tiny

Performance comparision of cairo-image from 1.8.8 to current on a slow netbook:
performance-1.8.8..

epiphany-20090810 1.00 1.02 1.48
evolution-20090607 1.02 1.00 4.33
evolution-20090618 1.00 1.02 2.15
firefox-20090601 1.00 1.02 1.83
firefox-periodic-table 1.19 1.00 1.86
firefox-talos-gfx-20090702 1.12 1.00 1.65
firefox-world-map 1.00 2.51 2.27
gnome-terminal-20090601 1.01 1.00 1.27
gnome-terminal-20090728 1.09 1.00 1.45
poppler-20090811 1.00 1.00 1.09
poppler-bug-12266 1.32 1.00 13.16
swfdec-fill-rate 1.00 1.03 1.09
swfdec-fill-rate-2xaa 1.00 1.00 1.15
swfdec-fill-rate-4xaa 1.00 1.00 1.16
swfdec-giant-steps 1.00 1.23 1.31
swfdec-youtube 1.00 1.00 1.14

[0] 1.8.8.tiny, image
[1] 1.9.2.tiny, image
[2] 1.9.2-505-g2e9cad3.tiny, image