From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "John Coughlin" Newsgroups: gmane.emacs.devel Subject: Re: Iteration over frame->face_alist is a huge performance suck Date: Fri, 02 Jul 2021 06:39:43 -0700 Message-ID: <4c146d56-2074-4ba0-9672-42439e5b0108@www.fastmail.com> References: <3be10451-2126-4f55-b460-6d8191535c30@www.fastmail.com> <83o8bljkxl.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f16c01e2ffbd4ea3847b3045692c0121 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29668"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.5.0-alpha0-530-gd0c265785f-fm-20210616.002-gd0c26578 Cc: emacs-devel@gnu.org To: "Eli Zaretskii" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 02 15:46:07 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 1lzJUb-0007T1-Ey for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Jul 2021 15:46:05 +0200 Original-Received: from localhost ([::1]:59468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzJUa-00042p-FZ for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Jul 2021 09:46:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzJOr-0007kq-Pa for emacs-devel@gnu.org; Fri, 02 Jul 2021 09:40:09 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:56095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzJOo-0004vU-5V; Fri, 02 Jul 2021 09:40:09 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 176115C015B; Fri, 2 Jul 2021 09:40:05 -0400 (EDT) Original-Received: from imap35 ([10.202.2.85]) by compute3.internal (MEProxy); Fri, 02 Jul 2021 09:40:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Nuqwi4 8k0p1aTIYL4m/VR0yZfHmL04D8jKDi302fm3w=; b=kP9Ss/LmancBA3lBVKlKUh yLsf2eujW8r4BHJwKRXDtWfT8hfiPa3g2jFagRGu4G489/PNeW9bgUih2XslPjyC joLFob2TagTrWNjTasYg6AVDtGP54phNk+L5spqV5jNmkjWz4wRSnGauOtNGYXkR smF7WNVwKXwD7oYAeofTXtApCMZEiNkrJngxPqtg725eGerEfvT78H78fUUB/B5N 34+dCqqTrRVX+R67Wl3SYB/n4EAvlFEdxaFdK0ekjKl7RSA9TJ+LoRzAMFQ5eogu ZoOxtidH3+xvEMsonEWWcb/EXn3Z8SXhGU/7FAz0LNxW1fA44LvJoZOR/URp2sKA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeikedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesrgdtreerreertdenucfhrhhomhepfdflohhh nhcuvehouhhghhhlihhnfdcuoehjrggtkhesjhhohhhnsggtohhughhhlhhinhdrtghomh eqnecuggftrfgrthhtvghrnhepffefjedvgfeugeekveduveeitdfhkeegteeuuddtvdef ieduleeitefgkeetfeejnecuffhomhgrihhnpehgnhhurdhorhhgnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhgrtghksehjohhhnhgstgho uhhghhhlihhnrdgtohhm X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id DFC0415A005E; Fri, 2 Jul 2021 09:40:04 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <83o8bljkxl.fsf@gnu.org> Received-SPF: none client-ip=66.111.4.29; envelope-from=jack@johnbcoughlin.com; helo=out5-smtp.messagingengine.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:271103 Archived-At: --f16c01e2ffbd4ea3847b3045692c0121 Content-Type: text/plain > see bug#41200 Thank you for the pointer. There was no discussion of frame_face_alist I could see on this mailing list. It looks like that thread (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41200) satisfied itself of all the issues raised, except for the copyright release of the author of the final version of the patch, which is a shame. Hopefully it can be merged soon. Thanks a lot, -Jack On Thu, Jul 1, 2021, at 11:20 PM, Eli Zaretskii wrote: > > 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. > --f16c01e2ffbd4ea3847b3045692c0121 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
> see bug#41= 200

Thank you for the pointer. There was no= discussion of frame_face_alist I could see on this mailing list. It loo= ks like that thread (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D41200= ) satisfied itself of all the issues raised, except for the copyright re= lease of the author of the final version of the patch, which is a shame.= Hopefully it can be merged soon.

Thanks a = lot,
-Jack

On Thu, Jul 1, 2021, a= t 11:20 PM, Eli Zaretskii wrote:
> Date: Thu, 01 Jul 2021 20:58:07 -0700
> From: "John Coughlin" <jack@johnbcoughlin.com>

=
> Recently I have been investigating slowdowns in overall respon= siveness
> and snappiness in my emacs setup, which aris= e during the course of
> normal work. I attached a samp= ling profiler to the process
> (Instruments on MacOS), = and recorded ten or so seconds of
> mashing the movemen= t 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<= br>
> a large association list, frame->face_list, which = in my current
> session contains over 1000 faces.

This is a known problem.  The current imple= mentation 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_na= med_face. Each such frame
>   in the stack (I= observed upwards of 50 such frames with my org-agenda button
<= div>>   mashing) is doing its own face lookups.

Yes, and watch out for faces that inherit from other f= aces, which
themselves inherit from other faces.
=

> So, what should be done about this?

We have a solution designed and almost implemented: se= e 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.


--f16c01e2ffbd4ea3847b3045692c0121--