unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
@ 2014-07-28 12:47 Sam Varshavchik
  2019-10-06 22:42 ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Varshavchik @ 2014-07-28 12:47 UTC (permalink / raw)
  To: 18134

I am seeing anomalous behavior in C++ major mode that's triggered by
long, but not excessively long -- only a few hundred lines -- Doxygen-style
comments.

Cursor navigation at the end of the Doxygen comment block in the
following file (just before the first typedef), and trying to add some
additional text there, results in 3-5 seconds' worth of delays for
nearly typed character.

Highlighting the entire Doxygen comment block: M-x indent-region takes
several minutes (!) with emacs consuming 100% CPU.

Sample file to open in C++ major mode.

====================================cut here=================================
#ifndef x_w_layoutmanager_H
#define x_w_layoutmanager_H

#include <x/ref.H>
#include <x/w/layoutmanagerfwd.H>
#include <x/w/layoutmanagerobj.H>
#include <x/namespace.h>

namespace LIBCXX_NAMESPACE {

	namespace w {
#if 0
	};
};
#endif

//! Base class for \ref layoutmanager "layoutmanager"s.

class layoutmanagerBase : public ptrrefBase {

public:

	//! A display element factory created by a \ref layoutmanager "layout manager".

	//! Refer to this class as \c INSERT_LIBX_NAMESPACE::w::layoutmanager::base::factory
	//!
	//! Obtain this factory from its \ref layoutmanager "layout manager".
	//! Calling one of
	//! \ref layoutmanagerObj::factoryObj "this factory's methods" adds a
	//! new display element
	//! to the container, in the manner controlled by the container's
	//! layout manager.
	//!
	//! The layout manager keeps its own reference on all ref handles
	//! returned by this factory. Generally, the layout manager will also
	//! have a mechanism by which a display element, created by this
	//! factory, gets removed from the container, releasing the layout
	//! manager's reference on the display element. If the last reference
	//! to the container goes out of scope, the container destroys the
	//! layout manager, which removes any remaining display elements from
	//! the container, automatically.
	//!
	//! \par Primitive display elements
	//!
	//! These methods create various primitive display elements. They are
	//! available when none of the more standard display elements fit the
	//! bill.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/label.H>
	//! #include <unicode.h>
	//!
	//! INSERT_LIBX_NAMESPACE::w::const_font font=window->label_font().font();
	//!
	//! std::string str;
	//! std::vector<unicode_char> ustr;
	//! INSERT_LIBX_NAMESPACE::w::richtextmetamap_t markup;
	//! INSERT_LIBX_NAMESPACE::w::dim_t initial_width;
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(font, str);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(font, str, unicode::utf_8);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(font, ustr);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_label(ustr, markup);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(font, str, initial_width);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(font, str, unicode::utf_8, initial_width);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(font, ustr, initial_width);
	//!
	//! INSERT_LIBX_NAMESPACE::w::label l=factory->create_wrappable_label(ustr, markup, initial_width);
	//! \endcode
	//!
	//! Creates a \ref label "label" display element.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/canvas.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::const_picture pic;

	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(width, height);
	//!
	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(width, height, INSERT_LIBX_NAMESPACE::w::rgb(0, 0, 0));
	//!
	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(pic);
	//!
	//! INSERT_LIBX_NAMESPACE::w::canvas c=factory->create_canvas(pic, INSERT_LIBX_NAMESPACE::w::rgb(0, 0, 0));
	//! \endcode
	//!
	//! Creates a \ref canvas "canvas" display element.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/button.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::button b=factory->create_checkbox();
	//!
	//! INSERT_LIBX_NAMESPACE::w::button b=factory->create_radio();
	//!
	//! INSERT_LIBX_NAMESPACE::w::button b=factory->create_standard_button("name");
	//! \endcode
	//!
	//! Creates a \ref button "button" display element.
	//! create_standard_button() loads a standard button image, specified
	//! by name. create_checkbox() loads a standard checkbox button image,
	//! create_radio() loads a standard radio button image and additionally
	//! invokes the new button's oneshot() method.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/inputfocus.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::focusable element;
	//!
	//! INSERT_LIBX_NAMESPACE::w::inputfocus focus=factory->create_inputfocus(element);
	//!
	//! INSERT_LIBX_NAMESPACE::w::inputfocus focus=factory->create_inputfocus(element, INSERT_LIBX_NAMESPACE::w::rgb(0,0,0));
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus,
	//!           INSERT_LIBX_NAMESPACE::w::focusable> focuspair=factory->create_standalone_inputfocus([]
	//!    (const INSERT_LIBX_NAMESPACE::w::gridlayout &layout)
	//!    {
	//!        return layout->create_checkbox();
	//!    });
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus,
	//!           INSERT_LIBX_NAMESPACE::w::focusable> focuspair=factory->create_standalone_inputfocus([]
	//!    (const INSERT_LIBX_NAMESPACE::w::gridlayout &layout)
	//!    {
	//!        return layout->create_checkbox();
	//!    }, INSERT_LIBX_NAMESPACE::w::rgb(0,0,0));
	//! \endcode
	//!
	//! Creates an \ref inputfocus "input focus frame" with the default or
	//! an explicit background color. create_inputfocus() attached an
	//! input focus frame to an existing display element.
	//!
	//! create_standalone_inputfocus() creates a new input focus to an
	//! element that gets returned by the lambda parameter, which receives
	//! the new input focus frame's grid layout manager, and must return
	//! a focusable display element. This allows the input focus frame to
	//! be created for a display element contained by the same input focus
	//! frame. create_standalone_inputfocus() returns a \c std::pair
	//! containing the new input focus frame display element and the
	//! focusable display element, returned by the lambda, that the input
	//! focus frame got attached to.
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/xcontainer.H>
	//! #include <INSERT_LIBX_NAMESPACE/w/xfocusablecontainer.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::xcontainer container=
	//!     layout->create_generic_container();
	//!
	//! INSERT_LIBX_NAMESPACE::w::xcontainer container=
	//!     layout->create_generic_container(INSERT_LIBX_NAMESPACE::rgb(0, 0 ,0));
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=
	//!     layout->create_focusable_container();
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=
	//!     layout->create_focusable_container(INSERT_LIBX_NAMESPACE::rgb(0, 0 ,0));
	//! \endcode
	//!
	//! create_generic_container() creates a generic
	//! \ref xcontainer "container object",
	//! create_focusable_container() creates a generic container that's
	//! also \ref focusable "focusable". The generic container
	//! creates an inner focusable scope. Display elements
	//! added to the focusable container have their own independent
	//! tabbing order that starts at 0. Tabbing into the focusable
	//! container sets input focus to the first enabled display element
	//! in the container. Back-tabbing sets the input focus to the last
	//! enabled display element. So the tabbing flow appears to be
	//! ordinary, however the tabbing order of the elements inside the
	//! focusable container is independent and separate (a display
	//! element inside the focusable container cannot be set to tab
	//! between the outside elements, and vice versa).
	//!
	//! The new container either inherits its parent container's
	//! background color, or uses an explicit one, for its own
	//! background. An optional second parameter selects
	//! the new container's \ref layout "layout manager", and
	//! defaults to the \ref gridlayout "grid layout manager".
	//!
	//! \code
	//! #include <INSERT_LIBX_NAMESPACE/w/actionbutton.H>
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_normal_actionbutton();
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton_style style(INSERT_LIBX_NAMESPACE::w::rgb(0, 0, 0),
	//!         INSERT_LIBX_NAMESPACE::w::rgb(INSERT_LIBX_NAMESPACE::w::rgb::maximum, INSERT_LIBX_NAMESPACE::w::rgb::maximum, INSERT_LIBX_NAMESPACE::w::rgb::maximum);
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_normal_actionbutton(style);
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_special_actionbutton();
	//!
	//! INSERT_LIBX_NAMESPACE::w::actionbutton button=
	//!     layout->create_special_actionbutton(style);
	//! \endcode
	//!
	//! create_normal_actionbutton() creates an
	//! \ref actionbutton "action button", a button with a border,
	//! that changes background colors when clicked; using the default
	//! button color for the normal and the clicked background, or
	//! \ref actionbutton_style "custom colors".
	//!
	//! create_special_actionbutton() creates a action button with
	//! a slighly thicker border.
	//!
	//! \par Standard display elements
	//!
	//! The following methods combine several primitive display elements together
	//! to form convenient traditional UI objects:
	//!
	//! \code
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus, INSERT_LIBX_NAMESPACE::w::button> button=layout->
	//!      create_checkbox_with_label("Label");
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::inputfocus, INSERT_LIBX_NAMESPACE::w::button> button=layout->
	//!      create_radio_with_label("Label");
	//! \endcode
	//!
	//! create_checkbox_with_label() and create_radio_with_label() creates
	//! an input focus frame containing either a checkbox or a radio button,
	//! and a text label to the right of it.
	//!
	//! The returned \ref inputfocus "input focus frame" is the actual display
	//! element that gets added to the layout manager's container. The
	//! button object is the button inside it.
	//!
	//! \code
	//! std::pair<INSERT_LIBX_NAMESPACE::w::actionbutton, INSERT_LIBX_NAMESPACE::w::ref<INSERT_LIBX_NAMESPACE::w::obj>> button=layout->
	//!      create_normal_actionbutton_with_label([]
	//!          {
	//!             // ...
	//!          }, "Label");
	//!
	//! std::pair<INSERT_LIBX_NAMESPACE::w::actionbutton, INSERT_LIBX_NAMESPACE::w::ref<INSERT_LIBX_NAMESPACE::w::obj>> button=layout->
	//!      create_special_actionbutton_with_label([]
	//!          {
	//!             // ...
	//!          }, "Label");
	//!
	//! \endcode
	//!
	//! Creates an action button with a label, and a callback. The first
	//! parameter is the callback lambda that gets invoked on_activate()-ion.
	//! The second parameter is the button's label. Optional parameters
	//! follow: a character set designator, like unicode::utf_8
	//! (from <unicode.h>), non-default regular and activated background color.
	//! \par Text input fields
	//!
	//! \code
	//! INSERT_LIBX_NAMESPACE::w::text_input_style style=w->default_text_input_style();
	//!
	//! std::string initial_value;
	//!
	//! INSERT_LIBX_NAMESPACE::w::textinputfield input=layout->create_text_input(style, initial_value, 41, 40);
	//!
	//! INSERT_LIBX_NAMESPACE::w::textinputfield input=layout->create_text_input(style, initial_value, unicode::utf_8, 41);
	//! \endcode
	//!
	//! create_text_input() creates a single line text input field. Use
	//! the parent window's default_text_input_style() to obtain a default
	//! \ref drawableObj::text_input_style "text_input_style".
	//!
	//! The initial value of the text input file gets specified using the
	//! current locale's codeset, or by explicitly specifying the character
	//! string's codeset. The initial value can also be given as a
	//! \c std::vector<unicode_char>.
	//!
	//! The third (or the fourth) parameter is the text input field's width,
	//! given in character columns. The actual width gets computed based on the
	//! text input style's font width, that gets multiple by the column character,
	//! deriving the actual width in pixels.
	//!
	//! An optional parameter after the text input field's width specifies the
	//! maximum number of characters that can be entered. The first example
	//! specifies a 41 character wide text input that accepts up to a 40
	//! character text string (the additional character column accomodates the
	//! cursor at the end of the full text string, without scrolling).
	//!
	//! \par Selection lists
	//!
	//! \code
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=create_selection_list_rows(4);
	//!
	//! INSERT_LIBX_NAMESPACE::w::listlayoutstyle custom_style=INSERT_LIBX_NAMESPACE::w::listlayoutstyle::create(parent_window);
	//!
	//! INSERT_LIBX_NAMESPACE::w::xfocusablecontainer container=create_selection_list_rows(4, custom_style);
	//! \endcode
	//!
	//! create_selection_list() creates a focusable container with a
	//! \ref listlayoutmanager "list layout manager". The first parameter
	//! specifies the number of rows in the list, if the list contains only
	//! simple text labels.
	//!
	//! The optional second parameter specifies a custom
	//! \ref listlayoutstyle "list layout style".

	typedef ref<layoutmanagerObj::factoryObj> factory;

	//! A nullable pointer reference to a layout manager's factory

	//! Refer to this class as \c INSERT_LIBX_NAMESPACE::w::layoutmanager::base::factoryptr
	typedef ptr<layoutmanagerObj::factoryObj> factoryptr;
};


#if 0
{
	{
#endif
	}
}

#endif
====================================cut here=================================




In GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9)
 of 2014-05-21 on buildvm-07.phx2.fedoraproject.org
Windowing system distributor `Fedora Project', version 11.0.11404000
Configured using:
 `configure '--build=x86_64-redhat-linux-gnu'
 '--host=x86_64-redhat-linux-gnu' '--program-prefix='
 '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr'
 '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
 '--datadir=/usr/share' '--includedir=/usr/include'
 '--libdir=/usr/lib64' '--libexecdir=/usr/libexec'
 '--localstatedir=/var' '--sharedstatedir=/var/lib'
 '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus'
 '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff'
 '--with-xft' '--with-xpm' '--with-x-toolkit=gtk3' '--with-gpm=no'
 'build_alias=x86_64-redhat-linux-gnu'
 'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
 -fstack-protector-strong --param=ssp-buffer-size=4
 -grecord-gcc-switches -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ''

Important settings:
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: C++/l

Minor modes in effect:
  tooltip-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
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
<right> <right> <right> <right> <right> <right> <right> 
<backspace> <end> SPC s [ p e <backspace> <backspace> 
<backspace> p e c i f i e s SPC a SPC c u s t o m SPC 
l i s t SPC l a y <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <return> / / ! SPC \ r e f SPC l i s t 
l a y o u t s t y l e SPC " l i s t SPC l a y o u t 
SPC s t y l e " . <return> C-SPC <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <escape> w C-x C-b C-x 
o <down> <down> <return> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <down> <down> <down> 
C-y <prior> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <return> <up> / / ! <right> 
C-SPC <next> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <escape> x i n d e n t - r e g 
i o n <return> <help-echo> C-x 1 <prior> <prior> <prior> 
<prior> <prior> <prior> <prior> <prior> <prior> <prior> 
<prior> <prior> <next> <next> <next> <next> <next> 
<next> <next> <next> <next> <next> <next> <next> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
C-x C-s <prior> <help-echo> <escape> x r e p o r t 
- e m a c s - b u g <return>

Recent messages:
Mark set [6 times]
Saved text until "ef listlayoutstyle "list layout style".
"
Mark set [2 times]
Indenting region... done
scroll-down-command: Beginning of buffer
scroll-up-command: End of buffer
Auto-saving...done
Saving file /home/mrsam/src/libcxxw-work/includes/x/w/layoutmanager.H...
Wrote /home/mrsam/src/libcxxw-work/includes/x/w/layoutmanager.H

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message cl-macs gv format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils mule-util misearch multi-isearch vc-git
cc-langs cl cl-lib cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
  2014-07-28 12:47 bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior Sam Varshavchik
@ 2019-10-06 22:42 ` Stefan Kangas
  2019-10-07 18:51   ` Alan Mackenzie
  2019-10-19 16:13   ` Alan Mackenzie
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-10-06 22:42 UTC (permalink / raw)
  To: Sam Varshavchik; +Cc: 18134

found 27.0.50
thanks

Sam Varshavchik <sam.varshavchik@gmail.com> writes:

> I am seeing anomalous behavior in C++ major mode that's triggered by
> long, but not excessively long -- only a few hundred lines -- Doxygen-style
> comments.
>
> Cursor navigation at the end of the Doxygen comment block in the
> following file (just before the first typedef), and trying to add some
> additional text there, results in 3-5 seconds' worth of delays for
> nearly typed character.
>
> Highlighting the entire Doxygen comment block: M-x indent-region takes
> several minutes (!) with emacs consuming 100% CPU.
[Snipped a long C++ example file here.]

I can reproduce both issues on current master using the provided example
file.

1. Editing is very slow after the Doxygen comment block.

2. Opening the example file under "emacs -Q", pressing C-x h TAB takes
   several minutes and sees the emacs process consume 100 % CPU (on one
   core at least).

Using the profiler during step 2 gives me:

>- command-execute                                               59856  97%
> - call-interactively                                           59856  97%
>  - funcall-interactively                                       59827  97%
>   - c-indent-line-or-region                                    59820  97%
>    - c-indent-region                                           59819  97%
>     - c-guess-basic-syntax                                     59809  97%
>      - c-beginning-of-statement-1                              39327  63%
>       - c-crosses-statement-barrier-p                          39105  63%
>        - c-backward-sws                                        22222  36%
>         + c-beginning-of-macro                                   492   0%
>           #<compiled 0x1579d1980ead>                               1   0%
>          c-literal-limits                                       9508  15%
>          c-literal-start                                        6228  10%
>        + c-at-macro-vsemi-p                                      217   0%
>       + c-backward-sws                                            61   0%
>       + c-at-macro-vsemi-p                                        16   0%
>       + c-beginning-of-macro                                      10   0%
>      - c-just-after-func-arglist-p                             19872  32%
>       - c-beginning-of-statement-1                             19872  32%
>        - c-crosses-statement-barrier-p                         19795  32%
>         - c-backward-sws                                       11424  18%
>          + c-beginning-of-macro                                  287   0%
>            #<compiled 0x1579d1980ead>                              2   0%
>           c-literal-limits                                      4707   7%
>           c-literal-start                                       3095   5%
>         + c-at-macro-vsemi-p                                     121   0%
>        + c-backward-sws                                           17   0%
>          c-beginning-of-macro                                      2   0%
>          c-at-macro-vsemi-p                                        1   0%
>        + c-looking-at-inexpr-block                                 1   0%
>      + c-backward-sws                                            202   0%
>      + c-back-over-member-initializers                           106   0%
>      + c-determine-limit                                         103   0%
>      + c-parse-state                                              61   0%
>      + c-looking-at-decl-block                                    55   0%
>      + c-looking-at-inexpr-block                                  19   0%
>      + c-syntactic-skip-backward                                  13   0%
>      + c-back-over-member-initializer-braces                       4   0%
>      + c-beginning-of-decl-1                                       4   0%
>      + c-in-literal                                                3   0%
>      + c-at-macro-vsemi-p                                          1   0%
>      + c-inside-bracelist-p                                        1   0%
>      + c-at-statement-start-p                                      1   0%
>     + c-indent-line                                                9   0%
>   + execute-extended-command                                       7   0%
>  - byte-code                                                      29   0%
>   + read-extended-command                                         29   0%
>+ ...                                                            1784   2%

(Quoted above so Gmail doesn't mess it up...)

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
  2019-10-06 22:42 ` Stefan Kangas
@ 2019-10-07 18:51   ` Alan Mackenzie
  2019-10-07 19:04     ` Stefan Kangas
  2019-10-19 16:13   ` Alan Mackenzie
  1 sibling, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2019-10-07 18:51 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 18134, Sam Varshavchik

Hello, Stefan.

On Mon, Oct 07, 2019 at 00:42:46 +0200, Stefan Kangas wrote:
> found 27.0.50
> thanks

> Sam Varshavchik <sam.varshavchik@gmail.com> writes:

> > I am seeing anomalous behavior in C++ major mode that's triggered by
> > long, but not excessively long -- only a few hundred lines -- Doxygen-style
> > comments.

> > Cursor navigation at the end of the Doxygen comment block in the
> > following file (just before the first typedef), and trying to add some
> > additional text there, results in 3-5 seconds' worth of delays for
> > nearly typed character.

> > Highlighting the entire Doxygen comment block: M-x indent-region takes
> > several minutes (!) with emacs consuming 100% CPU.
> [Snipped a long C++ example file here.]

> I can reproduce both issues on current master using the provided example
> file.

> 1. Editing is very slow after the Doxygen comment block.

> 2. Opening the example file under "emacs -Q", pressing C-x h TAB takes
>    several minutes and sees the emacs process consume 100 % CPU (on one
>    core at least).

I will be looking at this in the coming days.  It is likely to take
several (or even many) days to resolve, not hours.

[ .... ]

> Best regards,
> Stefan Kangas

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
  2019-10-07 18:51   ` Alan Mackenzie
@ 2019-10-07 19:04     ` Stefan Kangas
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-10-07 19:04 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 18134, Sam Varshavchik

Hi Alan,

Alan Mackenzie <acm@muc.de> writes:

> I will be looking at this in the coming days.  It is likely to take
> several (or even many) days to resolve, not hours.

Thanks!  Best of luck with the debugging.

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
  2019-10-06 22:42 ` Stefan Kangas
  2019-10-07 18:51   ` Alan Mackenzie
@ 2019-10-19 16:13   ` Alan Mackenzie
  2019-10-20 13:36     ` Stefan Kangas
  1 sibling, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2019-10-19 16:13 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 18134, Sam Varshavchik

Hello, Stefan and Sam.

On Mon, Oct 07, 2019 at 00:42:46 +0200, Stefan Kangas wrote:
> found 27.0.50
> thanks

> Sam Varshavchik <sam.varshavchik@gmail.com> writes:

> > I am seeing anomalous behavior in C++ major mode that's triggered by
> > long, but not excessively long -- only a few hundred lines -- Doxygen-style
> > comments.

> > Cursor navigation at the end of the Doxygen comment block in the
> > following file (just before the first typedef), and trying to add some
> > additional text there, results in 3-5 seconds' worth of delays for
> > nearly typed character.

> > Highlighting the entire Doxygen comment block: M-x indent-region takes
> > several minutes (!) with emacs consuming 100% CPU.
> [Snipped a long C++ example file here.]

> I can reproduce both issues on current master using the provided example
> file.

> 1. Editing is very slow after the Doxygen comment block.

> 2. Opening the example file under "emacs -Q", pressing C-x h TAB takes
>    several minutes and sees the emacs process consume 100 % CPU (on one
>    core at least).

Yes.  Some optimisation is needed in c-crosses-statement-barrier-p for
large blocks of comments.  Please try out this patch, and let me know if
anything untoward happens:


diff -r d84523ed901e cc-engine.el
--- a/cc-engine.el	Sat Oct 12 08:55:31 2019 +0000
+++ b/cc-engine.el	Sat Oct 19 16:06:23 2019 +0000
@@ -1474,10 +1474,13 @@
 		     (progn
 		       (if (setq lit-start (c-literal-start from)) ; Have we landed in a string/comment?
 			   (goto-char lit-start))
-		       (c-backward-syntactic-ws) ; ? put a limit here, maybe?
+		       (c-backward-syntactic-ws (c-point 'bopl))
 		       (setq vsemi-pos (point))
 		       (c-at-vsemi-p))))
 	      (throw 'done vsemi-pos))
+	     ((progn (c-forward-syntactic-ws to)
+		     (>= (point) to))
+	      (throw 'done nil))
 	     ;; In a string/comment?
 	     ((setq lit-range (c-literal-limits from))
 	      (goto-char (cdr lit-range)))


> Using the profiler during step 2 gives me:

> >- command-execute                                               59856  97%
> > - call-interactively                                           59856  97%
> >  - funcall-interactively                                       59827  97%
> >   - c-indent-line-or-region                                    59820  97%
> >    - c-indent-region                                           59819  97%
> >     - c-guess-basic-syntax                                     59809  97%
> >      - c-beginning-of-statement-1                              39327  63%
> >       - c-crosses-statement-barrier-p                          39105  63% <====
> >        - c-backward-sws                                        22222  36%
> >         + c-beginning-of-macro                                   492   0%
> >           #<compiled 0x1579d1980ead>                               1   0%
> >          c-literal-limits                                       9508  15%
> >          c-literal-start                                        6228  10%
> >        + c-at-macro-vsemi-p                                      217   0%
> >       + c-backward-sws                                            61   0%
> >       + c-at-macro-vsemi-p                                        16   0%
> >       + c-beginning-of-macro                                      10   0%
> >      - c-just-after-func-arglist-p                             19872  32%
> >       - c-beginning-of-statement-1                             19872  32%
> >        - c-crosses-statement-barrier-p                         19795  32%
> >         - c-backward-sws                                       11424  18%
> >          + c-beginning-of-macro                                  287   0%
> >            #<compiled 0x1579d1980ead>                              2   0%
> >           c-literal-limits                                      4707   7%
> >           c-literal-start                                       3095   5%
> >         + c-at-macro-vsemi-p                                     121   0%
> >        + c-backward-sws                                           17   0%
> >          c-beginning-of-macro                                      2   0%
> >          c-at-macro-vsemi-p                                        1   0%
> >        + c-looking-at-inexpr-block                                 1   0%
> >      + c-backward-sws                                            202   0%
> >      + c-back-over-member-initializers                           106   0%
> >      + c-determine-limit                                         103   0%
> >      + c-parse-state                                              61   0%
> >      + c-looking-at-decl-block                                    55   0%
> >      + c-looking-at-inexpr-block                                  19   0%
> >      + c-syntactic-skip-backward                                  13   0%
> >      + c-back-over-member-initializer-braces                       4   0%
> >      + c-beginning-of-decl-1                                       4   0%
> >      + c-in-literal                                                3   0%
> >      + c-at-macro-vsemi-p                                          1   0%
> >      + c-inside-bracelist-p                                        1   0%
> >      + c-at-statement-start-p                                      1   0%
> >     + c-indent-line                                                9   0%
> >   + execute-extended-command                                       7   0%
> >  - byte-code                                                      29   0%
> >   + read-extended-command                                         29   0%
> >+ ...                                                            1784   2%

> (Quoted above so Gmail doesn't mess it up...)

> Best regards,
> Stefan Kangas


-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
  2019-10-19 16:13   ` Alan Mackenzie
@ 2019-10-20 13:36     ` Stefan Kangas
  2019-10-20 17:04       ` Alan Mackenzie
  2019-10-20 23:12       ` Sam Varshavchik
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Kangas @ 2019-10-20 13:36 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 18134, Sam Varshavchik

Hi Alan,

Alan Mackenzie <acm@muc.de> writes:

> Yes.  Some optimisation is needed in c-crosses-statement-barrier-p for
> large blocks of comments.  Please try out this patch, and let me know if
> anything untoward happens:

I've now tried the patch, and it fixes both the slow editing and the
indentation.  I don't code much C++ these days, so I didn't test it
much beyond that.

Thanks for providing a fix.

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
  2019-10-20 13:36     ` Stefan Kangas
@ 2019-10-20 17:04       ` Alan Mackenzie
  2019-10-20 23:12       ` Sam Varshavchik
  1 sibling, 0 replies; 8+ messages in thread
From: Alan Mackenzie @ 2019-10-20 17:04 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 18134-done, Sam Varshavchik

Hello, Stefan and Sam.

On Sun, Oct 20, 2019 at 15:36:23 +0200, Stefan Kangas wrote:
> Hi Alan,

> Alan Mackenzie <acm@muc.de> writes:

> > Yes.  Some optimisation is needed in c-crosses-statement-barrier-p for
> > large blocks of comments.  Please try out this patch, and let me know if
> > anything untoward happens:

> I've now tried the patch, and it fixes both the slow editing and the
> indentation.  I don't code much C++ these days, so I didn't test it
> much beyond that.

> Thanks for providing a fix.

Thanks for the quick test.  I've now committed the fix to master, and
I'm closing the bug with this post.

> Best regards,
> Stefan Kangas

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior
  2019-10-20 13:36     ` Stefan Kangas
  2019-10-20 17:04       ` Alan Mackenzie
@ 2019-10-20 23:12       ` Sam Varshavchik
  1 sibling, 0 replies; 8+ messages in thread
From: Sam Varshavchik @ 2019-10-20 23:12 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Alan Mackenzie, 18134

Thanks to everyone for looking into this.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-20 23:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-28 12:47 bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior Sam Varshavchik
2019-10-06 22:42 ` Stefan Kangas
2019-10-07 18:51   ` Alan Mackenzie
2019-10-07 19:04     ` Stefan Kangas
2019-10-19 16:13   ` Alan Mackenzie
2019-10-20 13:36     ` Stefan Kangas
2019-10-20 17:04       ` Alan Mackenzie
2019-10-20 23:12       ` Sam Varshavchik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).