Eli Zaretskii writes: >> Date: Tue, 16 Nov 2021 15:21:31 +0800 >> From: Po Lu via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Starting from `emacs -Q', do M-x pixel-scroll-mode RET, then configure >> it as follows: >> >> (setq pixel-dead-time 0) >> (setq pixel-resolution-fine-flag 1) >> (setq garbage-collection-messages t) >> >> Then scroll the display with the mouse wheel. It will garbage collect >> like crazy, leading to a great deal of stuttering (in emacs-28 as well). >> >> I want to reuse most of the code in pixel-scroll.el for XInput2 pixel >> scrolling, but this is holding me back, as the excessive garbage >> collection makes it completely unusable. > > Did you try to figure out which part of the code produces most of the > garbage? Here's the report from the memory profiler scrolling down (emacs)Top with those settings applied in Info: 347,738,992 30% + beginning-of-visual-line 203,047,297 17% + end-of-visual-line 170,995,572 14% + pixel-posn-y-at-point 143,277,076 12% + pixel-visual-line-height 113,156,817 9% + pixel-visible-pos-in-window 99,928,040 8% + if 11,567,121 1% + pixel-line-height 9,885,201 0% + pixel--whistlestop-pixel-up 9,471,180 0% + pixel--whistlestop-line-up 7,420,310 0% + redisplay 5,325,728 0% + window-current-scroll-bars 4,814,936 0% + pixel-scroll-up 4,092,960 0% + pixel-eob-at-top-p 3,597,328 0% + profiler-stop 2,783,202 0% + unless 2,146,848 0% + window-edges 1,586,384 0% + sit-for 1,448,085 0% + window-inside-pixel-edges 1,297,072 0% + pixel-point-at-top-p 1,196,572 0% + pixel-scroll-pixel-up 978,872 0% + mouse-wheel--get-scroll-window 268,778 0% + apply 220,291 0% + eval 166,360 0% + c-type-finder-timer-func 155,896 0% + timer--time-less-p 144,822 0% + read-from-minibuffer 117,312 0% + execute-extended-command 105,840 0% + timer--time-setter 102,392 0% + timer-relative-time 95,312 0% + timer-create 94,648 0% + pixel-scroll-in-rush-p 83,304 0% + Info-check-pointer 66,944 0% + mwheel-scroll 65,968 0% + Info-extract-pointer 38,435 0% + completing-read-default 38,008 0% + frame-focus-state 32,736 0% + funcall-interactively 29,768 0% + posn-at-point 22,176 0% + timer-activate 17,952 0% + window-pixel-edges 17,136 0% + call-interactively 15,840 0% + redisplay_internal (C function) 12,664 0% + command-execute 12,432 0% + jit-lock--run-functions 11,248 0% + menu-bar-update-buffers-1 8,288 0% + # 8,184 0% + x-gtk-map-stock 7,494 0% + window-frame 7,432 0% + pos-visible-in-window-p 7,312 0% + jit-lock-fontify-now 6,336 0% + # 6,336 0% + user-error 6,336 0% + undo-auto--boundaries 3,810 0% + line-number-at-pos 2,120 0% + scroll-up 1,959 0% timer-event-handler 1,921 0% + fboundp 1,905 0% + window-scroll-bars 1,905 0% + constrain-to-field 1,905 0% clear-minibuffer-message 1,905 0% + frame-live-p 1,863 0% + window-margins 1,863 0% + line-pixel-height 1,863 0% + mwheel-event-button 1,863 0% + profiler-memory-running-p 1,056 0% + handle-focus-in 1,056 0% + minibuffer-mode 1,056 0% + # 1,056 0% + menu-bar-update-buffers 1,056 0% + keymap-canonicalize 1,056 0% + run-hooks 1,024 0% mouse-fixup-help-message 912 0% + count-lines 631 0% + profiler-start 21 0% + generate-new-buffer And here's the entire profile: