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 10:10:17 +0200 Message-ID: <83pmb1emxi.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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25889"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60953@debbugs.gnu.org, dgutov@yandex.ru To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 26 09:11: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 1pKxLq-0006b7-GJ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Jan 2023 09:11:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKxLc-0001pl-Ba; Thu, 26 Jan 2023 03:11:04 -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 1pKxLa-0001pY-OA for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 03:11: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 1pKxLa-0004V1-G1 for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 03:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pKxLa-0006OI-Az for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 03:11: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 08:11: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.167472060824477 (code B ref 60953); Thu, 26 Jan 2023 08:11:02 +0000 Original-Received: (at 60953) by debbugs.gnu.org; 26 Jan 2023 08:10:08 +0000 Original-Received: from localhost ([127.0.0.1]:60592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKxKi-0006Mi-DM for submit@debbugs.gnu.org; Thu, 26 Jan 2023 03:10:08 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKxKg-0006M5-Lo for 60953@debbugs.gnu.org; Thu, 26 Jan 2023 03:10:07 -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 1pKxKb-00037F-ER; Thu, 26 Jan 2023 03:10:01 -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=0pFttqP5ydyYtKWicBVAhbzETeqCqmA+Ytx8shNzBEI=; b=XSC1roB0DPpf xG/ZmIOKVB7dKGIhBRNRHBCN1x4u0Vfxo3jeG4DuO4qeUPqC72b2ISNYEL/rduHRbYQqNZlKfJvXP 1T8I1+8c6Ma4nL1Xbjqecds8834pwpN3EIWj4cLRDjiilDwo2s0qP0zPB22djnGa65L/ZP4Zs7z82 n4ubYxH1FnnX7v4bJP/yoMzC72CMN32gpu02VizRibvcbjjoZnYQPnVyQuu4i8Z5+1Te55zlcbiCe kLFJ3EpROAj8TH0oTQ+GKwm8ciLULJmEFf4tTBEHT7hAx+nB5ZFQoe46HsJRJX2nTslQGr3e+Rk4O 99zY49OgkXsreSMkGGiaXA==; 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 1pKxKa-00047H-P8; Thu, 26 Jan 2023 03:10:01 -0500 In-Reply-To: <5026D975-983F-4D18-8690-BE139C92825D@gmail.com> (message from Yuan Fu on Wed, 25 Jan 2023 23:17:25 -0800) 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:254191 Archived-At: > From: Yuan Fu > Date: Wed, 25 Jan 2023 23:17:25 -0800 > Cc: Dmitry Gutov , > 60953@debbugs.gnu.org > > >> Switching to using :pred with function (like I did in commit > >> d94dc606a0934) which still uses buffer-substring inside is significantly > >> faster. > > > > If the performance issue is fixed, then the only aspect that we should > > perhaps try to improve is consing. Consing a string each time you > > need to fontify increases the GC pressure, so if there's a good way of > > avoiding that without performance degradation, we should take it. Is > > it possible to use your :pred technique in a way that doesn't need to > > produce strings from buffer text? > > Why is :pred more performant though? They just use string-match-p. If anything, the :pred predicates should be more expensive, since they execute lisp functions and conses tree-sitter nodes into lisp objects. Yes, exactly my thoughts. Perhaps Dmitry could present comparison of profiles from perf which would allow us to understand the reason(s)?