From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#60953: The :match predicate with large regexp in tree-sitter font-lock seems inefficient Date: Wed, 25 Jan 2023 23:17:25 -0800 Message-ID: <5026D975-983F-4D18-8690-BE139C92825D@gmail.com> 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> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3727"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60953@debbugs.gnu.org, Dmitry Gutov To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 26 08:18:17 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 1pKwWX-0000tm-Ry for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Jan 2023 08:18:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKwWK-0000d8-QN; Thu, 26 Jan 2023 02:18: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 1pKwWJ-0000cP-Lz for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 02:18:03 -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 1pKwWI-0005a2-0i for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 02:18:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pKwWH-0004ua-Ry for bug-gnu-emacs@gnu.org; Thu, 26 Jan 2023 02:18:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Jan 2023 07:18:01 +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.167471746918846 (code B ref 60953); Thu, 26 Jan 2023 07:18:01 +0000 Original-Received: (at 60953) by debbugs.gnu.org; 26 Jan 2023 07:17:49 +0000 Original-Received: from localhost ([127.0.0.1]:60486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKwW4-0004tu-Ks for submit@debbugs.gnu.org; Thu, 26 Jan 2023 02:17:48 -0500 Original-Received: from mail-pf1-f181.google.com ([209.85.210.181]:46688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKwW1-0004tb-3k for 60953@debbugs.gnu.org; Thu, 26 Jan 2023 02:17:47 -0500 Original-Received: by mail-pf1-f181.google.com with SMTP id 20so556737pfu.13 for <60953@debbugs.gnu.org>; Wed, 25 Jan 2023 23:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=X1LoNddQtKSBIcOu8XkeUEdfM3/ZGbglGZbldh5thaw=; b=XK8bHyS6C12NkFbl5YGcjC9xdFTV4uoA88b4TFj3X1r0RFja3XgJHbI6mEtwaV+wHm VraMMqR+aXTT1qn8A3EgUlc7q0WPJq2HUTk0jGHrxAUgFS5frKTC9y+8aBugqn7vs2Qb kJjrRg5IG9CteOss5tbw127Zfk3S7Xhef+eWHcvINugvuyzrQOr0eScHxbKUcK46uln4 jwcbi2haimVpNMdp0toPiYEF9xiqCYi8V3i52ZFwe75SCC8IB4hRvpjYKYO1wMzGwn41 /o9QhhP4QJ4VcEKfPo5mvkX874gh4n08Pvt7RjsoIkII0OEjmNLscF3+XDHxdnIYeWgf kN9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X1LoNddQtKSBIcOu8XkeUEdfM3/ZGbglGZbldh5thaw=; b=vHK5rWeMvSSZ/Hi5JJ9Zu8blRO+GyIczTdz/7xmUF9sdt1VnpmgH/vTMPl6amZ7PbD HbIRGGkasS9vbYRBGbmAYmolqk7H/Cct1QYDgNNhWBy39GPdW4hqcQawruS3vnPdhrGg pw1ymkNMO3aUvteBjaVxylpC11VWhNtOTwrriV2iw4mUDaboamaNMhXwmDSrWamXIvsx LKRZey7jhjtPwQYyfesb3jzVt2II7t4Dcr+42BDS8BOA9TCqECJeD0clU0i5xk9DYjgT KOmj9zXbMygO/p978FXQwOF6n0ge20ZhEeJYnTUUawcrDxZu5PH6J3v2CHOawJ7HNgV4 KxWQ== X-Gm-Message-State: AO0yUKXr8IkNqL0Guxc9vKh0+lJfwtK9Fh9ytBzYHcylPaVy0LmR63ts mWlUgPav2v/sXZZwfboXAtI= X-Google-Smtp-Source: AK7set8FoN7ZKjbGnppSO1LJy6zJB49+9hGvhYlMf4uRkIiT+1oLZmxwXt6Mmy9PgEw+R2tG+V44yA== X-Received: by 2002:a62:e110:0:b0:590:32a6:b6d6 with SMTP id q16-20020a62e110000000b0059032a6b6d6mr1178643pfh.32.1674717459294; Wed, 25 Jan 2023 23:17:39 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id a23-20020aa794b7000000b0058837da69edsm264665pfl.128.2023.01.25.23.17.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2023 23:17:38 -0800 (PST) In-Reply-To: <838rhpg57n.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.300.101.1.3) 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:254176 Archived-At: > On Jan 25, 2023, at 10:50 PM, Eli Zaretskii wrote: >=20 >> Date: Thu, 26 Jan 2023 01:21:08 +0200 >> Cc: casouri@gmail.com, 60953@debbugs.gnu.org >> From: Dmitry Gutov >>=20 >> Thank you. Unfortunately, the performance improvement from this patch = is=20 >> still fairly negligible. >=20 > This is quite strange, since all of the approaches basically use the > same primitives under the hood. Perhaps the reason for the slowness > is that the code which computes the text span of a node is slow? > Otherwise, I must be missing something here, since the rest of the > code on the C level is basically the same, give or take some wrappers > that should not change the overall picture. >=20 > Yuan, do you have some insights here? Sadly, no. >=20 >> Switching to using :pred with function (like I did in commit=20 >> d94dc606a0934) which still uses buffer-substring inside is = significantly=20 >> faster. >=20 > 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. Yuan=