Bug 1 - Optimizations
Summary: Optimizations
Status: VERIFIED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.1
Hardware: x86 (IA32) Linux (All)
: high enhancement
Assignee: Keith Packard
QA Contact:
URL:
Whiteboard:
Keywords:
: 82557 (view as bug list)
Depends on:
Blocks: asa q
  Show dependency treegraph
 
Reported: 2003-01-09 11:22 UTC by Kevin Puetz
Modified: 2019-04-22 12:09 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
various speedups (4.52 KB, patch)
2003-01-09 11:24 UTC, Kevin Puetz
Details | Splinter Review
fontconfig-opt-cache.patch (7.60 KB, patch)
2003-01-10 22:56 UTC, Kevin Puetz
Details | Splinter Review
fontconfig-opt-constants.patch (1012 bytes, patch)
2003-01-10 22:57 UTC, Kevin Puetz
Details | Splinter Review
fontconfig-opt-hashed-lang.patch (5.64 KB, patch)
2003-01-10 22:57 UTC, Kevin Puetz
Details | Splinter Review
fontconfig-opt-name-parse.patch (1.67 KB, patch)
2003-01-10 22:57 UTC, Kevin Puetz
Details | Splinter Review
fontconfig-opt-string.patch (707 bytes, patch)
2003-01-10 22:58 UTC, Kevin Puetz
Details | Splinter Review

Description Kevin Puetz 2003-01-09 11:22:48 UTC
fontconfig is using about 30% of the cpu time during kde login (according to oprofile) this seems a  
tad high :-)  
  
attached patch contains some optimizations, mostly to name parsing and language index lookup  
that get this down to about 23%. Hopefully more to come.
Comment 1 Kevin Puetz 2003-01-09 11:24:11 UTC
Created attachment 1 [details] [review]
various speedups
Comment 2 Keith Packard 2003-01-09 22:23:51 UTC
Looks like some useful improvements here; let's get them split into pieces so we
can take them one at a time without breaking things.
Comment 3 Kevin Puetz 2003-01-10 22:56:00 UTC
Improved and split-out patches, and the timings which show the 
benefits of each. Attachments coming... 
 
all times taken using a modified fc-list which loads the cache 100  
times instead of once to reduce timing jitter. This probably results 
in some understatement of the benefit of fontconfig-opt-cache.patch 
(the disk cache warmup is quite good, after which the difference  
between requesting I/O from the kernel in blocks or as a long read  
is less). 
 
plain: 
./fc-list  3.86s user 0.12s system 99% cpu 3.999 total 
 
fontconfig-opt-cache.patch: 
./fc-list  3.67s user 0.15s system 99% cpu 3.826 total 
 
fontconfig-opt-constants.patch:  
	changes to tolower->FcToLower usage are also correctness fixes 
	overall speedup is quote minor if visible at all 
./fc-list/fc-list  3.82s user 0.13s system 99% cpu 3.958 total 
 
fontconfig-opt-hashed-lang.patch: 
	use of hash table to find start/end offsets - very significant 
./fc-list  3.13s user 0.13s system 99% cpu 3.262 total 
 
fontconfig-opt-name-parse.patch: 
bitmask test for parsing out delimiters 
./fc-list/fc-list  3.50s user 0.12s system 99% cpu 3.623 total 
 
fontconfig-opt-string.patch: 
shortcut in case insensitive comparison - check for strict  
equality first, then if that fails check insensitively. 
since we are usually seeing all lowercase this is worth quite a bit 
./fc-list/fc-list  3.79s user 0.14s system 99% cpu 3.939 total 
 
with all: 
./fc-list/fc-list  2.63s user 0.15s system 99% cpu 2.792 total 
 
some oprofile data for a kde HEAD login sequence 
columns are #samples, %total time, %app time, library 
 
std: 
<snip non-kdeinit stuff - some of which does call fontconfig, but...> 
55806     59.9336  0.0000 /usr/local/src/kde/parts/HEAD/.kdelibs/usr/local/kdeHEAD/bin/kdeinit 
<snip other libs> 
  1633       1.7538  2.9262 /lib/libpthread-0.10.so 
  1659       1.7817  2.9728 /usr/lib/libstdc++.so.5.0.2 
  5099       5.4761  9.1370 
/usr/local/src/kde/parts/HEAD/.kdelibs/usr/local/kdeHEAD/lib/libkdecore.so.4.2.0 
  7392       7.9387 13.2459 
/usr/local/src/kde/parts/misc/.qt-copy/usr/local/kde3.1/lib/libqt-mt.so.3.1.1 
  8355       8.9730 14.9715 /lib/libc-2.3.1.so 
  15122     16.2405 27.0974 /usr/lib/libfontconfig.so.1.0 
  15978     17.1598 28.6313 /lib/ld-2.3.1.so 
 
with all patches: 
<snip non-kdeinit stuff - some of which does call fontconfig, but...> 
43772     56.0633  0.0000 /usr/local/src/kde/parts/HEAD/.kdelibs/usr/local/kdeHEAD/bin/kdeinit 
<snip other libs> 
  1569       2.0096  3.5845 /usr/lib/libstdc++.so.5.0.2 
  2952       3.7809  6.7440 /lib/libpthread-0.10.so 
  4443       5.6906 10.1503 
/usr/local/src/kde/parts/HEAD/.kdelibs/usr/local/kdeHEAD/lib/libkdecore.so.4.2.0 
  5211       6.6743 11.9049 /lib/libc-2.3.1.so 
  5958       7.6310 13.6114 /usr/lib/libfontconfig.so.1.0 
  6520       8.3508 14.8954 
/usr/local/src/kde/parts/misc/.qt-copy/usr/local/kde3.1/lib/libqt-mt.so.3.1.1 
  15595     19.9741 35.6278 /lib/ld-2.3.1.so 
 
 
 
if you want to see the full oprofile data, I can attach the logs. I don't think  
Comment 4 Kevin Puetz 2003-01-10 22:56:47 UTC
Created attachment 3 [details] [review]
fontconfig-opt-cache.patch
Comment 5 Kevin Puetz 2003-01-10 22:57:19 UTC
Created attachment 4 [details] [review]
fontconfig-opt-constants.patch
Comment 6 Kevin Puetz 2003-01-10 22:57:36 UTC
Created attachment 5 [details] [review]
fontconfig-opt-hashed-lang.patch
Comment 7 Kevin Puetz 2003-01-10 22:57:54 UTC
Created attachment 6 [details] [review]
fontconfig-opt-name-parse.patch
Comment 8 Kevin Puetz 2003-01-10 22:58:15 UTC
Created attachment 7 [details] [review]
fontconfig-opt-string.patch
Comment 9 Peter Bowen 2003-03-04 15:58:29 UTC
Any chance these will get in before 2.2 is released?
Comment 10 Keith Packard 2003-03-04 16:15:10 UTC
I'd rather get 2.2 out the door as the bits released with XFree86 are quite
buggy.  I'd also like to see if we can't squeeze significantly more than a
factor of two out of the speedups; perhaps something like mmap'ing the cache
files would help here, and then parsing the names in place instead of copying
strings around.  That's a lot more ambitious, but I think it'll reduce cache
thrashing.
Comment 11 Keith Packard 2003-03-04 22:13:30 UTC
I've included the short-circuited language lookups, a couple of changes of
tolower to FcToLower and the string compare optimizations (fixed).  I'm
discarding the remaining patches as I suggest we look at reformatting the cache
files to make
loading them more efficient.
Comment 12 testput5 2015-08-27 09:54:30 UTC
*** Bug 82557 has been marked as a duplicate of this bug. ***
Comment 13 vswadeyarie@gmail.com (Spammer; Account disabled) 2019-04-22 12:09:00 UTC
*** Bug 110491 has been marked as a duplicate of this bug. ***


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.