From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#60691: 29.0.60; Slow tree-sitter font-lock in ruby-ts-mode Date: Tue, 10 Jan 2023 00:33:12 +0200 Message-ID: <51ee2f6f-6e1d-eccd-f536-461d916cc94d@yandex.ru> References: <867cxv3dnn.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38132"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 To: Juri Linkov , 60691@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 09 23:34:31 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 1pF0it-0009gi-4I for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Jan 2023 23:34:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pF0ia-00026B-Jc; Mon, 09 Jan 2023 17:34:12 -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 1pF0iQ-00022C-RX for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 17:34:06 -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 1pF0iQ-0002OZ-Jv for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 17:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pF0iQ-0003uI-0S for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 17:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Jan 2023 22:34: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.167330360314963 (code B ref 60691); Mon, 09 Jan 2023 22:34:01 +0000 Original-Received: (at 60691) by debbugs.gnu.org; 9 Jan 2023 22:33:23 +0000 Original-Received: from localhost ([127.0.0.1]:38348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pF0hm-0003tH-KA for submit@debbugs.gnu.org; Mon, 09 Jan 2023 17:33:22 -0500 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:43611) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pF0hk-0003sx-HX for 60691@debbugs.gnu.org; Mon, 09 Jan 2023 17:33:21 -0500 Original-Received: by mail-wm1-f51.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so8425690wms.2 for <60691@debbugs.gnu.org>; Mon, 09 Jan 2023 14:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=WYRubfQD14nka8tVqf3xnXSCiwbxr3yjYi5GLCe7sTw=; b=ij17FLxTXlpXUnY5J8+Sioh9IjSFeYAPR+atDsUeR0BWYw2F6qpjQWBBrQkUgi3t/3 Pfz3DRzIMdRe6PcEuBE6wbWrpKd+uk7/08O318TDKfhAEeXW4xtNLi6d5gvICpsTWeB3 8Hh/3WF+uJ7UULXKbfbRsIOwV8ijYkXWUFfe9RcUXJ2Q0S8FNYvwV2g1+SwKG3woi21S ohrOqHTrmegct/uqT7PiDHLoD9Hkwg9/ZHOR9jPT5yGlpYMa/S9NlhH0vYuUc2hn5xJS DklzrdabSToE2HZtG+8FiJaUBMbX1tIDsbrZ8wH44QbI8EXu9oVUSYQAaK1AZVjCBh5H WgXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WYRubfQD14nka8tVqf3xnXSCiwbxr3yjYi5GLCe7sTw=; b=Fq8eL8l3M92G7CjY+LI2jQLzMd992jmnmKE0FigHz0VKEN/lKjh3bTBmmT1rIO36cX 9LvFbymgFu8Na5pdPm/eWUfqr9xmXbNhh94yQqQNLNlrTTh5GBNvuskandvKcGd39ePy yB5vlkYQiqUL1aB92OUAIvOLBDe0D7mheHXE8aqEuvXkuwyDKjRWR64eCgKKbh7hhUVO 5gklnbYOSduEVRsf+KN37hmU6O0BrPSkg73f2+Igq1qCV7mUMH09kGCILm5RnGlu4cm/ SnVKzaf1R8hMtb5JoVzUecRWPYhalRwGSmGg1e1BkyL52BPIkQGsAk4VzPhzSH4WNRfR bBpw== X-Gm-Message-State: AFqh2koRyLKs5cRcQIy+OeYgWS6T/74fF+9YO+Q7VJRprxxBFSuPLgjb kgsrPIXpPJdQJE8SWM/R+I0= X-Google-Smtp-Source: AMrXdXsGYKRrlHNV0Y6gPFwFPASJC3AIAEVFKgNP5cK/yVbpSCpOnZjAn472t/hlRDEJrg1IoCrywQ== X-Received: by 2002:a7b:ca51:0:b0:3d2:7a7:5cc6 with SMTP id m17-20020a7bca51000000b003d207a75cc6mr51171463wml.18.1673303594410; Mon, 09 Jan 2023 14:33:14 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id o5-20020a05600c510500b003b4ff30e566sm45901wms.3.2023.01.09.14.33.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Jan 2023 14:33:13 -0800 (PST) Content-Language: en-US In-Reply-To: <867cxv3dnn.fsf@mail.linkov.net> 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:253050 Archived-At: Hi! On 09/01/2023 19:16, Juri Linkov wrote: > X-Debbugs-Cc: Dmitry Gutov > > After more rules were added recently to ruby-ts--font-lock-settings, > font-lock became slow even on very small files. Some measurements: If you saw a particular commit that made things slower, did you try reverting it? What was the performance after? > M-: (benchmark-run 1000 (progn (font-lock-mode -1) (font-lock-mode 1) (font-lock-ensure))) > > M-x ruby-mode > (1.3564674989999999 0 0.0) > > M-x ruby-ts-mode > (8.349582391999999 2 6.489918534000001) I have tried this scenario (which, to be frank, is pretty artificial, given that fontification is usually performed in chunks, not over the whole buffer). Perhaps the results depend on a particular file. The ones I have tried (ruby.rb and ruby-after-operator-indent.rb) show only 2x difference (or less). The difference was in favor of ruby-mode, but given the difference in approaches I wouldn't be surprised if ruby-ts-mode incurs a fixed overhead somewhere. > This is not a problem when files are visited infrequently, but > becomes a problem for diff-syntax fontification that wants to > highlight simultaneously many files from git logs. > So a temporary measure would be not to enable ruby-ts-mode > in internal buffers: Is it common to try to highlight 1000 or even 100 files in one diff? > (add-hook 'find-file-hook > (lambda () > (when (and (eq major-mode 'ruby-mode) > ;; Only when not internal as from diff-syntax > (not (string-prefix-p " " (buffer-name)))) > (ruby-ts-mode)))) Have you tried similar tests with other -ts- modes? Ones with complex font-lock rules in particular. I've tried commenting out different rules in ruby-ts--font-lock-settings, but none of them seem to have particularly outsides impact. Performance seems, roughly, inversely proportional to the number of separate "features". And if all ts modes turn out to have this problem, perhaps the place to improve this is inside some common code.