From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter integration on feature/tree-sitter (severe performance issues together with linum-mode) Date: Sat, 20 Aug 2022 10:14:43 -0400 Message-ID: References: <7e24d0aa-9980-6204-5064-5a92963ae7bd@secure.kjonigsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17006"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: jostein@kjonigsen.net, "Ergus via Emacs development discussions." , =?utf-8?Q?Tu=E1=BA=A5n-Anh_Nguy=E1=BB=85n?= , Markus Triska , Theodor Thornhill , dgutov@yandex.ru To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 20 16:16:24 2022 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 1oPPGy-0004Dp-H3 for ged-emacs-devel@m.gmane-mx.org; Sat, 20 Aug 2022 16:16:24 +0200 Original-Received: from localhost ([::1]:42922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oPPGx-0004QG-Ea for ged-emacs-devel@m.gmane-mx.org; Sat, 20 Aug 2022 10:16:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oPPFZ-0003d3-9X for emacs-devel@gnu.org; Sat, 20 Aug 2022 10:14:57 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:6253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oPPFW-00036g-Ix for emacs-devel@gnu.org; Sat, 20 Aug 2022 10:14:56 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 0486F100142; Sat, 20 Aug 2022 10:14:51 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 602AD1000FF; Sat, 20 Aug 2022 10:14:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1661004885; bh=1pPw4UedUvDGO09sk+9o33ZDAVgiLZVvQ1khN4ejUVc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=JT3k2LaZJ+AjgtDKYIO/QRaO7IaUKVK2e+8ae4sPcH3RoT/CEnIX0f4HBGPzHWmmW FSgQvDYWW8snYnK8yewVzqn3SEri6JBTN2bAoRw00H4n/s1Es4Tn0xDxkD9BB/HodI p9+TGF3K6n997irXXSmIdOECGBv5bPzaryWwB63iRX+SMocmDKkDV+WtoT1zFSHRUK XAROZ2HUH4Wmz9j5AOlGUnDnpen6Qo4KQ7LHVWwDX2t3u3WLr69o6ifCe6Rg0cZCC2 /3LDbb5UyH4piAxvnrSchPJeXjNV3GFXZ7EeCwikz4CPA2YWCMoY9H/+DvA7A4S8AR cn2WmxUqnmFSA== Original-Received: from pastel (unknown [45.72.195.111]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C8FAC120071; Sat, 20 Aug 2022 10:14:44 -0400 (EDT) In-Reply-To: (Yuan Fu's message of "Fri, 19 Aug 2022 14:58:49 -0700") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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:293667 Archived-At: Yuan Fu [2022-08-19 14:58:49] wrote: >> On Aug 18, 2022, at 11:01 PM, Jostein Kj=F8nigsen wrote: >>=20 >> On 18.08.2022 11:44, Yuan Fu wrote: >>>=20 >>> Good news, the slowness can be easily resolved by compiling the query >>> pattern in csharp-mode-font-lock-settings-1 (this is a recent addition = to >>> treesit). >>>=20 >>> Yuan >>>=20 >> Thanks for the reply and thanks for looking into this. >>=20 >> I can confirm that by compiling the query like you suggested, and >> replacing linum-mode with nlinum-mode, I'm not experiencing any >> performance issues any more! >>=20 >> To avoid issues like this... Should perhaps the function >> treesit-query-capture (in treesit.c) emit a warning/message when >> encountering non-compiled queries? >>=20 >> That way writing more performant major-modes would be more >> self-explanatory, resulting in a better, faster Emacs for everyone. > > Warning/message seems a bit drastic. There are valid use-cases where one > want to use an uncompiled query. For now I have words in the docstring th= at > advices using compiled queries (albeit not in all caps :-) FWIW, I think specifying the highlighting rules with something akin to: (defvar ') is a mistake. It should go through some kind of macro, such as (maybe): (defvar (tree-sitter-rules )) which can thus do any preprocessing we may want, such as pre-compiling queries. It also helps evolve the syntax since we can more easily warn about obsolete uses, etc... I've had a "rewrite font-lock.el so the rules go through a macro" in my todo list for ages. Stefan