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.bugs Subject: bug#60953: The :match predicate with large regexp in tree-sitter font-lock seems inefficient Date: Thu, 26 Jan 2023 22:01:14 +0200 Message-ID: <83pmb1cbg5.fsf@gnu.org> References: <7624dddc-4600-9a03-ac8b-d3c9e0ab618c@yandex.ru> <04729838-b7d4-8a08-2b71-12536a28aebb@yandex.ru> <83wn5ag4nc.fsf@gnu.org> <01b5d074-fb12-6b1f-cbfb-5e759833b854@yandex.ru> <838rhpg57n.fsf@gnu.org> <5026D975-983F-4D18-8690-BE139C92825D@gmail.com> <83pmb1emxi.fsf@gnu.org> <6f318afc-ca71-8b7e-c822-52e6635b5718@yandex.ru> <83sffxcfxw.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37154"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 60953@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 26 21:02:19 2023 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 1pL8Ru-0009Wx-GS for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Jan 2023 21:02:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL8Rh-00046e-NA; Thu, 26 Jan 2023 15:02:05 -0500 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 1pL8Re-00045i-Es for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 15:02:02 -0500 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 1pL8Re-0006zm-5w for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 15:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pL8Re-0001wc-1v for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 15:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Jan 2023 20:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60953 X-GNU-PR-Package: emacs Original-Received: via spool by 60953-submit@debbugs.gnu.org id=B60953.16747632977435 (code B ref 60953); Thu, 26 Jan 2023 20:02:02 +0000 Original-Received: (at 60953) by debbugs.gnu.org; 26 Jan 2023 20:01:37 +0000 Original-Received: from localhost ([127.0.0.1]:36262 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pL8RF-0001vr-8J for submit@debbugs.gnu.org; Thu, 26 Jan 2023 15:01:37 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pL8RD-0001ve-Fd for 60953@debbugs.gnu.org; Thu, 26 Jan 2023 15:01:36 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL8R7-0006vy-Sx; Thu, 26 Jan 2023 15:01:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=jh/ylYjk4N1pyci2YZyOauxjzn6+c99gp03GFmTG+ac=; b=QPo8V3v4uW8I i/BdOA+Gd3og27Qxv2NJjDPJQTW3Q5CV+bXas4hIvT6YNCD9eyvOtetPj5txdiaUB9FkYW2TGOkyU gRKE5S/C60sBRn3af01GjNXwg5gu3YQmIkxTBK4SSeMNXghFOfznzw/kJARDh8f3d4qbWx3wnfWvb MBhLNCrOnGFGd2+sd9oGsfEhCHHs6rCkTXnuGVANA7D/pPU4nbMTDKAjvDFnTXxl25Bdt4QDcKmpz 1VycX4XX9/ZH2HVwFtc+G109UT75ouWJAiuda0ivAqPKou9mpDJG76sJsS5D26PrB0ewQYYzzjHjU eRLpFVYWXkt6JwnoTUM6dA==; Original-Received: from [87.69.77.57] (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 1pL8R4-0006Rm-CA; Thu, 26 Jan 2023 15:01:28 -0500 In-Reply-To: (message from Dmitry Gutov on Thu, 26 Jan 2023 21:35:55 +0200) 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:254231 Archived-At: > Date: Thu, 26 Jan 2023 21:35:55 +0200 > Cc: casouri@gmail.com, 60953@debbugs.gnu.org > From: Dmitry Gutov > > > If you are saying that GC is responsible, then running the benchmark > > with gc-cons-threshold set to most-positive-fixnum should produce a > > more interesting profile and perhaps a more interesting comparison. > > That really helps: > > (benchmark-run 1000 (progn (font-lock-mode -1) (font-lock-mode 1) (let > (treesit--font-lock-fast-mode) (font-lock-ensure)))) > > => (16.078430587 251 5.784299419999996) > > (let ((gc-cons-threshold most-positive-fixnum)) (benchmark-run 1000 > (progn (font-lock-mode -1) (font-lock-mode 1) (let > (treesit--font-lock-fast-mode) (font-lock-ensure))))) > > => (10.369389725 0 0.0) > > Do you want a perf profile for the latter? It might not be very useful. I'd be interested in comparing the profiles of the two techniques, the :pred and the :match, with GC disabled like that. > > (But I thought you concluded that GC alone cannot explain the > > difference in performance?) > > I'm inclined to think the difference is related to copying of the regexp > string, but whether the time is spent in actually copying it, or > scanning its copies for garbage later, it was harder to say. Seems like > it's the latter, though. If we can avoid the copying, I think it's desirable in any case. They are constant regexps, aren't they?