Hi, Michael Meeks points a very inefficient read loop in fontconfig. Should be easy to fix... Would have been easier in fact if fontconfig was mmapping the cache file right away... --behdad http://behdad.org/ "Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill" -- Dan Bern, "New American Language" ---------- Forwarded message ---------- Date: Mon, 6 Feb 2006 05:45:50 -0500 From: michael meeks <michael.meeks@novell.com> To: performance-list@gnome.org Cc: Rodrigo Moya <rodrigo@novell.com> Subject: icon theme weight query ... Hi guys, Just running gnome-screenshot-applet and seeing some rather nasty performance problems (some of which are most likely related to some fontconfig grief we''ve been suffering recently)[1] Michael. [snip] [1] - I though only OO.o did things as stupid as this: 8844 stat64("/home/michael/.fonts.cache-2", {st_mode=S_IFREG|0600, st_size=217089, ...}) = 0 8844 open("/home/michael/.fonts.cache-2", O_RDONLY) = 23 8844 read(23, "G", 1) = 1 8844 read(23, "L", 1) = 1 8844 read(23, "O", 1) = 1 8844 read(23, "B", 1) = 1 8844 read(23, "A", 1) = 1 8844 read(23, "L", 1) = 1 8844 read(23, "\0", 1) = 1 8844 lseek(23, 0, SEEK_SET) = 0 8844 read(23, "G", 1) = 1 8844 read(23, "L", 1) = 1 8844 read(23, "O", 1) = 1 8844 read(23, "B", 1) = 1 8844 read(23, "A", 1) = 1 8844 read(23, "L", 1) = 1 8844 read(23, "\0", 1) = 1 8844 lseek(23, 0, SEEK_CUR) = 7 8844 lseek(23, 7, SEEK_SET) = 7 8844 read(23, " ", 1) = 1 8844 read(23, " ", 1) = 1 8844 read(23, " ", 1) = 1 8844 read(23, "3", 1) = 1 8844 read(23, "4", 1) = 1 8844 read(23, "f", 1) = 1 8844 read(23, "f", 1) = 1 8844 read(23, "9", 1) = 1 8844 read(23, " ", 1) = 1 8844 read(23, "7", 1) = 1 8844 read(23, "8", 1) = 1 8844 read(23, "5", 1) = 1 8844 read(23, "6", 1) = 1 8844 read(23, "3", 1) = 1 8844 read(23, "4", 1) = 1 8844 read(23, "1", 1) = 1 8844 read(23, "2", 1) = 1 8844 read(23, " ", 1) = 1 8844 read(23, " ", 1) = 1 8844 read(23, " ", 1) = 1 8844 read(23, " ", 1) = 1 8844 read(23, "1", 1) = 1 .... -- michael.meeks@novell.com <><, Pseudo Engineer, itinerant idiot _______________________________________________ Performance-list mailing list Performance-list@gnome.org http://mail.gnome.org/mailman/listinfo/performance-list
On Monday 06 February 2006 15:12, Behdad Esfahbod wrote:> Michael Meeks points a very inefficient read loop in fontconfig. > Should be easy to fix... Would have been easier in fact if > fontconfig was mmapping the cache file right away...I''m working on a patch for that. Dirk
Behdad Esfahbod wrote:> Hi, > > Michael Meeks points a very inefficient read loop in fontconfig. > Should be easy to fix... Would have been easier in fact if > fontconfig was mmapping the cache file right away...Yes, fontconfig reads the header of the cache file one byte at a time. The header tells fontconfig whether the cache file is global or not (so that''s one string) and about the sizes of things on that architecture (another string). There should be about 160 bytes this way, but since it''s a string, it''s kind of hard to tell how many bytes there should be. The old fontconfig used getc, but that was less bad since it was on a FILE *. Hopefully Dirk will have a patch soon. It should only need to change FcCacheReadString. There''s a convenient ''len'' parameter to FcCacheReadString which would be useful in deciding how much to read, so it should be something like this: read (fd, dest, len); // iterate though and replace \\ with \, etc lseek (fd, strlen(dest)-len, SEEK_SET); pat
On Monday, 6. February 2006 15:22, Patrick Lam wrote:> Hopefully Dirk will have a patch soon. It should only need to change > FcCacheReadString. There''s a convenient ''len'' parameter to > FcCacheReadString which would be useful in deciding how much to read, so > it should be something like this: > > read (fd, dest, len); > // iterate though and replace \\ with \, etc > lseek (fd, strlen(dest)-len, SEEK_SET);Yes, except that the de-escaping isn''t needed, since we don''t escape anyway in FcCacheWriteString(). See patch below (survived my testing): -------------- next part -------------- A non-text attachment was scrubbed... Name: string-read-cleanup.diff Type: text/x-diff Size: 1912 bytes Desc: not available Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20060207/b565bfcd/string-read-cleanup.bin
Dirk Mueller wrote:> On Monday, 6. February 2006 15:22, Patrick Lam wrote: > > >>Hopefully Dirk will have a patch soon. It should only need to change >>FcCacheReadString. There''s a convenient ''len'' parameter to >>FcCacheReadString which would be useful in deciding how much to read, so >>it should be something like this: >> >>read (fd, dest, len); >>// iterate though and replace \\ with \, etc >>lseek (fd, strlen(dest)-len, SEEK_SET); > > > Yes, except that the de-escaping isn''t needed, since we don''t escape anyway in > FcCacheWriteString(). See patch below (survived my testing):Right, I fixed a C++-ism (stmt; int foo;) and committed. pat