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#69071: Emacs master branch: c-ts-mode is slow with large C functions. Date: Mon, 19 Feb 2024 21:49:26 -0800 Message-ID: <0C0D2B19-C026-4719-97C0-7F450F12D92A@gmail.com> References: <86le7mw2dg.fsf@gnu.org> <7178B3F3-CCD7-4A2B-9F29-DFF78A6BA243@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="7494"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Alan Mackenzie , 69071@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 20 06:52:04 2024 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 1rcJ2y-0001j6-1Y for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Feb 2024 06:52:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcJ2c-0003qj-NY; Tue, 20 Feb 2024 00:51:42 -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 1rcJ2b-0003qV-IW for bug-gnu-emacs@gnu.org; Tue, 20 Feb 2024 00:51:41 -0500 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 1rcJ2b-0003w1-Aa for bug-gnu-emacs@gnu.org; Tue, 20 Feb 2024 00:51:41 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcJ2w-0002OF-Ga for bug-gnu-emacs@gnu.org; Tue, 20 Feb 2024 00:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Feb 2024 05:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69071 X-GNU-PR-Package: emacs Original-Received: via spool by 69071-submit@debbugs.gnu.org id=B69071.17084082739108 (code B ref 69071); Tue, 20 Feb 2024 05:52:02 +0000 Original-Received: (at 69071) by debbugs.gnu.org; 20 Feb 2024 05:51:13 +0000 Original-Received: from localhost ([127.0.0.1]:44138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcJ28-0002Mq-DG for submit@debbugs.gnu.org; Tue, 20 Feb 2024 00:51:12 -0500 Original-Received: from mail-pj1-f42.google.com ([209.85.216.42]:61777) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcJ23-0002MI-Dw for 69071@debbugs.gnu.org; Tue, 20 Feb 2024 00:51:11 -0500 Original-Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2997cb49711so1054433a91.3 for <69071@debbugs.gnu.org>; Mon, 19 Feb 2024 21:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708408180; x=1709012980; 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=mb6xMkxdqL3ckKH9Sp3bxuWTg26G6qtRt0TPOqAPVwI=; b=DBQi6PC6vbSwco3u/CZH16X2liDVdmzi5FqkWPZM1o40pdtTjGYnQeIkzTlRBtKKVQ eX4I6+Wt/N+0IF2k+7xMjuIBGilrASPRsGKrz9NCfLo1HLJq8auR5U943fJs7kBjGwsf 58qH+rhbYFbk8UFZx4LFqkKDWYL9Xtv2d0bG4mDS/ORHqUBwIL08kI4b3BL4VcOLFAv9 ZU4U7c7gQ4sbEsxBdmY0u6GZrwQZ9C7mM3C0lHzIqhi5f/V122p9rCfbkU4jJNreGvyp W8WswFgS9wKC22yS/Y9rV7AnAAju72jaSSks/V3Q8aHmfQp7Q3ZiX3WhUmg3E/N+MqQh 52ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708408180; x=1709012980; 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=mb6xMkxdqL3ckKH9Sp3bxuWTg26G6qtRt0TPOqAPVwI=; b=aDWOqsysohxN66Yflxdpxj8f7mAWD8+qxbEeB7hY89ILR4hRLLVHJhuGB8m8GikLH0 wTXhtihFN5cTC93Zj3LG49QJNvFCvwIRIW+lGWRYDjo4VSU+6RajszPpPM8w8jrGMNos fxYU9zOMfJgNPbf4cJzhYJTFz21mJiQxlePqGP7wLlztqeAkRr8cD5w+WR8gXwXr6t76 Q7x3fk/Kq6OtnY9BPkIRq4aDj+Hr4HYhQVmyyZtF9KuidUTuX9fLH5wEFFFeAznUlQMx 4aLhrcx+RFs7yO1f8ac454fx0a2ls0Q4hFz5B02iAJSLoi6DnosBRCPwRIsw7lRBXjiE JK9g== X-Forwarded-Encrypted: i=1; AJvYcCVszbp/RSbHBVk1Ty1BgES11qhz1dgUZakXSANjacevWbN6ymzd6soGF/fxcv18I2yxo6+JuKtcqdEZY4+izNEO65oLhks= X-Gm-Message-State: AOJu0Yx+7HkdVVnJfs6aSMqZBpaNCXKTTsk/sY9xFK/eo1AVLMln27rt 3pHBicadfSiWjydnKT9GmcltmmstPlksxCmyKJ7RBPaLMWdyCGBL X-Google-Smtp-Source: AGHT+IFwcCntQkuUEquXd5gurGnIsfX4N9YRbwAe0jjYYGjmICOsmn41akRoiaayrIf5xVvlrPoVxg== X-Received: by 2002:a17:90a:8ce:b0:299:35e9:f18 with SMTP id 14-20020a17090a08ce00b0029935e90f18mr8087234pjn.39.1708408179697; Mon, 19 Feb 2024 21:49:39 -0800 (PST) Original-Received: from smtpclient.apple (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id y3-20020a17090a8b0300b0029942a73eaesm6395950pjn.9.2024.02.19.21.49.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Feb 2024 21:49:39 -0800 (PST) In-Reply-To: <7178B3F3-CCD7-4A2B-9F29-DFF78A6BA243@gmail.com> 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:280311 Archived-At: > On Feb 15, 2024, at 8:06 PM, Yuan Fu wrote: >=20 >=20 >=20 >> On Feb 15, 2024, at 12:36 AM, Eli Zaretskii wrote: >>=20 >>> Date: Mon, 12 Feb 2024 11:30:00 +0000 >>> From: Alan Mackenzie >>>=20 >>> Using Emacs master: >>>=20 >>> c-ts-mode is slow on large C functions when editing towards the end = of >>> such a function. >>>=20 >>> As an extreme example, there is a function proto_register_rrc in the >>> file packet-rrc.c which is part of Wireshark. This file is = "available" >>> from Github, but sadly no longer freely available - you need to = allow >>> Microsoft's scripts to run on your machine. I'm willing to send = this >>> file by email to anybody who needs it. It is almost 10 MB in size. >>>=20 >>> proto_register_rrc is around 50,000 lines long, total size about 2=C2=BC= MB. >>>=20 >>> Near the end of the function, after typing a character, there is a = delay >>> of between 9 and 10 seconds (on my 7 year old machine) before = redisplay >>> happens. This is too long. Some optimisation seems needed. >>>=20 >>> On disabling font-lock-mode, the response becomes instantaneous. >>=20 >> Yuan, could you please look into this? >=20 > Oops, didn=E2=80=99t see this. I=E2=80=99ll take a look. Before we continue, let me note that this seems like another case where = tree-sitter-c parser chokes on some extreme C code. Profiler reports = shows that almost all time are spent in treesit-parser-root-node, which = indicates that all the time are spent parsing the text. Yuan 6094 61% - ... 5542 55% - self-insert-command 5542 55% - electric-indent-post-self-insert-function 5542 55% - indent-according-to-mode 5542 55% - treesit-indent 5542 55% - let* 5542 55% - treesit--indent-1 5542 55% - let* 5542 55% - cond 5542 55% - treesit-node-at 5542 55% - let* 5542 55% - if 5542 55% - or 5542 55% - treesit-buffer-root-node 5542 55% - let* 5542 55% - if 5542 55% treesit-parser-root-node 552 5% + # 3834 38% - redisplay_internal (C function) 3824 38% - redisplay--pre-redisplay-functions 3824 38% - run-hook-with-args 3824 38% - treesit--pre-redisplay 3824 38% - if 3824 38% - let 3824 38% - while 3824 38% - let 3824 38% treesit-parser-root-node 5 0% + command-execute 5 0% + timer-event-handler