From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Iteration over frame->face_alist is a huge performance suck Date: Fri, 02 Jul 2021 09:20:54 +0300 Message-ID: <83o8bljkxl.fsf@gnu.org> References: <3be10451-2126-4f55-b460-6d8191535c30@www.fastmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21493"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: "John Coughlin" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 02 08:22:25 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lzCZF-0005Ks-FX for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Jul 2021 08:22:25 +0200 Original-Received: from localhost ([::1]:39126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzCZE-00067h-0s for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Jul 2021 02:22:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzCXq-0005MG-2G for emacs-devel@gnu.org; Fri, 02 Jul 2021 02:20:59 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52274) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzCXp-0006W8-PK; Fri, 02 Jul 2021 02:20:57 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3498 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzCXp-0007bw-D1; Fri, 02 Jul 2021 02:20:57 -0400 In-Reply-To: <3be10451-2126-4f55-b460-6d8191535c30@www.fastmail.com> (jack@johnbcoughlin.com) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271099 Archived-At: > Date: Thu, 01 Jul 2021 20:58:07 -0700 > From: "John Coughlin" > > Recently I have been investigating slowdowns in overall responsiveness > and snappiness in my emacs setup, which arise during the course of > normal work. I attached a sampling profiler to the process > (Instruments on MacOS), and recorded ten or so seconds of > mashing the movement cursors in my org-agenda window. The result is > that 93.4% of the total samples are inside of the function > lface_from_face_name_no_resolve, in xfaces.c. The culprit seems to be > a large association list, frame->face_list, which in my current > session contains over 1000 faces. This is a known problem. The current implementation of face lookup doesn't scale well enough to such usage patterns. > - This may be less of a problem in vanilla emacs, but some packages create faces > that result in quite deep recursive calls to merge_named_face. Each such frame > in the stack (I observed upwards of 50 such frames with my org-agenda button > mashing) is doing its own face lookups. Yes, and watch out for faces that inherit from other faces, which themselves inherit from other faces. > So, what should be done about this? We have a solution designed and almost implemented: see bug#41200. Unfortunately, its development stalled. It would be good to finalize the code, resolve the issues that were found with it (as discussed in the bug thread), and install it.