unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46350: 28.0.50; touchpad-scrolling-eats-lots-of-cpu-samples
@ 2021-02-06 17:33 Andrey Orst
  2021-02-06 17:59 ` Eli Zaretskii
  0 siblings, 1 reply; 26+ messages in thread
From: Andrey Orst @ 2021-02-06 17:33 UTC (permalink / raw)
  To: 46350

[-- Attachment #1: Type: text/plain, Size: 7153 bytes --]

Hello.  I'm experiencing major slowdown in Emacs -q fundamental mode
when setting `mouse-wheel-progressive-speed' to `nil'.  Here are
reproduction steps:

1. Run emacs -q
2. Open some big file, in my case I've opened lisp-mode.el
3. Turn on fundamental-mode (optional)
4. Go to the end of the buffer.
5. Rapidly produce scroll up events from touchpad or mouse wheel
   (although it is much harder to achieve with mouse) with significant
   scroll amount.  By significant scroll amount I mean continuous
   scrolling event from touchpad, which can be achieved by swiping over
   whole touchpad area very rapidly.
6. Observe that Emacs doesn't scroll almost at all and just waits until
   scroll events will stop.  Then it scrolls correct amount.

The delay I'm talking about is what bothers me.

First, there's no delay at all when scrolling with scrollbars
(provided by `scroll-bar-mode').  I can scroll with scrollbars as
rapidly as I want, and there is literally no lag whatsoever.

Second, when producing slow scrolling motion on touchpad or mouse
(e.g. one line at a time) scrolling is very responsive.  But I'm
scrolling one line at a time very rarely so this is useless to me.

Third, this bug also reproduces with default value of
`mouse-wheel-progressive-speed', although it is a bit more difficult
to catch this as it requires enormously big buffer for lag to build
up, as scrolling increases in speed (seemingly) exponentially and can
reach top of the buffer before lag builds up significantly.

Last but not least, this also happens when scrolling down (to buffer
end) but the lag seems to be smaller, yet it still noticeable.

I've did some profiling during irresponsibility the amount of CPU
samples is enormous, but down the tree, called functions don't consume
much.  Here's a fragment of report, and I've also attached profiler
exported report to the mail:

        4400  88% - command-execute
        4359  87%  - funcall-interactively
        3776  75%   - mwheel-scroll
          26   0%      mouse-wheel--get-scroll-window
          26   0%    - run-with-timer
          23   0%     - run-at-time
           4   0%        timer-set-time
           1   0%        timer-set-function
           1   0%        timer-activate
          23   0%    - scroll-up
          12   0%     - eval
           8   0%      - if
           1   0%         display-graphic-p
           1   0%        mode-line-eol-desc
          19   0%    - scroll-down
           9   0%     - eval
           7   0%      - if
           1   0%         frame-parameter
           1   0%        unless
          15   0%    - error-message-string
          11   0%     - substitute-command-keys
           7   0%      - #<compiled -0x1fc708cc6b8a9a73>
           4   0%       - kill-buffer
           2   0%        - replace-buffer-in-windows
           1   0%         - unrecord-window-buffer
           1   0%            assq-delete-all
           2   0%      #<compiled -0xd2dd66c27d231f8>
           1   0%      message
         288   5%   - scroll-bar-toolkit-scroll
         264   5%    - sit-for
          10   0%     - redisplay_internal (C function)
           2   0%      - eval
           1   0%         mode-line-eol-desc
           1   0%         if

My wild guess is that touchpad sends much more input to Emacs, compared
to mouse, and that's why scrolling function has to work with much more
inputs and hence the struggle.  I was under assumption that Emacs'
font-lock was the culprit here, as disabling it kinda helps, but then
I've managed to reproduce it without font locking and now I think that
there might be another issue.  Everything I've tested happened on GCC
Emacs branch, but also happens (and actually a bit more noticeable in
27.1 and master branches).


In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.13, cairo version 1.16.0)
 of 2021-01-17 built on toolbox
Repository revision: 88100bed0af530f04cf56acca9f9d1bb12b45771
Repository branch: feature/native-comp
Windowing system distributor 'Fedora Project', version 11.0.12010000
System Description: Fedora 33 (Workstation Edition)

Configured using:
 'configure --with-nativecomp --with-mailutils
 --prefix=/home/andreyorst/.local/emacs
 --bindir=/home/andreyorst/.local/bin
 '--program-transform-name=s/^ctags$/ctags.emacs/''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE
XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

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
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils jka-compr shortdoc text-property-search
cl-indent comp comp-cstr warnings rx cl-seq cl-macs cl-extra seq
byte-opt gv bytecomp byte-compile cconv inf-lisp comint ansi-color ring
thingatpt profiler help-fns radix-tree cl-print debug backtrace
help-mode find-func time-date subr-x vc-git diff-mode easymenu
easy-mmode cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer 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 cl-preloaded nadvice button
loaddefs faces cus-face pcase macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process nativecomp
emacs)

Memory information:
((conses 16 120435 14545)
 (symbols 48 9569 1)
 (strings 32 28965 2841)
 (string-bytes 1 952843)
 (vectors 16 38276)
 (vector-slots 8 804855 15451)
 (floats 8 80 204)
 (intervals 56 3638 189)
 (buffers 984 12))


-- 
Best regards,
Andrey Listopadov

[-- Attachment #2: report --]
[-- Type: application/octet-stream, Size: 12439 bytes --]


[profiler-profile "28.1" cpu #s(hash-table size 97 test equal rehash-size 1.5 rehash-threshold 0.8125 data ([profiler-report-insert-calltree-children profiler-report-render-calltree-1 profiler-report-rerender-calltree profiler-report-render-calltree profiler-report-setup-buffer profiler-report-profile-other-window profiler-report-cpu profiler-report eval-expression funcall-interactively command-execute nil nil nil nil nil] 1 [display-buffer-pop-up-window display-buffer--maybe-pop-up-window display-buffer--maybe-pop-up-frame-or-window display-buffer pop-to-buffer switch-to-buffer-other-window profiler-report-profile-other-window profiler-report-cpu profiler-report eval-expression funcall-interactively command-execute nil nil nil nil] 6 [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 6539 [redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 37 [timer-activate timer-event-handler nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 3664 [mouse-wheel--get-scroll-window mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 26 [eval redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 3 [scroll-up mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 11 [if eval redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil] 23 [run-at-time run-with-timer mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil] 17 [keymap-canonicalize redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 3 ["#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_10>" apply timer-event-handler nil nil nil nil nil nil nil nil nil nil nil nil nil] 3 [eval scroll-down mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil] 1 ["#<compiled -0xd2dd66c27d231f8>" mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 2 ["#<compiled 0x6607ab7520a98b4>" redisplay--update-region-highlight run-hook-with-args redisplay--pre-redisplay-functions apply "#<compiled 0x1342edd5b5745bef>" redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil] 4 [window-pixel-edges window-at-side-p mode-line-default-help-echo redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil] 5 [scroll-down mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 10 [if eval scroll-up mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 7 [tool-bar-make-keymap-1 tool-bar-make-keymap redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil] 3 [redisplay--update-region-highlight run-hook-with-args redisplay--pre-redisplay-functions apply "#<compiled 0x1342edd5b5745bef>" redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil] 1 [frame-parameter if eval scroll-down mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil] 1 [internal-timer-start-idle nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 2 [run-at-time run-with-timer blink-cursor--start-timer blink-cursor-start apply timer-event-handler nil nil nil nil nil nil nil nil nil nil] 1 [mode-line-eol-desc eval scroll-up mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 [kill-this-buffer-enabled-p redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 2 [mwheel-filter-click-events nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [if eval scroll-down mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 6 [eval scroll-up mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil] 3 ["#<compiled -0x407f9bd5497621a>" internal-echo-keystrokes-prefix nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [undo-auto--add-boundary nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [timer-set-function run-at-time run-with-timer mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 [funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 6 [timer-set-time run-at-time run-with-timer mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 4 [timer-inc-time timer-event-handler nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [tooltip-show-help nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [run-with-idle-timer blink-cursor--start-idle-timer blink-cursor-check blink-cursor--rescan-frames apply "#<compiled 0x1bc2eb6ca99c6a39>" handle-focus-in funcall-interactively command-execute nil nil nil nil nil nil nil] 1 [mode-line-default-help-echo redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 2 [mwheel-inhibit-click-timeout apply timer-event-handler nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [mouse--click-1-maybe-follows-link nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 254 [window-at-side-p mode-line-default-help-echo redisplay_internal\ \(C\ function\) sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil] 1 ["#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_0>" internal--before-save-selected-window scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil] 1 [scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 21 [mode-line-eol-desc eval redisplay_internal\ \(C\ function\) sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil] 1 [if eval redisplay_internal\ \(C\ function\) sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil] 1 ["#<compiled 0x6607ab7520a98b4>" redisplay--update-region-highlight run-hook-with-args redisplay--pre-redisplay-functions apply "#<compiled 0x1342edd5b5745bef>" redisplay_internal\ \(C\ function\) sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil] 1 [frames-on-display-list "#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_0>" internal--before-save-selected-window scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 [redisplay_internal\ \(C\ function\) sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil] 3 [message mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 1 ["#<compiled -0x1fc708cc6b8a9a73>" substitute-command-keys error-message-string mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 3 [kill-buffer "#<compiled -0x1fc708d9ebea0673>" substitute-command-keys error-message-string mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil] 2 [error-message-string mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 4 [apply "#<compiled 0x1342edd5b5745bef>" redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil] 4 [substitute-command-keys error-message-string mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil] 4 [replace-buffer-in-windows kill-buffer "#<compiled -0x1fc708cd2ece9a73>" substitute-command-keys error-message-string mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil] 1 [mode-line-eol-desc eval redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil] 2 ["#<compiled -0x16886ce7ad90d52d>" apply gui-backend-selection-exists-p "#<compiled -0x4c2f306cc48bdb5>" funcall redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil] 1 [internal-echo-keystrokes-prefix nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 4 [timer-activate run-at-time run-with-timer mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 [window-at-side-p mode-line-default-help-echo redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [tooltip-show tooltip-help-tips tooltip-timeout apply timer-event-handler nil nil nil nil nil nil nil nil nil nil nil] 1 [x-show-tip tooltip-show tooltip-help-tips tooltip-timeout apply timer-event-handler nil nil nil nil nil nil nil nil nil nil] 1 [tool-bar-make-keymap redisplay_internal\ \(C\ function\) sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 ["#<compiled 0x1fcc7f61ec2e2>" scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 1 ["#<compiled -0x16886ce7ad90d52d>" apply gui-backend-selection-exists-p "#<compiled -0x4c2f306cc48bdb5>" funcall redisplay_internal\ \(C\ function\) sit-for scroll-bar-toolkit-scroll funcall-interactively command-execute nil nil nil nil nil nil] 2 [run-with-timer mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 3 [run-hook-with-args redisplay--pre-redisplay-functions apply "#<compiled 0x1342edd5b5745bef>" redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil nil nil] 4 [timer-event-handler nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [save-buffers-kill-emacs handle-delete-frame funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil] 6 [save-some-buffers save-buffers-kill-emacs handle-delete-frame funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil] 133 ["#<compiled 0x1f40d722227a>" save-some-buffers save-buffers-kill-emacs handle-delete-frame funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 [handle-delete-frame funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 134 [eval redisplay_internal\ \(C\ function\) save-buffers-kill-emacs handle-delete-frame funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 [handle-focus-out funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [timer-set-idle-time run-with-idle-timer blink-cursor--start-idle-timer blink-cursor-check blink-cursor--rescan-frames apply "#<compiled 0x1bc2eb6ca99c6a39>" handle-focus-in funcall-interactively command-execute nil nil nil nil nil nil] 1 [undo-auto--boundaries undo-auto--add-boundary nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 [unless eval scroll-down mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil] 1 [assq-delete-all unrecord-window-buffer replace-buffer-in-windows kill-buffer "#<compiled -0x1fc708da2f9d3e73>" substitute-command-keys error-message-string mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil] 1 [display-graphic-p if eval scroll-up mwheel-scroll funcall-interactively command-execute nil nil nil nil nil nil nil nil nil] 1 [byte-code command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 19 [font-lock-mode turn-on-font-lock turn-on-font-lock-if-desired global-font-lock-mode-enable-in-buffers run-hooks run-mode-hooks minibuffer-inactive-mode read--expression byte-code command-execute nil nil nil nil nil nil] 1 [read--expression byte-code command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 20 [funcall-interactively command-execute read--expression byte-code command-execute nil nil nil nil nil nil nil nil nil nil nil] 1 [eval-expression funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 4 [Automatic\ GC] 475)) (24606 51417 254368 662000) nil]

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

end of thread, other threads:[~2021-02-08 15:31 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-06 17:33 bug#46350: 28.0.50; touchpad-scrolling-eats-lots-of-cpu-samples Andrey Orst
2021-02-06 17:59 ` Eli Zaretskii
2021-02-06 18:34   ` Andrey Orst
2021-02-06 18:55     ` Andrey Orst
2021-02-06 19:05       ` Eli Zaretskii
2021-02-06 19:02     ` Eli Zaretskii
2021-02-06 19:47       ` Andrey Orst
2021-02-06 20:03         ` Eli Zaretskii
2021-02-07 17:23           ` Andrey Orst
2021-02-07 17:49             ` Eli Zaretskii
2021-02-07 18:33               ` Andrey Orst
2021-02-07 18:44                 ` Eli Zaretskii
2021-02-07 18:52                   ` Andrey Orst
2021-02-07 19:05                     ` Eli Zaretskii
2021-02-07 19:37                       ` Lars Ingebrigtsen
2021-02-07 19:47                         ` Eli Zaretskii
2021-02-07 20:54                           ` Lars Ingebrigtsen
2021-02-07 22:16                     ` Alan Third
2021-02-07 22:22                       ` Andrey Orst
2021-02-07 22:24                         ` Alan Third
2021-02-07 22:30                           ` Andrey Orst
2021-02-08 10:12                             ` Andrey Orst
2021-02-08 14:35                               ` Andrey Orst
2021-02-08 15:28                                 ` Eli Zaretskii
2021-02-08 15:31                                   ` Andrey Orst
2021-02-08 15:19                               ` Eli Zaretskii

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).