GNU bug report logs - #71454
30.0.50; Performance issues with font selection

Previous Next

Package: emacs;

Reported by: Kai Ma <justksqsf <at> gmail.com>

Date: Sun, 9 Jun 2024 19:41:02 UTC

Severity: wishlist

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Kai Ma <justksqsf <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>, luangruo <at> yahoo.com, alan <at> idiocy.org, 71454 <at> debbugs.gnu.org, mituharu <at> math.s.chiba-u.ac.jp
Subject: bug#71454: 30.0.50; Performance issues with font selection
Date: Tue, 15 Oct 2024 22:34:59 +0200
[Message part 1 (text/plain, inline)]
I’ve been personally using my change for some while and I didn’t notice any regression (only for my use cases of course).  Attached is the final patch.  Hopefully it can encourage more NSport users to test it.

[0001-Improve-the-performance-of-font-selection-on-macOS.patch (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]

> On Oct 12, 2024, at 13:20, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> Ping!
> 
>> From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
>> Cc: Kai Ma <justksqsf <at> gmail.com>,  Alan Third <alan <at> idiocy.org>,  Po Lu
>> <luangruo <at> yahoo.com>,  71454 <at> debbugs.gnu.org, YAMAMOTO Mitsuharu
>> <mituharu <at> math.s.chiba-u.ac.jp>
>> Date: Sat, 28 Sep 2024 05:36:32 +0200
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>>>> From: Kai Ma <justksqsf <at> gmail.com>
>>>> Date: Fri, 27 Sep 2024 00:42:04 +0200
>>>> 
>>>> I got back to this problem today and have some initial ideas.
>>>> 
>>>> I did some profiling and the profiler clearly shows that most CPU
>>>> time was in macfont_list and
>>>> CTFontDescriptorCreateMatchingFontDescriptors. (screenshot attached
>>>> below) So yes, it’s a Mac-only problem.
>>>> 
>>>> macfont_list will call CTFontDescriptorCreateMatchingFontDescriptors
>>>> for n times, where n is the number of installed fonts. It seems
>>>> CTFontDescriptorCreateMatchingFontDescriptors is very expensive, and
>>>> we should minimize the use of it.
>>>> 
>>>> I did a quick proof-of-concept patch (attached) that removes the
>>>> outer loop (utilizing CTFontDescriptorCreateMatchingFontDescriptors
>>>> itself to search for fonts). And now I no longer experience long
>>>> delays. It’s not complete as I haven’t adapted & incorporated
>>>> mac_font_create_preferred_family_for_attributes yet.
>>>> 
>>>> I don’t see noticeable font differences after the change on the
>>>> files I’m working on. I would like to gather some feedback from the
>>>> more experienced on whether this is a promising solution or not. If
>>>> it is, I will refine it into a formal patch.
>>> 
>>> Thanks.  I'm adding a few people in the hope that they could comment
>>> on the patch, or maybe try it and provide feedback.
>> 
>> I haven't tried the patch because I can't reproduce the problem and I
>> don't use much beyond Latin-1 so I think chances are low that I'd see
>> anyting breaking with the patch.
>> 
>> But looking at the patch, which mostly removes stuff from macfont_list,
>> I wonder if/how that can be semeantically equalivalent to the existing
>> code.
>> 
>> Just saying, I'm definitely not an expert in this area.
>> 
>> Adding YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>, the original
>> author.
>> 


This bug report was last modified 248 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.