From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fu Yuan Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter integration on feature/tree-sitter (severe performance issues together with linum-mode) Date: Mon, 22 Aug 2022 18:53:10 -0700 Message-ID: <04E35325-9A74-4395-9C93-2300827494C4@gmail.com> References: Mime-Version: 1.0 (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="8470"; mail-complaints-to="usenet@ciao.gmane.io" 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: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 23 03:54:14 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 1oQJ7N-0001wF-PE for ged-emacs-devel@m.gmane-mx.org; Tue, 23 Aug 2022 03:54:13 +0200 Original-Received: from localhost ([::1]:48820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQJ7M-0003zb-Q1 for ged-emacs-devel@m.gmane-mx.org; Mon, 22 Aug 2022 21:54:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQJ6U-0003KU-3s for emacs-devel@gnu.org; Mon, 22 Aug 2022 21:53:18 -0400 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:40506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQJ6R-0004Tp-0E for emacs-devel@gnu.org; Mon, 22 Aug 2022 21:53:17 -0400 Original-Received: by mail-pj1-x102c.google.com with SMTP id t11-20020a17090a510b00b001fac77e9d1fso13052348pjh.5 for ; Mon, 22 Aug 2022 18:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc; bh=1exFUYwMrUxelAZmmldUzjdUFaVEZ3dk36Qy0lpudlE=; b=o582YURsepy/eDXnbVExTeRm+W7ncV6NgFYGg+wngSUIgUBe61zqqooGaOvDwnxHJs yGkkVi20sy8ClA21gzC8gYMUlJzklfqwxYZR7/4D3bR2hJjXECh7yDA0Vosl8bNI0UOP W1MvWw1Ag/Xnjm7APQAp3P6VAP2N062HFEpgxr24wf/x9h4Gb9nfyuY7E2OzCrOAcaKs uslvBMaia8BmldKeZqwdzTakYe7L8Y11GurAlET5X14VmQTGBMvynh2ZDnVUOvvOna5A 3Tzs1GT5av57yjwvpdTsN2azj2Om/vf5Op2rCKRAZlvrW0dsyammUh4GMVPpDIaosIQ9 f+GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc; bh=1exFUYwMrUxelAZmmldUzjdUFaVEZ3dk36Qy0lpudlE=; b=LwqpNT5WteYdv2vqa560dvIMu0Hv2aqHal1Waka8xnj3chqJ0jm+C6TxdMil0mG8wt 2/aAMYOy5UezGBe8MDgRf/2JuTRlTDGKYgjUqIrxiOUsZmHnnsk6kGfnoffBLUyBXnyg PVW1rV4ePmLQ3/gnheOs+N6SiCac5Pz3PH6b5DKZ7Dnav1XIISyoUr3R4YfoLd29R1pa 82BSk8RXRFWAD/KcN59xfpPIT3hNp/sBlf0dnZDsH3aUmDfu9lXjy8FkNjhdeJ1Lyl1k swmJXe0ushf6pVER8wfo49ZuzZr8sBhc0lVXhxHJ7XH3YmFhtBrXwKOKu4eNlWCSrF3A lX0Q== X-Gm-Message-State: ACgBeo30lmn04OTv2GRFDjcizIcy4NYmfeR9IS3aatar7KR7bTBMP3Wh 9v7Wv2eVBqUPXNkWaVOpZvc= X-Google-Smtp-Source: AA6agR5/ToqFK7tpAyLk/JovjHHo3gAR7WFYexZQ0RP1LT9OHcD6f/EefUeNvKXQHs7c66gGf6TeBw== X-Received: by 2002:a17:902:ce91:b0:172:d9f6:e20e with SMTP id f17-20020a170902ce9100b00172d9f6e20emr11524386plg.97.1661219592602; Mon, 22 Aug 2022 18:53:12 -0700 (PDT) Original-Received: from smtpclient.apple ([2607:fb90:22dd:2eae:7461:b8a5:4dd9:a44f]) by smtp.gmail.com with ESMTPSA id w1-20020a1709026f0100b00172f6726d8esm1871418plk.277.2022.08.22.18.53.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Aug 2022 18:53:12 -0700 (PDT) In-Reply-To: X-Mailer: iPhone Mail (19G71) Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=casouri@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:293825 Archived-At: >=20 > =EF=BB=BFYuan Fu [2022-08-19 14:58:49] wrote: >=20 >>>> On Aug 18, 2022, at 11:01 PM, Jostein Kj=C3=B8nigsen 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 t= o >>>> 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. >>=20 >> 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 :-) >=20 > FWIW, I think specifying the highlighting rules with something akin to: >=20 > (defvar ') >=20 > is a mistake. It should go through some kind of macro, such as (maybe): >=20 > (defvar (tree-sitter-rules )) >=20 > 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... >=20 > I've had a "rewrite font-lock.el so the rules go through a macro" in my > todo list for ages. Yeah! I can do that. Do you have some ideas on the syntax you would use for f= ont-lock? If possible I=E2=80=99d like treesit stuff to be similar to font-l= ock. For example I made treesit to use font-lock=E2=80=99s decoration level s= ystem. Yuan=