After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 158991 - Pango performance is not what it should be. (highly inefficient)
Pango performance is not what it should be. (highly inefficient)
Status: RESOLVED DUPLICATE of bug 104683
Product: pango
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2004-11-21 22:07 UTC by Dave
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.7/2.8



Description Dave 2004-11-21 22:07:42 UTC
This could be classified as a feature request as it doesn't cause a crash, 
just massive CPU usage. 
 
When updating any gtk widget that uses fonts at a high rate. (i.e. more than 5 
times per second) there is a severe CPU penalty caused by pango rerendering 
things in an inefficient manner. 
 
Here's a scenario.  Create  GTK+ app that talks to an outside device that reads 
sensor reading,s which you want to display in text (GTK_label) at as high a 
rate as possible.  IF you try to update 5 labels at 30 times/sec (we won't go 
into the issues if a person can actual SEE those changes, that's NOT the point) 
cpu usage will go to over 40% for a dual athlon 1.2 ghz box. 
 
It appears that pango recalculates the size needed, and a bunch of other things 
that REALLY DOES NOT need to be done OVER AND OVER.  Here's a solution. 
When pango is called to render some font of a specific size, it should ONCE: 
 1. "pre-render" each glyph of the font requested to an offscreen pixmap (1 per 
glyph) and record dimensions (in ram) and KEEP THE GLYPHS in memory (of the 
xserver for speed reasons) 
 2. on subsequent calls to render text, just get the dimensions needed for each 
char from the pre stored stuff above and copy the glyphs, instead fo rendering 
over again from scratch. 
 
When a draw_layout call is made, it just adds up the char sizes that were 
previously calculated ONCE and copies over the glyphs to the destination pixmap 
and is basically done. 
 
This way once the initial font is rendered (only once into an offscreen pixmap) 
that is stored in the X server redrawing text just becomes a simple series of  
copies from the offscreen pixmaps for each glyph to the screen. with no 
rerendering necessary. 
 
Tradeoffs:  
  more memory usage (not much if you think about it), but RAM is cheap and CPU 
is NOT! 
 
This method should be doable and should speedup EVERY AND ANY application that 
depends on pango by at least an order of magnitude or potentially much more.
Comment 1 Owen Taylor 2004-11-22 17:32:18 UTC
caching of rendered glyphs and glyph bitmaps is done currently.

See bug 135683 for a concrete patch, and bug 104683 for extensive flamage
about what makes a useful bug report about performance.


*** This bug has been marked as a duplicate of 104683 ***