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.devel Subject: Re: treesitter local parser: huge slowdown and memory usage in a long file Date: Mon, 27 May 2024 15:05:22 -0700 Message-ID: <13F12132-4E95-43A8-BC24-0C7187426DAF@gmail.com> References: <2DB11528-C657-4AC1-A143-A13B1EAC897A@gmail.com> <0132CFC2-CFA0-4D58-9632-6E6E03FE57DB@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) 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="1352"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 28 00:06:01 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 1sBiTg-000Adg-TR for ged-emacs-devel@m.gmane-mx.org; Tue, 28 May 2024 00:06:00 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBiTL-0002qC-9F; Mon, 27 May 2024 18:05:39 -0400 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 1sBiTI-0002pg-Hq for emacs-devel@gnu.org; Mon, 27 May 2024 18:05:36 -0400 Original-Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBiTH-0002mn-1Z for emacs-devel@gnu.org; Mon, 27 May 2024 18:05:36 -0400 Original-Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6f8e98760fcso134355b3a.1 for ; Mon, 27 May 2024 15:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716847533; x=1717452333; darn=gnu.org; 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=+Ci6o1NPqh0vp94/NCl3xZ23MdGEelGJEeCzMVSHicI=; b=CIvVLxVeedIfkbd4BNSz1cpm1hPrD6mRZ5jGFwFSCcYbg+z/2MD1XlmTXkZT6JeMXF nkH+mI00R6T6IajdR7xef7OVqlVFKYP4HpMj3n+BqIf2cOPIpTM2Bm1R5NyhiGvs7bxR cv7OVh3F+UH6HUMDKmwxM47/I8E4wq0u7qchkkI6Mr+uufeuhnov2ctuCSHh0SZjUHuC ttF5YIV0CAgdvm5UTindny55hRoEjkRH5i/c+3sBNInyukt/vinxA//G7olko8CdaRlF 0LYD4Syv4EUbWPu6zNaZR3S7+TEEWuA+p6G1QZTN9kAIL4+j4iJCbCUgIb5nfyk85wba knag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716847533; x=1717452333; 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=+Ci6o1NPqh0vp94/NCl3xZ23MdGEelGJEeCzMVSHicI=; b=BnGGLKS57GccNon9AgG8wXL/7hZpIaC6CpKv/rB+xiiaPpRq+cSxLJZ9IJIYT3ev7o cKY3cud0xmjOFLIzPaRaRo9s3SYItPqsy27aQo7JRObzg226lxVVTUasScIt7LZxeOHo 3soQuwnCCQ9wtd+HXbOC3d/KAqkmouJRpzm8tYqCc9FmZzSlygMdsUAR75wIHLAHiXUA 8rjPOeAz9SLT913liO2g2kITDiDxjvZa0v1uLQXtvBx7qMuew7FiEU9kjjowfYtWoc+G j6sxhXWfvqHGc0SA+YVvTbBLZT36bd8ztIOfj2VdwmChlrto3nftG+N3ZvbyFWTBdauv Lliw== X-Gm-Message-State: AOJu0YyBbiFSkn+6+jPC1HIaDMU/US0yl/F8htFGoalryL/bRC8+L9Vz Yq+ase5/zavjwjBSI7GhpbLJdsMZ2oKDhMMdJ/S3YiKFNXv5r/5AWVpOCA== X-Google-Smtp-Source: AGHT+IHRKTr1+waqXdAgRspnO6/bQ6QG5DoYIY+/3yQ0T2atocsPuK81zjTvXUVzYKnIiawpb/vy5g== X-Received: by 2002:a17:902:fc44:b0:1f4:a761:d12c with SMTP id d9443c01a7336-1f4a761e4bamr42880385ad.62.1716847533653; Mon, 27 May 2024 15:05:33 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:641:300:4910:3097:2bb7:97eb:9759]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f44c967a62sm66520755ad.120.2024.05.27.15.05.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2024 15:05:33 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3774.600.62) Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=casouri@gmail.com; helo=mail-pf1-x42f.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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:319632 Archived-At: > On May 25, 2024, at 9:23=E2=80=AFPM, Stefan Monnier via Emacs = development discussions. wrote: >=20 >> The only problem is to decide how long a history of updated ranges do = we >> keep for each parser. The 100% correct approach is to maintain a = separate >> history for each consumer, and never throw away old ranges until the >> consumer consumes them. But then you risk wasting memory if some = consumer >> never consumes the ranges. To handle that we can add a hard limit. = But then >> this hard limit might be too low for some edge case=E2=80=A6 We can = make this hard >> limit configurable, and if we ever encountered a case where this hard = limit >> is not enough and there=E2=80=99s no way around it (unlikely), we can = instruct users >> or lisp program to increase it. >=20 > Side note: the above is fairly close to describing `track-changes.el`. > [ where I don't have any hard limit, currently. ] >=20 I see. I suppose you had to shift =E2=80=9Cmodified region=E2=80=9D = around according to later edits, right? Yuan=