Subject: 26.1; very large c++-mode yank performance regression 25.3_1-x86_64 -> 26.1-x86_64

From: Chris Hecker <[email-masked]>
Date: Fri, 7 Dec 2018 18:42:23 -0800

Hi, I recently upgraded from 25.3_1 to to 26.1 on Windows 7 x64 and I've
noticed a very large performance regression on yanks in C++ mode buffers
(it feels slower in many other operations as well, but I actually
measured yank with the profiler).  This happens even starting with with
emacs -Q.

If I start emacs and visit a moderately large cpp file (18k LOC), and go
to the same place in the middle of the file in both versions of emacs,
then kill and yank the current line, the performance on 26.1 is easily
10x worse...the yank is instant in 25.3_1 and takes literally almost a
second on 26.1 sometimes.  I decided to test this with a profiler run,
so I went to the same line in both, killed the line, and evaled this:

(progn (profiler-start 'cpu) (yank) (profiler-report) (profiler-stop))

Here are the results:

25.3_1:

- ...                                               1 100%
   Automatic GC                                     1 100%

26.1:
- command-execute                                  14 100%
 - call-interactively                              14 100%
  - funcall-interactively                          14 100%
   - eval-expression                               14 100%
    - eval                                         14 100%
     - progn                                       14 100%
      - yank                                       14 100%
       - insert-for-yank                           14 100%
        - insert-for-yank-1                        14 100%
         - c-after-change                          13  92%
          - mapc                                   13  92%
           - #<compiled 0x9dcce1>                  13  92%
            - c-after-change-re-mark-raw-strings    6  42%
             - c-in-literal                         3  21%
              - c-state-semi-pp-to-literal          3  21%
                 c-parse-ps-state-below             3  21%
            - c-restore-<>-properties               4  28%
               c-syntactic-re-search-forward        4  28%
              c-neutralize-syntax-in-CPP            3  21%
         - remove-yank-excluded-properties          1   7%
          - remove-list-of-text-properties          1   7%
           - c-after-change                         1   7%
            - c-before-change                       1   7%
             - mapc                                 1   7%
              - #<compiled 0xfcb439>                1   7%
                 c-depropertize-CPP                 1   7%
- ...                                               0   0%
   Automatic GC                                     0   0%

I'm going to try the older cc-mode with the newer emacs and see if that
fixes it, but I figured I'd report this bug now in case you haven't
gotten other reports yet.

Thanks,
Chris

In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)
 of 2018-05-30 built on CIRROCUMULUS
Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
spyparty_ui.cpp has auto save data; consider M-x recover-this-file
Mark saved where search started
Mark set
Quit
CPU profiler started
Mark set
CPU profiler stopped
"CPU profiler stopped"
C-; is undefined
Quit [3 times]
Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS THREADS LCMS2

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Profiler-Report

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils profiler misearch multi-isearch
vc-dispatcher vc-bzr cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib
elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win
w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote w32notify w32 lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 126347 12125)
 (symbols 56 22860 1)
 (miscs 48 74 192)
 (strings 32 37966 2210)
 (string-bytes 1 1104314)
 (vectors 16 37221)
 (vector-slots 8 997518 11240)
 (floats 8 65 156)
 (intervals 56 1881 214)
 (buffers 992 15))