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#60691: 29.0.60; Slow tree-sitter font-lock in ruby-ts-mode Date: Fri, 13 Jan 2023 19:48:40 -0800 Message-ID: <3FBD8C40-2C2B-4B10-BDB3-8CDD93B495A9@gmail.com> References: <867cxv3dnn.fsf@mail.linkov.net> <6F1CC7E3-E5B2-4E51-93F6-455A2D0C771E@gmail.com> <0ba1ca9c-78e3-f961-787e-4758beaa3c5b@yandex.ru> <83r0vyamtb.fsf@gnu.org> <83mt6mac0c.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="31292"; mail-complaints-to="usenet@ciao.gmane.io" Cc: juri@linkov.net, 60691@debbugs.gnu.org, monnier@iro.umontreal.ca, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 14 04:49:20 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 1pGXXk-0007wo-0I for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Jan 2023 04:49:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGXXU-0006l6-DZ; Fri, 13 Jan 2023 22:49:04 -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 1pGXXS-0006ks-J1 for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2023 22:49:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pGXXS-0003ZE-BE for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2023 22:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pGXXR-00088Z-UB for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2023 22:49:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Jan 2023 03:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60691 X-GNU-PR-Package: emacs Original-Received: via spool by 60691-submit@debbugs.gnu.org id=B60691.167366813031259 (code B ref 60691); Sat, 14 Jan 2023 03:49:01 +0000 Original-Received: (at 60691) by debbugs.gnu.org; 14 Jan 2023 03:48:50 +0000 Original-Received: from localhost ([127.0.0.1]:52926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGXXG-000886-86 for submit@debbugs.gnu.org; Fri, 13 Jan 2023 22:48:50 -0500 Original-Received: from mail-pj1-f54.google.com ([209.85.216.54]:37558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGXXE-00087t-1X for 60691@debbugs.gnu.org; Fri, 13 Jan 2023 22:48:49 -0500 Original-Received: by mail-pj1-f54.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so28848528pjj.2 for <60691@debbugs.gnu.org>; Fri, 13 Jan 2023 19:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=mJwoFOhxZip+RMp6eVcrydfjakDfE+zcJXQfnL9xL+g=; b=bllNYqR/56URhI50lwJTXe6eKVKS2ElYzc5rrfDx2vGMMTLe1n/fiiitn9X0FvvaLR 7K1Ybw+pmxe8AK0fUlz43OHNIl7zvHb6aBqmSBAWnLTxcldLkw8RTkfjgnoYG9odVpgW Mklkr+98W0lZbNpmSuatBVZotqPdcLqXWkqs2PnOJsYCVp5p5JykGa1tlHMftagCazZ9 QYeKAC5ze4pQsZCWzA0PEwEEwqK+NMeCG6RALFC7yboItpJICrP3XBi3/XovSRN8oaxu 9RJtIRzMCCSftQ2lgiajhpmL55SIhJwyAuO/xJ+sSqbYG9zmNcfBi5jMElESxcWVbvVK FHog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=mJwoFOhxZip+RMp6eVcrydfjakDfE+zcJXQfnL9xL+g=; b=yJV44p43g5WwanplNpYTdEAKLSJHGeiiuEFxnfTqZlDIyrsC1vTUaK4IeR8HVsuiHN YVY4HVB4vsX438u8cvc4V0wWYrWRxumC457wMZsxXO+yQVTQ8Y4IcPN9AJQEkmfNWwQN tc1kDjBceafkD2WDIlaMP84egRRTMxFuRIxEtOcjKJU9REwX8HP7s4jI70wnDaxzCrNm TATQ+ykh3UrjKBHPmFYu/VFRrt0BZah0wj8vADwxvuJ8MOIgGbhiqPm40aOyPfrarIDK l2n1ninYLqCcrJe/g9OXSASVFgYbCfjOjGF4EztLzmknJDLYIYLnruf/PQlNcq18qz1c P79Q== X-Gm-Message-State: AFqh2konV5y19veQUnVCYRVFF32Ov0Awc4EQYJ29nLwtRN+k7kCBU/rb o+s5PghJJgsmEmIcFKjyK5g= X-Google-Smtp-Source: AMrXdXtpSk23kJnzTR+bw/wfRcdIt8T3jDpdSKU5es3l/FqspbfkVSE3CUGlUYNrbDd1t0kotkb7bA== X-Received: by 2002:a17:902:6a87:b0:194:6d39:5911 with SMTP id n7-20020a1709026a8700b001946d395911mr4941697plk.40.1673668122011; Fri, 13 Jan 2023 19:48:42 -0800 (PST) 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 h18-20020a170902f55200b001929dff50a9sm14950031plf.87.2023.01.13.19.48.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2023 19:48:41 -0800 (PST) In-Reply-To: <83mt6mac0c.fsf@gnu.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) 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:253318 Archived-At: > On Jan 13, 2023, at 3:51 AM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Fri, 13 Jan 2023 01:15:09 -0800 >> Cc: Dmitry Gutov , >> 60691@debbugs.gnu.org, >> Juri Linkov , >> Stefan Monnier >>=20 >>> On Jan 12, 2023, at 11:57 PM, Eli Zaretskii wrote: >>>=20 >>>> Cc: 60691@debbugs.gnu.org, juri@linkov.net >>>> Date: Fri, 13 Jan 2023 01:40:56 +0200 >>>> From: Dmitry Gutov >>>>=20 >>>> Managed to reproduce this after running the test in a couple of=20 >>>> different files. >>>>=20 >>>> But 'M-x memory-usage' says no such command, and 'M-x = memory-report'=20 >>>> ends up with this error: >>>>=20 >>>> Debugger entered--Lisp error: (wrong-type-argument = number-or-marker-p nil) >>>> memory-report--gc-elem(nil strings) >>>> memory-report--garbage-collect() >>>> memory-report() >>>=20 >>> This means GC is disabled in this session at the time you invoke >>> memory-report. Which shouldn't happen, of course. It sounds like >>> your pure Lisp storage overflowed, and that disabled GC. >>>=20 >>> And I think I see the problem: we use build_pure_c_string in = treesit.c >>> in places that we shouldn't. >>>=20 >>> Yuan, build_pure_c_string should only be used in places such as >>> syms_of_treesit, which are called just once, during dumping. Look = at >>> all the other calls to this function in the sources, and you will = see >>> it. In all other cases, you should do one of the following: >>>=20 >>> . for strings whose text is fixed, define a variable, give it the >>> value in syms_of_treesit using build_pure_c_string, then use that >>> variable elsewhere in the source >>=20 >> Can I define a bunch of static C variables and initialize them in = syms_of_treesit, or they have to be all Lisp variables? Eg, >>=20 >> static Lisp_Object TREESIT_STAR; >>=20 >> ... >>=20 >> void >> syms_of_treesit (void) >> { >> ... >> TREESIT_STAR =3D build_pure_c_string ("*"); >> ... >> } >=20 > Yes, of course. Look, for example, how coding.c does that: >=20 > /* A string that serves as name of the reusable work buffer, and as = base > name of temporary work buffers used for code-conversion = operations. */ > static Lisp_Object Vcode_conversion_workbuf_name; > [...] > void > syms_of_coding (void) > { > [...] > staticpro (&Vcode_conversion_workbuf_name); > Vcode_conversion_workbuf_name =3D build_pure_c_string (" = *code-conversion-work*"); >=20 > But please keep the convention of naming such variables Vsome_thing, > both regarding the "V" and the fact that the name is otherwise > lower-case. Thanks, I pushed a fix for it. I also used intern_c_string in some = places like these: intern_c_string (":?=E2=80=9D) intern_c_string (":*") I want to change them to use DEFSYM, but what should be the c name for = them? Yuan