From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: calculation of text extents [Re: Memory leak] Date: Sat, 24 May 2008 11:30:40 +0900 Message-ID: References: <85lk2b1829.fsf@lola.goethe.zz> <482CD48E.3020601@gmail.com> <482D8332.5030908@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1211596468 3471 80.91.229.12 (24 May 2008 02:34:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 May 2008 02:34:28 +0000 (UTC) Cc: eliz@gnu.org, lennart.borgman@gmail.com, monnier@IRO.UMontreal.CA, emacs-devel@gnu.org To: Jason Rumney Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 24 04:35:05 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jzjb6-0008Ow-3C for ged-emacs-devel@m.gmane.org; Sat, 24 May 2008 04:35:04 +0200 Original-Received: from localhost ([127.0.0.1]:54390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzjaL-0005j1-ED for ged-emacs-devel@m.gmane.org; Fri, 23 May 2008 22:34:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JzjXA-0003wD-ND for emacs-devel@gnu.org; Fri, 23 May 2008 22:31:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JzjXA-0003vY-7K for emacs-devel@gnu.org; Fri, 23 May 2008 22:31:00 -0400 Original-Received: from [199.232.76.173] (port=45893 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzjX9-0003vS-S4 for emacs-devel@gnu.org; Fri, 23 May 2008 22:30:59 -0400 Original-Received: from mx1.aist.go.jp ([150.29.246.133]:35374) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JzjX0-0007Xm-Aa; Fri, 23 May 2008 22:30:50 -0400 Original-Received: from rqsmtp1.aist.go.jp (rqsmtp1.aist.go.jp [150.29.254.115]) by mx1.aist.go.jp with ESMTP id m4O2UiVg023477; Sat, 24 May 2008 11:30:44 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp3.aist.go.jp by rqsmtp1.aist.go.jp with ESMTP id m4O2UhTH009260; Sat, 24 May 2008 11:30:43 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp3.aist.go.jp with ESMTP id m4O2Ue6R008461; Sat, 24 May 2008 11:30:40 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken.m17n.org with local (Exim 4.69) (envelope-from ) id 1JzjWq-0008DY-Gt; Sat, 24 May 2008 11:30:40 +0900 In-reply-to: <482D8332.5030908@gnu.org> (message from Jason Rumney on Fri, 16 May 2008 13:50:58 +0100) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-detected-kernel: by monty-python.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:97634 Archived-At: In article <482D8332.5030908@gnu.org>, Jason Rumney writes: > A while ago I noticed w32font_open being called multiple times for the > same font, so I suspect that we may be overlooking the font cache in > places and reopening fonts when we could be reusing an existing font. With the recent fix of font-cache handling, I think the number of calling `open' callback of a font-backend for the same font is reduced. Can you confirm that? > There is another similar problem when we get text extents - each redraw > cycle can call w32font_text_extents a number of times for the same > glyph_string (from compute_glyph_string_overhangs, left_overwriting and > right_overwriting in quick succession in draw_glyphs, with nested > compute_overhangs_and_x within some of the if statements that cause > extra calls for preceding and following glyph_strings if there is > overhang, which there often is with antialising enabled). Perhaps this > operation is cheap with the X font backends, but on Windows it is > expensive (even with caching of metrics), and I suspect this is a major > cause of the slowdown reported by Windows users. It seems that we can reduce the number of calling `text_extents' callback by recording lbearing and rbearing in struct glyph; which grows the size of that structure from the current 32-byte to 36-byte. I'm not sure how much that change impacts the memory usage of Emacs, but isn't it worth trying? --- Kenichi Handa handa@ni.aist.go.jp