From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter navigation time grows as sqrt(line-number) Date: Sat, 19 Aug 2023 10:24:12 -0400 Message-ID: <1F7C956D-6D22-4CC1-8656-6E2A4D07D5FB@gmail.com> References: <3E82D409-6903-4679-9031-939CA35791FF@gmail.com> <32507689-3b2c-ccbf-dd14-e7bf0bed1ac7@gutov.dev> <6db52945-5459-197c-405d-153ff395a824@gutov.dev> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) 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="21848"; mail-complaints-to="usenet@ciao.gmane.io" To: Dmitry Gutov , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 19 16:25:26 2023 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 1qXMtJ-0005VX-FF for ged-emacs-devel@m.gmane-mx.org; Sat, 19 Aug 2023 16:25:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXMsS-0003s0-Dl; Sat, 19 Aug 2023 10:24:33 -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 1qXMsP-0003rl-0m for emacs-devel@gnu.org; Sat, 19 Aug 2023 10:24:29 -0400 Original-Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXMsM-0001Fu-N2 for emacs-devel@gnu.org; Sat, 19 Aug 2023 10:24:28 -0400 Original-Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-790930d78e8so54852139f.1 for ; Sat, 19 Aug 2023 07:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692455064; x=1693059864; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=NoWUOsMTQgk79ZzLRuXFBALRn+tqohQiw78F+XjkzxA=; b=Mzfa0EZhYjGQiGQZ/mjn/rSVE3duvP5rJAjZWZxZxXGwqNzi+RQawZnm6H0G0W6SbP gBfr3YcGp4cBka9u5j9ewDY/AuJ0pDpzpxKs/MAImh4Q4SyjrSXSLXRZ/VR6Mi5uZ0k+ beWKgKkvEW8pI+kiZ44Xc3GOEXcgGrF6ecrbFasVtq0zRdRqccxhFWJVw0YKXr6vrKln FQgJBxiwLFQ2KzFlclfgwBnpzKvwEIl611pPUoaqnqrV2+toMut+MOV4OTMocjQ/eb0o kGLJGGXUBxDDyPVojDInRAyNiStdudfL7RiD/gejd9Hx6E5Lplyv7QOResHkdUXvaB9w 8J4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692455064; x=1693059864; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NoWUOsMTQgk79ZzLRuXFBALRn+tqohQiw78F+XjkzxA=; b=RHA4ECljobOIaig9ecIFV9Y4uOK6yW+x5bnloUvdrxmfDrf8bBr9/iVAVQ8m0aaxGI N/QBInchkwZ64HeZfzyfg03eWYSvhUVTjJ+fGqJl3AKAIWnDrhLd/GpZvMgqWm3ydrVR n/EF9BgiFzVTJVc7mGdv33ZWUu9ExxHG5syujkYYbAHsOsT1nGIKq90kEy7X7q4MGxsF DzblTvFfe6bbeCcDXls91CjrPXSFy/d6nDIOXi3zTtvu2HPtmr4Zva9KCoFHBWUNhRz0 ev7EybmVoOIP4cQCwhQ/bA7PoIXKA9LlmwhJufsHKq8xv+7K8p/toEzo47cRCVtvXzEH jfPQ== X-Gm-Message-State: AOJu0YzcW5EUYbo0kqUKrfO0+cSYkc/rqCrg5zmZ0jtwNT3hVWJf6ca0 Q7vOmJX8JKTVNTLarhyYr7Y= X-Google-Smtp-Source: AGHT+IGp6undqM6FLJNRcgk8SgHxChHpK4G6ZsMdhFovwaVsyQuucBJHy5/prGvnD5rYy9Au0AulEA== X-Received: by 2002:a6b:6d0c:0:b0:786:25a3:ef30 with SMTP id a12-20020a6b6d0c000000b0078625a3ef30mr3250760iod.7.1692455064340; Sat, 19 Aug 2023 07:24:24 -0700 (PDT) Original-Received: from smtpclient.apple (cm-24-53-184-115.buckeyecom.net. [24.53.184.115]) by smtp.gmail.com with ESMTPSA id g5-20020a0566380bc500b0042b1d495aecsm1206747jad.123.2023.08.19.07.24.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Aug 2023 07:24:23 -0700 (PDT) In-Reply-To: <6db52945-5459-197c-405d-153ff395a824@gutov.dev> X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::d33; envelope-from=jdtsmith@gmail.com; helo=mail-io1-xd33.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 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:308937 Archived-At: Thanks for your patch, Dmitry. I had a chance to test it this morning = (the new, non-crashing version). I made a new NS build, with and = without the patch. The results are really striking (scroll to bottom): https://gist.github.com/jdtsmith/7fa6263a13559d587abb51827e6ae472 Summary: - Applying the same test above on _axes.py reproduces the earlier = emacs-mac/29 results: the time to navigate from the node at line = beginning to root starts at under 10=C2=B5s, but rises as sqrt(N) by = ~100x, reaching over 3000=C2=B5s. - With Dimitry=E2=80=99s patch, it performs much, much better, starting = off with similar timing at early positions in the file, but rising no = higher than 50=C2=B5s, scaling much shallower than sqrt(N). I should emphasize this is a new fast machine; I fully expect my old = laptop would be much slower (10x ?) than 3ms in files this large, which = makes using parent navigation for things like font-lock problematic. The patched version results also make a lot more sense in terms of their = similar logarithmic growth as node-at-point, since the method of search = for a node at point and for its parent is, as Yuan points at, quite = similar.