From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#60691: 29.0.60; Slow tree-sitter font-lock in ruby-ts-mode Date: Fri, 13 Jan 2023 13:51:15 +0200 Message-ID: <83mt6mac0c.fsf@gnu.org> References: <867cxv3dnn.fsf@mail.linkov.net> <6F1CC7E3-E5B2-4E51-93F6-455A2D0C771E@gmail.com> <0ba1ca9c-78e3-f961-787e-4758beaa3c5b@yandex.ru> <83r0vyamtb.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7920"; mail-complaints-to="usenet@ciao.gmane.io" Cc: juri@linkov.net, 60691@debbugs.gnu.org, monnier@iro.umontreal.ca, dgutov@yandex.ru To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 13 12:52:24 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 1pGIbf-0001jO-VR for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Jan 2023 12:52:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGIbM-0008Bg-KE; Fri, 13 Jan 2023 06:52: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 1pGIbK-0008BG-Ru for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2023 06:52: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 1pGIbK-0004kS-Jb for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2023 06:52:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pGIbK-0000lJ-18 for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2023 06:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Jan 2023 11:52: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.16736106872886 (code B ref 60691); Fri, 13 Jan 2023 11:52:01 +0000 Original-Received: (at 60691) by debbugs.gnu.org; 13 Jan 2023 11:51:27 +0000 Original-Received: from localhost ([127.0.0.1]:49768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGIal-0000kU-4m for submit@debbugs.gnu.org; Fri, 13 Jan 2023 06:51:27 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGIaj-0000kI-93 for 60691@debbugs.gnu.org; Fri, 13 Jan 2023 06:51:25 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGIab-0004gp-Of; Fri, 13 Jan 2023 06:51:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=v8L5KErd7/OHhGFb/Qc5qHRtsMnHLsT41EQx85iBh5k=; b=lt3mc3XnkpMi wKgin12cfjd39wdkwFMBf7/au6rEBHLG6Z2GNLyrBxIbnFe+TLAE6iMNuJ0VIXMEeAoljP6oX0cio KS8iIebJl1fSH9Fyd2ze698oCq85Fg2NzCQNEWKQxuJ6jv6ulKQKKcVy4WRks7Pr/Sa0om6kqKP61 y7Pw8RSU1qkUTwezMoSUkQ9KOG7pJSRIpFUTfRBXcac0caVHsI+VBhIorKFlAFT5KzEY7ROnLb6SA 0i8l9NKpyfUFtIjI1GgIgCa6frZ7TJMXPPP2UPB9WNJeJY3cdnK4NbNnppMTZuWBLscWzfK36txLC EWQqAJPDl98sULV/BPzd6Q==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGIaa-0007gG-Vg; Fri, 13 Jan 2023 06:51:17 -0500 In-Reply-To: (message from Yuan Fu on Fri, 13 Jan 2023 01:15:09 -0800) 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:253285 Archived-At: > From: Yuan Fu > Date: Fri, 13 Jan 2023 01:15:09 -0800 > Cc: Dmitry Gutov , > 60691@debbugs.gnu.org, > Juri Linkov , > Stefan Monnier > > > On Jan 12, 2023, at 11:57 PM, Eli Zaretskii wrote: > > > >> Cc: 60691@debbugs.gnu.org, juri@linkov.net > >> Date: Fri, 13 Jan 2023 01:40:56 +0200 > >> From: Dmitry Gutov > >> > >> Managed to reproduce this after running the test in a couple of > >> different files. > >> > >> But 'M-x memory-usage' says no such command, and 'M-x memory-report' > >> ends up with this error: > >> > >> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) > >> memory-report--gc-elem(nil strings) > >> memory-report--garbage-collect() > >> memory-report() > > > > 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. > > > > And I think I see the problem: we use build_pure_c_string in treesit.c > > in places that we shouldn't. > > > > 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: > > > > . 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 > > 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, > > static Lisp_Object TREESIT_STAR; > > ... > > void > syms_of_treesit (void) > { > ... > TREESIT_STAR = build_pure_c_string ("*"); > ... > } Yes, of course. Look, for example, how coding.c does that: /* 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 = build_pure_c_string (" *code-conversion-work*"); 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.