From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#58950: [PATCH] * lisp/subr.el (buffer-match-p): Optimise performance Date: Fri, 04 Nov 2022 23:00:12 +0000 Message-ID: <878rkqjpfn.fsf@posteo.net> References: <875yfyebi0.fsf@posteo.net> 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="36089"; mail-complaints-to="usenet@ciao.gmane.io" To: 58950@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 05 00:01:12 2022 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 1or5gV-0009CM-Qq for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Nov 2022 00:01:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1or5gQ-0006bL-BQ; Fri, 04 Nov 2022 19:01:06 -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 1or5gM-0006at-FK for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 19:01:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1or5gM-0004xs-7J for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 19:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1or5gM-00018K-2H for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 19:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Nov 2022 23:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58950 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58950-submit@debbugs.gnu.org id=B58950.16676028254284 (code B ref 58950); Fri, 04 Nov 2022 23:01:02 +0000 Original-Received: (at 58950) by debbugs.gnu.org; 4 Nov 2022 23:00:25 +0000 Original-Received: from localhost ([127.0.0.1]:55033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5fl-000170-Gc for submit@debbugs.gnu.org; Fri, 04 Nov 2022 19:00:25 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:33081) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5fg-00016g-Jk for 58950@debbugs.gnu.org; Fri, 04 Nov 2022 19:00:24 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 13AD124002B for <58950@debbugs.gnu.org>; Sat, 5 Nov 2022 00:00:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667602815; bh=F/sXLNWDxrmVaz9NXg3JdkL54yuregoCr0vvNffAlFY=; h=From:To:Subject:Autocrypt:Date:From; b=SmlDB2WzSD1V/Kejn/jOgd73FVVnAD6+NTo+ujesH8KwFchutazJ3o1XDG7a4ftlo 9VgJ9DtuRDpTkCrFgB0tUIbm19HTA7Q0GojdMNfFAiHtx1p6LEKZykvobUb22XQGLI A80rPbTGGeNT7s6fbrKWTQjaYF7rpaJ994zt/P2gLO6+LiRE1cWWM3uKdF4DCnsJi8 5/Np7sEB7JSM8jZn7uUQ3aHkDkNE3V/VliPmgMfk+TkLsTqc9/sCLrv4/JJrDwRHWU n1nj1dr1ApekO4PQkHpxQ6KmczMhZLkzAeYdy1YnWY2gBb9u/OIMAQXoP8YRWUZqVW pJ/X4N2Ikyufw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N3x0t03Pgz6ttj for <58950@debbugs.gnu.org>; Sat, 5 Nov 2022 00:00:12 +0100 (CET) In-Reply-To: <875yfyebi0.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 01 Nov 2022 19:11:03 +0000") Autocrypt: addr=philipk@posteo.net; keydata= mQGNBGLfygUBDADVznbke6w0n9nE42xb+ZggbBy0IYRkkru/K+NA67523YTl2DoR2a5OMW90w7L9 KDtX2Mp34JN/6jVOSVC07VUbHVu6/exoGKixkiTpGhBPy5tUUJoxQKqLrzVQhN3fIyvg1oyHXKZm QGkUeevV0wjj4++xfjmcP235YvDh3TF8HC9t5KxIQIbhWnQm4ZyDkpWWS2CmdNttlj2+eH+51WLL bgx2bcwTmqrs079Q3hgF3yh44bBEmp9MgFjiZldOY2my0/ZSeucRxYmiM0vbJEBQgZV/MvA3gTxe 7ibV3ii7AyoYA8FiFDP98S/R2y5Nfq3ez9B7qeqtpSNseQHOU7h8Y5VV01a71ZszENAmbbwsldb9 j+HRLke7rn6mswDZl1qA/9ZFRzliFOdQtS1878XjraY+h5jfjvxaFVK23prGGVrrKv0LPWavoFUr nsjeHEZhYezBKhC2PwvRtXm01S3rkNbwm9pj0tfLSDW+1pT+6eZWptfQCXF2oEvgfKSTASUAEQEA AbQmUGhpbGlwIEthbHVkZXJjaWMgPHBoaWxpcGtAcG9zdGVvLm5ldD6JAdQEEwEKAD4WIQRxJuHe LwzjXHcL7QHyw8xRPbifZgUCYt/KBQIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAK CRDyw8xRPbifZkH+DACmCKmhrYgcv2i6dj3vRCVINaLtKUODTna/wAmP20WRKPhqvqvKNUx/wzpT aZrXIxpxOU2xawRWeHhWUktxS+W9L3xTACeR0gf5gomCxD9RuBTIohzWDkQt5rk8QwLqx5rAy5 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: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:247118 Archived-At: Philip Kaludercic writes: > Tags: patch > > > The below patch is based on a tangent discussion in bug#58839, the below > patch was written in collaboration with Jo=C3=A3o T=C3=A1vora. It involv= es an > optimisation to `buffer-match-p' that dramatically speeds the execution > of the function. This is important for the very least as > `buffer-match-p' is used for displaying buffer. > > Running (benchmark-run 1000 (match-buffers "\\*.+\\*")) I previously got > (22.822269875 178 15.524474267999977), and with the patch applied > (0.27100275 2 0.1730835160000197). > > There are a few points that can be discussed: > > 1. Style. I wrap the defun in a let (or rather letrec) block to avoid > littering the global namespace. It isn't necessary, and one could > argue it makes debugging more difficult. > > 2. Caching policy. Caching is critical to this optimisation. Just > using byte-compilation would cause the above test to slow down to > (76.323692627 656 57.088315405). The question is if the hash map > will collect too much garbage over time, and if there is a better > approach that could be taken? > > In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version > 3.24.30, cairo version 1.16.0) of 2022-10-31 built on heron > Repository revision: 462a66e79edcc34ecbeef7cc1604765adfdc038e > Repository branch: feature/package+vc > System Description: Guix System > > Configured using: > 'configure --with-pgtk --with-imagemagick > PKG_CONFIG_PATH=3D/gnu/store/ssg343s6ldqdwh30136pnawhbgd0cb6i-profile/li= b/pkgconfig:/gnu/store/ssg343s6ldqdwh30136pnawhbgd0cb6i-profile/share/pkgco= nfig' Ping?