From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#32175: Terrible performance of c++-mode refontifying Date: Sat, 16 May 2020 20:49:58 -0700 Message-ID: References: <32585dd1-ecab-4745-06b0-7a117c57447c@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="15620"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 32175@debbugs.gnu.org, Konstantin Kharlamov To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 17 05:51:10 2020 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 1jaAKT-0003xq-Fo for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 May 2020 05:51:09 +0200 Original-Received: from localhost ([::1]:50406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaAKS-0000uW-FI for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 May 2020 23:51:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaAKM-0000uE-82 for bug-gnu-emacs@gnu.org; Sat, 16 May 2020 23:51:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaAKL-00014z-Uk for bug-gnu-emacs@gnu.org; Sat, 16 May 2020 23:51:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jaAKL-0007Iw-Sx for bug-gnu-emacs@gnu.org; Sat, 16 May 2020 23:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 May 2020 03:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32175 X-GNU-PR-Package: emacs Original-Received: via spool by 32175-submit@debbugs.gnu.org id=B32175.158968740928012 (code B ref 32175); Sun, 17 May 2020 03:51:01 +0000 Original-Received: (at 32175) by debbugs.gnu.org; 17 May 2020 03:50:09 +0000 Original-Received: from localhost ([127.0.0.1]:42031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaAJR-0007Hf-Q1 for submit@debbugs.gnu.org; Sat, 16 May 2020 23:50:09 -0400 Original-Received: from mail-yb1-f174.google.com ([209.85.219.174]:37161) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaAJQ-0007H5-KS for 32175@debbugs.gnu.org; Sat, 16 May 2020 23:50:05 -0400 Original-Received: by mail-yb1-f174.google.com with SMTP id b123so1183137yba.4 for <32175@debbugs.gnu.org>; Sat, 16 May 2020 20:50:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc :content-transfer-encoding; bh=pFkh0XFe5ArGnMr1ZKBQle5fI1h/Zkp/rXNJzJcSY8I=; b=V8BPhFpMJSxhPfjmmU+fqG/a01JKSyd30grPGsNaUfelbyzp2IsvhM8RrWAbVlukfe s2cZVS5XOFigs+F6Lm3wo8Gsmmo4Eg8j488wYlmlh+50wtFEnI/dxPAESu3+n9xCtq+2 oT/eUzRJzitukD4EURwhGN/9+649ucOkXG41Ujn8QubCDoii4iXc6UUBpfQy6+BUzHtO 5vXpb0si6juOS8e6XJCagKnUa1v7siIyNdqcNmneagpFR5fjciEuceeqhfSbsjZK/5ic rk8SLcypf+B5qYiiuq2n6LYT4GXWhGUI/wHb5VYGvzJvIxXN8oQ2lfyp+IPDqbuXw0Lh rFsQ== X-Gm-Message-State: AOAM531hNcRJLr8P79kRADcOeWl44K1Anms1/0Quj2E2RmIlb3hrqnaP XgTNsgcZ7jpjNpsYrsAeUuOxxS8iOiICkVV+QAo= X-Google-Smtp-Source: ABdhPJwrXzH0jfeEPB2YQrZT3VVPNSf+14znGXHn0OocjD8RHnXcSRdMiTwqK1wmDTXyoDpLylXQgX22np0F+9Zq2mw= X-Received: by 2002:a25:ad4c:: with SMTP id l12mr16397432ybe.389.1589687399014; Sat, 16 May 2020 20:49:59 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 16 May 2020 20:49:58 -0700 In-Reply-To: <32585dd1-ecab-4745-06b0-7a117c57447c@yandex.ru> (Konstantin Kharlamov's message of "Mon, 16 Jul 2018 16:36:29 +0300") 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" Xref: news.gmane.io gmane.emacs.bugs:180430 Archived-At: Hi Alan, This bug was reported in July 2018 but got no followup. Perhaps you could take a look? Best regards, Stefan Kangas Konstantin Kharlamov writes: > Sometimes for working with C++ code I start experiencing lags for typing > the text, like, 1-second delay between pressing the key and the actual > text appearing. This does not happen at the beginning of the work, but > rather after Emacs have been running for a while. > > It seems to be a per-buffer issue. E.g. right now I > have the problem in one c++mode buffer, but not in another. > > This problem have definitely existed for 2 years (maybe more). I > didn't report it because I thought it's my computer slow. I attached > profiling result at the end, and I remember that some years ago traces > of low performance have also been leading to functions about > refontifying. > > Emacs version: GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Vers= ion > 3.22.30) of 2018-07-06 > (It's 12 days old build from git, commit 3bbd4ffc68b) > > FWIW it's built with -flto -march=3Dnative options, i.e. I have as much > optimization as possible. > > Profiling below is done by pressing key, then waiting for > symbol to appear; and repeating this for =E2=89=8810 times. > > - redisplay_internal (C function) 6900 69= % > - jit-lock-function 6887 69= % > - jit-lock-fontify-now 6887 69= % > - jit-lock--run-functions 6873 69= % > - run-hook-wrapped 6873 69= % > - # 6873 69= % > - font-lock-fontify-region 6873 69= % > - c-font-lock-fontify-region 6866 69= % > - font-lock-default-fontify-region 6514 65= % > - font-lock-fontify-keywords-region 6447 65= % > - c-font-lock-declarations 5059 51= % > - c-find-decl-spots 5012 50= % > - c-bs-at-toplevel-p 2972 29= % > - c-brace-stack-at 2937 29= % > - c-update-brace-stack 2831 28= % > - c-syntactic-re-search-forward 1263 12= % > + c-beginning-of-macro 548 5= % > # 6 0= % > - c-forward-<>-arglist 1220 12= % > - c-forward-<>-arglist-recur 1041 10= % > + c-syntactic-re-search-forward 285 2= % > + c-forward-<>-arglist-recur 245 2= % > + c-backward-token-2 125 1= % > c-forward-sws 52 0= % > + c-backward-sws 12 0= % > c-beginning-of-current-token 48 0= % > match-string-no-properties 6 0= % > + # 1823 18= % > + c-beginning-of-macro 40 0= % > c-backward-sws 8 0= % > c-forward-sws 6 0= % > # 4 0= % > + c-backward-token-2 3 0= % > + c-font-lock-enclosing-decls 240 2= % > + # 203 2= % > + c-font-lock-<>-arglists 183 1= % > + c-font-lock-cut-off-declarators 176 1= % > + color-identifiers:colorize 140 1= % > + c-font-lock-raw-strings 45 0= % > + c-font-lock-invalid-single-quotes 37 0= % > + c-font-lock-enum-tail 34 0= % > # 31 0= % > # 29 0= % > + c-font-lock-complex-decl-prepare 25 0= % > # 24 0= % > # 22 0= % > + c-font-lock-c++-lambda-captures 18 0= % > # 9 0= % > # 3 0= % > eval 3 0= % > c-font-lock-enum-body 3 0= % > + font-lock-fontify-syntactically-region 40 0= % > + c-before-context-fl-expand-region 348 3= % > + eval 9 0= % > + mode-line-default-help-echo 4 0= % > - ... 1411 14= % > Automatic GC 1411 14= % > + command-execute 1252 12= % > + flycheck-handle-signal 301 3= % > + timer-event-handler 32 0= % > + evil-repeat-post-hook 5 0= % > global-highlight-symbol-mode-check-buffers 5 0= % > evil--jump-hook 1 0= %