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.bugs Subject: bug#62368: 29.0.60; Evaluating predicates before creating captured nodes in treesit-query-capture Date: Mon, 11 Sep 2023 17:37:49 -0700 Message-ID: References: <09A7EAB7-332E-4123-A6DB-8921FBD325C4@gmail.com> 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="19032"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62368-done@debbugs.gnu.org, Dmitry Gutov To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 12 02:39:14 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qfrQv-0004lu-CF for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Sep 2023 02:39:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfrQi-0005Sg-Mz; Mon, 11 Sep 2023 20:39:00 -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 1qfrQg-0005Rt-Ib for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 20:38:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qfrQg-0005lp-8Q for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 20:38:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qfrQk-0004JJ-IX for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 20:39:02 -0400 Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Sep 2023 00:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 62368 X-GNU-PR-Package: emacs Mail-Followup-To: 62368@debbugs.gnu.org, casouri@gmail.com, casouri@gmail.com Original-Received: via spool by 62368-done@debbugs.gnu.org id=D62368.169447909516512 (code D ref 62368); Tue, 12 Sep 2023 00:39:02 +0000 Original-Received: (at 62368-done) by debbugs.gnu.org; 12 Sep 2023 00:38:15 +0000 Original-Received: from localhost ([127.0.0.1]:55439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfrPy-0004IF-PN for submit@debbugs.gnu.org; Mon, 11 Sep 2023 20:38:15 -0400 Original-Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:59804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfrPv-0004Hy-Kt for 62368-done@debbugs.gnu.org; Mon, 11 Sep 2023 20:38:13 -0400 Original-Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-68fe39555a0so436157b3a.3 for <62368-done@debbugs.gnu.org>; Mon, 11 Sep 2023 17:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694479081; x=1695083881; darn=debbugs.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=pFFhUEyvjouUCl/sHrU4SpVEajq8qDNs62w840bhgyA=; b=G9dYdPpdbApumr8YN6m8yysUIH3y+P8SNc2CYQEb72rO3I60PNbNZo7sc7JKY2THtB in6WiPJzk91GfwaU3Ttx9jDSNwNuh1+l9HJC5f+DcXIIwGhcuEa924wNo9yAThz6Qe4H IVw27+pM0JmxMprfC2d1tDL8kbaKXFsqtWRlDhUZ6NelHdLC0IZ/pKOiO+PpCvGELGLk DtIEWGKEwr/p6pxbX6jQDlg6MUjNGP1LhzpsQKufMciCmeVs337hAYN7XoJdADNQWeEO jYA3vCNysxCqPuq9F586wRihFKpDgB4nIJtmndrbPFniDe5eJ1BIdEOt3zcDrPJJqLWO gdJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694479081; x=1695083881; 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=pFFhUEyvjouUCl/sHrU4SpVEajq8qDNs62w840bhgyA=; b=bX3KD20az7rrkyORYKYzNoZ1hnqmBQdiekUVlCW+0+KTmuzATiRZVigcYfcGOEwCT1 lYgaeEHRQlBGaO9tUzPdeiLfeNYm4Mn5xQnqxxyhjOiHW6+5VpX8+Q+cbBJ8fdZCQ/EW 0abvJ97GTpaWpBHw6rXE4eEm0KwYwwy4bCtoKVb8xJFPpKUhIjIxP9rWbHSjqi3yE02S KJWV6NtN6XFAJbSBqRPuTYJ1ulG9Bkvf8SHiUz2jvmwSZqiaZOOCBRHS/eiKhexy/0Xo 9xui6ILT2+Sshy0KLxWpUpEK3xJ2Er29xBwE0xqVkbZ2wXFHR0Yvm1k/6BgdYZ9Lcgt6 oSOQ== X-Gm-Message-State: AOJu0YwkDtPJbvH3Gp7SD69jiPLN7xWytFPboI1OzJ0YClb80j5C1gj2 OroPDs+iciLavl0nr+lQ27M= X-Google-Smtp-Source: AGHT+IH99XUYjyBeX0KnzYU+lrtEy5D+Ud7QHhfHu3IN98LO5SmBh1jUEIpzvWZa7afC4TWXOLLLWg== X-Received: by 2002:a05:6a21:196:b0:133:f0b9:856d with SMTP id le22-20020a056a21019600b00133f0b9856dmr15743265pzb.17.1694479081316; Mon, 11 Sep 2023 17:38:01 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id j9-20020aa79289000000b0066a31111cc5sm6138345pfa.152.2023.09.11.17.38.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Sep 2023 17:38:01 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3731.700.6) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270122 Archived-At: > On Sep 11, 2023, at 5:05 PM, Stefan Kangas = wrote: >=20 > Yuan Fu writes: >=20 >>> On Mar 22, 2023, at 5:42 PM, Dmitry Gutov wrote: >>>=20 >>> Hi Yuan! >>>=20 >>> On 22/03/2023 06:49, Yuan Fu wrote: >>>> X-Debbugs-CC:dgutov@yandex.ru Dmitry, when you have time, could you >>>> try your benchmark in bug#60953 with this patch? I made predicates >>>> evaluate before we create any nodes, so #equal and #match should be >>>> more efficient now, when there are a lot of rejections. In the same >>>> time #pred is made slightly worst since they now create a lisp node >>>> and discard it. (But this can be fixed with a little more >>>> complexity.) >>>=20 >>> Thank you, I was curious what would the improvement be if we could >>> delay allocation of node structures until :match is checked. >>>=20 >>> But for my benchmark the difference is on the order of 4-5%. It = seems >>> we are scraping the barrel in terms of improving = allocations/reducing >>> GC because according to 'benchmark-run', where the whole run of a = 100 >>> iterations of the scenario takes ~1.1s, the time spent in GC is >>> 0.150s. And the improved version takes like 1.04s, with 0.1s in GC. >>>=20 >>> So if you ask me, I think I'd prefer to hold off on applying this >>> patch until we either find scenarios where the improvement is more >>> significant, or we find and eliminate some other bigger bottleneck >>> first, after which these 5% grow to become 10-20% or more, of >>> remaining runtime. The current approach is pretty Lisp-y, so I kind >>> of like it. >>>=20 >>> And there's the issue of #pred, of course, which which could swing >>> the difference in the other direction (I didn't test any code which >>> uses it). >>>=20 >>> We could also try a smaller change: where the initial list of conses >>> for result is build with capture_id's in car's, and then substituted >>> with capture_name if the predicates all match. Then tthe = treesit_node >>> pseudovectors would still be created eagerly, though. >>=20 >> Thank you very much! Yeah, it doesn=E2=80=99t seem to worth it. I = guess we can >> keep this in our back sleeve for now ;-) >>=20 >> I think using symbols is fine for now, since I don=E2=80=99t think it = would >> make much difference. >=20 > So should this bug be closed, then? We can close this for now. Thanks Stefan. Yuan