From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#71454: 30.0.50; Performance issues with font selection Date: Sat, 28 Sep 2024 05:36:32 +0200 Message-ID: References: <22612F93-FC37-48E8-8137-E9FF6F5B3A0D@gmail.com> <86y13d8v3h.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16452"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Po Lu , Kai Ma , 71454@debbugs.gnu.org, Alan Third , YAMAMOTO Mitsuharu To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 28 05:38:54 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1suOIH-00049O-Dd for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Sep 2024 05:38:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suOHy-0003B9-9a; Fri, 27 Sep 2024 23:38:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suOHx-0003Ax-Eq for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 23:38:33 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1suOHx-0000ws-6T for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 23:38:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=HJoXVgLLPc3he5vauazXhJjEyYqbOoUAqqlJHaiaoRA=; b=NW4Kl4ju+6pq4APp0lJRPgn3GPZLhEeGZU4IBvEyg5L+flkSRaopblH+bAX51Drn7lmObil/AcohG8rKHxIDvQlthIF8XQeMy3AA2QcqNDXhlmDlH8PBPDrThUJVFxIsGHwb0GWfIthr44j6FX8SBEdS5vV2ydM0qmHNJGijNUcc9hjywPWURTVjqlQu1UFkBw3tjR0ZrfzSiMd3PKLimFaJnS+AluYS9xZy3TwILZBz/ftE5vqGmfrkdA2qeWjPHWSoHcrbuzcBGhpQ5MnVrlgV/oZBgIhAW0dVxF/Gpa/6LS+VvVCIndGZ6eluFGLaM1AgtqQrxPBIi8+YkjOKyA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1suOIQ-00011X-HZ for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 23:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Sep 2024 03:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71454 X-GNU-PR-Package: emacs Original-Received: via spool by 71454-submit@debbugs.gnu.org id=B71454.17274946953817 (code B ref 71454); Sat, 28 Sep 2024 03:39:02 +0000 Original-Received: (at 71454) by debbugs.gnu.org; 28 Sep 2024 03:38:15 +0000 Original-Received: from localhost ([127.0.0.1]:39065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suOHe-0000zR-Nz for submit@debbugs.gnu.org; Fri, 27 Sep 2024 23:38:15 -0400 Original-Received: from mail-ej1-f53.google.com ([209.85.218.53]:51445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suOHb-0000z3-OE for 71454@debbugs.gnu.org; Fri, 27 Sep 2024 23:38:13 -0400 Original-Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a7a843bef98so354916566b.2 for <71454@debbugs.gnu.org>; Fri, 27 Sep 2024 20:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727494596; x=1728099396; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HJoXVgLLPc3he5vauazXhJjEyYqbOoUAqqlJHaiaoRA=; b=WSE4aRC/tsMPvG1FvhqErralEneiv4k2x1CIvHpXyqBwajReoWOXAOMJB+L9X4hY1y Mh28IZaJNuV5f5WzIYGz/2G2bJsrhyjrbnFWQ3dzxUccsFGTugVuBSIgqbGAr/RfsGwN kcvcWHtJOKUv9Wl9ytV7GdbUCfq9s5blgYavGAf4kGN0PYVq//fTaEGhh7FvX8BQjGT9 MEKBexkb99SPQ1cHV6gMfifzhk57M5kJ20x9KHOBXcu93vlQuquv2mQM64hU286JeGDr y99jiCZyspwIundgnNi8yzrky7/b6E9Xi3J3+TFaO4wvmyR0IOrt/BYRquq41qqPjIq/ unaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727494596; x=1728099396; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HJoXVgLLPc3he5vauazXhJjEyYqbOoUAqqlJHaiaoRA=; b=VxRBb8ywiVUGFqBHiKZygDD1VY8NRSaUapy0xVAGnVaj6EZzKXdOW2MUboGCH4B1Sp NLzFZ1upmo0+W5/BWAUqWcN8OWlMDujkiTZf14QArfI3hHaUtOzFJPFrzlAHQ8fczwcg qzeUgFdZ15HhTLM3UWItniMSPtqXmWHxCIQTx3RZ4CsqUf9sF8snaf8odpjYtQ0g8kIH ZPEWp17e+xjXjwOXxRwNCVby6Ea4rX1VJPZzZlcSnecVY1xFWChi5OOeIX2PKKPFFTKU OFEku04T6kCrZvBdE20nSzR9gyldy8OmqMkKi6g+gFBufRWIFdAAkgJlEZZRO/NJV/ZP 3yPg== X-Forwarded-Encrypted: i=1; AJvYcCWST0Lg5mNRTMu66xjp+6MdEcTIrFD/qz3ybznEefvitKaFPgOCkp2aukwqsni2pP2XcuWrZQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxwScs+S0sjUOFWmcY/aVyUfZl/pOHH85bkxvz1pP7FMm2aX2Fr L/O1L1yB3gfhhb/Wi1ZP0+PyvlwyQWjTQxZVBrUpcWPR7T5B2khE X-Google-Smtp-Source: AGHT+IGSCZxuECDZRZXt3KmGzQ8TIBEHX7DHwWDbqf8CV2iF/oF/t/eB1SAU77dcoeoAWqunrThqbA== X-Received: by 2002:a17:907:3f9d:b0:a86:700f:93c0 with SMTP id a640c23a62f3a-a93c492d70cmr599379066b.35.1727494596201; Fri, 27 Sep 2024 20:36:36 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e36953.dip0.t-ipconnect.de. [217.227.105.83]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c2775db3sm206385566b.12.2024.09.27.20.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 20:36:34 -0700 (PDT) In-Reply-To: <86y13d8v3h.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 27 Sep 2024 09:32:50 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292543 Archived-At: Eli Zaretskii writes: >> From: Kai Ma >> Date: Fri, 27 Sep 2024 00:42:04 +0200 >>=20 >> I got back to this problem today and have some initial ideas. >>=20 >> 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=E2=80=99s a Mac-only problem. >>=20 >> 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. >>=20 >> 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=E2=80=99s not complete as I haven=E2=80=99t adapted & incorpo= rated >> mac_font_create_preferred_family_for_attributes yet. >>=20 >> I don=E2=80=99t see noticeable font differences after the change on the >> files I=E2=80=99m 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 , the original author.