[cairo] Reducing CPU usage in News Ticker Implementation

Darwin Bautista djclue917 at gmail.com
Mon Sep 3 23:03:20 PDT 2007

Thanks for all the replies.

On 9/1/07, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> Darwin Bautista (djclue917 at gmail.com) said:
> > I just want to know if there's a more efficient way of implementing a
> > news ticker. Currently, I'm using my own "Cairo-fied" version of the
> > ticker widget used in pyt!ck (
> > http://whatah.nyunderground.net/code/pytick/ ).
> As pointed out, caching the layout in a surface pattern is the standard
> response to such speed issues.
> > The problem is that
> > the ticker consumes a lot of CPU when the Pango layout is relatively
> > big (377 character-long text, DejaVu Serif Semi-Condensed 40) since X
> > performs a lot of redrawing every second (e.g., 50 redraws/second if
> > the scroll timeout is set to 20ms).
> The question arises as to identify the bottleneck and is it worth
> fixing. In this case, the issue appears to be that we are causing X to
> render glyphs that will never reach the widget. On the Cairo side we
> have a few opportunities to cull glyphs that will never be visible. As a
> demonstration, the attached patch culls the glyphs before adding them to
> the Xlib glyph stream - as it appears to be the easiest place to perform
> the culling.
> Applying this patch causes the CPU usage to become negligible, a drop
> from 20% on my machine. (I've also attached the updated ticker.py that I
> was running as my benchmark.) However, it remains to be seen whether it
> brings sufficient benefit across the desktop to justify its overhead.

What version of Cairo are you using? It seems that the patch was
diff'ed against a different Cairo version. I'm using Cairo 1.4.10.

Darwin M. Bautista
BS Electronics and Communications Engineering
University of the Philippines Diliman

University of the Philippines Linux Users' Group

More information about the cairo mailing list