From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: treesitter local parser: huge slowdown and memory usage in a long file Date: Tue, 13 Feb 2024 02:50:20 +0200 Message-ID: References: <5991618.MhkbZ0Pkbq@fedora> <93F7DE13-0EC7-4A17-89B1-E07C99C6347B@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12260"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: "Ergus via Emacs development discussions." , Eli Zaretskii To: Yuan Fu , Vincenzo Pupillo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 13 01:50:49 2024 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 1rZh0a-00030o-DG for ged-emacs-devel@m.gmane-mx.org; Tue, 13 Feb 2024 01:50:49 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZh0G-0005t5-VI; Mon, 12 Feb 2024 19:50:28 -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 1rZh0E-0005rk-Nz for emacs-devel@gnu.org; Mon, 12 Feb 2024 19:50:26 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZh0C-0001aN-Ci; Mon, 12 Feb 2024 19:50:26 -0500 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 25E305C00CB; Mon, 12 Feb 2024 19:50:23 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 12 Feb 2024 19:50:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1707785423; x=1707871823; bh=VHbP4fLfNRe2NA5Q7RSeEm5XYTG+zvLA3oojdHQzCW4=; b= gkXdItvG2mYvEOhfsQyQ/MichX6Z+hTq6O+C46THwTE4gVHduUA44IfAgSSYmJ7A w30wMe3NdnFLiW+/NNPFFDM+NfgbihLcNUqUWZ/BzI+hiwos/XVi0hilQqK62FvU QSlyh/biZGWCmwBDOuOj0Ux06nQowvCQs2eYK2vhFoAw3X4bsFMg7F6Ts+iT3kop 0tB4gOIftjKvMrOYb1BYE+1drbTxZdz8/t5cFMbxrKK8KvNRquraYPFoxYztbMdd pJq/5Su7QSXSFJ9YZuxWzs7OhTixG81akOet7S3adQOsgTWaka7Xt/+MoAmwvm5C 3C/faAqPYriYR5tvPUoSUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1707785423; x= 1707871823; bh=VHbP4fLfNRe2NA5Q7RSeEm5XYTG+zvLA3oojdHQzCW4=; b=C +4wum2N2afuzRu6CKk83nj+rfC3QEbA/ZxNIpUVb2lgB5dJ1NHla2ZvfsoPuNXup uyYyz6v+MUsjxp1Ef1A0ef0/GgLLZdvG7pBRfM1+O5XIf9ukBg9Ug7XNxsL4MXLN 4SBW5emRevwk3wqklkdvtVVe61lHWO1dep2udFdDwOhZHfpq3t40FIr3J8ui7eEG zBYMEdH55WjMUcE+8Xa+zgQAeBNYnr4M7wt6w5AqYISSqLoGnPNFNSFJGVgwsasZ 81Uf4kFm3eDSjyLNNrZIVR83sRqYLdyh72DmP8t7mnSNp+G84RhUGWurgeEZMJ+9 h2vubF4ZAxO2JDtw60F+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeggddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeegleefteekgffhvdfhtdegveevveetteegteevgeettdehhfdukeetheffueek keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Feb 2024 19:50:21 -0500 (EST) Content-Language: en-US In-Reply-To: <93F7DE13-0EC7-4A17-89B1-E07C99C6347B@gmail.com> Received-SPF: pass client-ip=66.111.4.28; envelope-from=dmitry@gutov.dev; helo=out4-smtp.messagingengine.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_SBL_A=0.1 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:316156 Archived-At: On 12/02/2024 06:16, Yuan Fu wrote: > Thanks, the culprit is the call to treesit-update-ranges in > treesit--pre-redisplay, where we don’t pass it any specific range, so it > updates the range for the whole buffer. Eli, is there any way to get a > rough estimate the range that redisplay is refreshing? Do you think > something like this would work? If we don't update the ranges outside of some interval surrounding the window, what does that mean for correctness? Perhaps the mode has a syntax-propertize-function which behaves differently (as it should) depending on the language at point. Or different ranges have different syntax tables, something like that. If the ranges, after some edit (perhaps a programmatic one, performed far from the visible area), are kept not update somewhere around the beginning of the buffer, do we not risk confusing the syntax-ppss parser, for example? Come to think of it, take treesit-indent: it only updates the ranges for the current line. But the line's indentation usually depends on the previous buffer positions, doesn't it?