From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#32175: Terrible performance of c++-mode refontifying Date: Mon, 16 Jul 2018 16:36:29 +0300 Message-ID: <32585dd1-ecab-4745-06b0-7a117c57447c@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1531748169 7400 195.159.176.226 (16 Jul 2018 13:36:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2018 13:36:09 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 To: 32175@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 16 15:36:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ff3fX-0001mn-19 for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jul 2018 15:36:03 +0200 Original-Received: from localhost ([::1]:51817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff3hd-00089q-Nd for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jul 2018 09:38:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff3hX-00089U-5o for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2018 09:38:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ff3hU-0004Vy-22 for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2018 09:38:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ff3hT-0004Vr-SS for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2018 09:38:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ff3hT-0005hc-K9 for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2018 09:38:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Jul 2018 13:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 32175 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.153174823221855 (code B ref -1); Mon, 16 Jul 2018 13:38:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Jul 2018 13:37:12 +0000 Original-Received: from localhost ([127.0.0.1]:42396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ff3gd-0005gR-Nn for submit@debbugs.gnu.org; Mon, 16 Jul 2018 09:37:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36893) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ff3gb-0005gC-BN for submit@debbugs.gnu.org; Mon, 16 Jul 2018 09:37:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ff3gV-00046Y-6d for submit@debbugs.gnu.org; Mon, 16 Jul 2018 09:37:04 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:53953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ff3gV-00046Q-2h for submit@debbugs.gnu.org; Mon, 16 Jul 2018 09:37:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff3gT-00082f-J2 for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2018 09:37:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ff3gQ-00044G-At for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2018 09:37:01 -0400 Original-Received: from forward106p.mail.yandex.net ([77.88.28.109]:33569) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ff3gP-000438-OV for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2018 09:36:58 -0400 Original-Received: from mxback4g.mail.yandex.net (mxback4g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:165]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 502442D86215 for ; Mon, 16 Jul 2018 16:36:54 +0300 (MSK) Original-Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback4g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 28z46qH7Cj-aUpqYdvS; Mon, 16 Jul 2018 16:36:30 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1531748190; bh=AQ4TmDjjaMTQwWN/v774n+NW/5yCNsdnKD+VggfXkmA=; h=Subject:To:From:Message-ID:Date; b=MMAnDUJ7+bhTCUpWOc0/4wSf9+XMpaH0P4vhhs4rDxX0dhY48S2Wb1WFs6+RAjXVq FaUsjIRVJ80AuzToqrG4QDb1TA4NCtp0m5znw0kUcBXCK4Ot4eLFE234IzJUwGz0EG k8R8aOOQd+6AygB2J9vUoJxXyYEsUp4/v2D153PQ= Original-Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id wkUdgooNmp-aT9qgZJ2; Mon, 16 Jul 2018 16:36:29 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1531748189; bh=AQ4TmDjjaMTQwWN/v774n+NW/5yCNsdnKD+VggfXkmA=; h=Subject:To:From:Message-ID:Date; b=fxnZMirNsdIBw54a+8N5WKN3XfAuoHxeItnQ1FhjNySxdch/VZqwX/HB/ZuTvUL8R C8l2SYxiViDYmP8SSRkKr0V2d8HHLB6QB+xk8+oMOVq9uB3JxSHmdBkuJTp9bdG2Ag u/nImR6lVYFVsdr3aPVStQz6wCliT81gFO0m/MVE= Authentication-Results: smtp1j.mail.yandex.net; dkim=pass header.i=@yandex.ru Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148566 Archived-At: 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+=20 Version 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 6= 9% - jit-lock-fontify-now 6887 6= 9% - jit-lock--run-functions 6873 6= 9% - run-hook-wrapped 6873 6= 9% - # 6873 6= 9% - font-lock-fontify-region 6873 6= 9% - c-font-lock-fontify-region 6866 6= 9% - font-lock-default-fontify-region 6514 6= 5% - font-lock-fontify-keywords-region 6447 6= 5% - c-font-lock-declarations 5059 5= 1% - c-find-decl-spots 5012 5= 0% - c-bs-at-toplevel-p 2972 2= 9% - c-brace-stack-at 2937 2= 9% - c-update-brace-stack 2831 2= 8% - c-syntactic-re-search-forward 1263 1= 2% + c-beginning-of-macro 548 = 5% # 6 = 0% - c-forward-<>-arglist 1220 1= 2% - c-forward-<>-arglist-recur 1041 1= 0% + 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 1= 8% + 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 1= 4% + 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%