all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
@ 2024-09-02  9:18 Stephane Travostino
  2024-09-02 12:05 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stephane Travostino @ 2024-09-02  9:18 UTC (permalink / raw)
  To: 72960

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

Heavy operations, such as scrolling back and forth in a buffer, are
noticeably laggier, for lack of better word, in the PGTK/Wayland version
than the X11, both tested on KDE in Wayland mode. 

Affects both 29.2 and the latest HEAD compiled a few days ago.

I am unsure whether it is a KDE or Emacs problem.

Running on an AMD RX 6800 XT graphics card on a HiDPI 4k screen at 2x
scaling.

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.43, cairo version 1.18.0) of 2024-08-29 built on
toolbox.tranquility
Repository revision: b6f4ffcc106fdbc21dfea45c75fdc4f217d8f201
Repository branch: makepkg
Windowing system distributor 'The X.Org Foundation', version 11.0.12401002
System Description: Arch Linux

Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
--with-modules --without-m17n-flt --without-gconf
--with-native-compilation=yes --with-xinput2 --with-sound=no
--with-tree-sitter --without-gpm --without-compress-install
'--program-transform-name=s/\([ec]tags\)/\1.emacs/'
'CFLAGS=-march=native -O2 -pipe -fno-plt -fexceptions
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection'
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  vertico-prescient-mode: t
  prescient-persist-mode: t
  marginalia-mode: t
  vertico-mode: t
  consult-notes-denote-mode: t
  denote-menu-bar-mode: t
  whole-line-or-region-global-mode: t
  whole-line-or-region-local-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  server-mode: t
  midnight-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  recentf-mode: t
  super-save-mode: t
  savehist-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  direnv-mode: t
  pulsar-global-mode: t
  pulsar-mode: t
  which-key-mode: t
  winner-mode: t
  pixel-scroll-precision-mode: t
  override-global-mode: t
  gcmh-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  transient-mark-mode: (only . t)
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/var/home/sph/.emacs.d/elpa/ef-themes-1.6.1/theme-loaddefs hides /var/home/sph/.emacs.d/elpa/modus-themes-20240826.647/theme-loaddefs
/var/home/sph/.emacs.d/elpa/which-key-20240620.2145/which-key hides /usr/share/emacs/31.0.50/lisp/which-key
/var/home/sph/.emacs.d/elpa/transient-20240821.158/transient hides /usr/share/emacs/31.0.50/lisp/transient
/var/home/sph/.emacs.d/elpa/ef-themes-1.6.1/theme-loaddefs hides /usr/share/emacs/31.0.50/lisp/theme-loaddefs
/var/home/sph/.emacs.d/elpa/bind-key-20230203.2004/bind-key hides /usr/share/emacs/31.0.50/lisp/bind-key
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package hides /usr/share/emacs/31.0.50/lisp/use-package/use-package
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package-lint hides /usr/share/emacs/31.0.50/lisp/use-package/use-package-lint
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package-jump hides /usr/share/emacs/31.0.50/lisp/use-package/use-package-jump
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package-ensure hides /usr/share/emacs/31.0.50/lisp/use-package/use-package-ensure
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package-diminish hides /usr/share/emacs/31.0.50/lisp/use-package/use-package-diminish
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package-delight hides /usr/share/emacs/31.0.50/lisp/use-package/use-package-delight
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package-core hides /usr/share/emacs/31.0.50/lisp/use-package/use-package-core
/var/home/sph/.emacs.d/elpa/use-package-20230426.2324/use-package-bind-key hides /usr/share/emacs/31.0.50/lisp/use-package/use-package-bind-key
/usr/share/emacs/site-lisp/xscheme hides /usr/share/emacs/31.0.50/lisp/progmodes/xscheme
/var/home/sph/.emacs.d/elpa/idlwave-6.5.1/idlwave hides /usr/share/emacs/31.0.50/lisp/progmodes/idlwave
/var/home/sph/.emacs.d/elpa/idlwave-6.5.1/idlw-toolbar hides /usr/share/emacs/31.0.50/lisp/progmodes/idlw-toolbar
/var/home/sph/.emacs.d/elpa/idlwave-6.5.1/idlw-shell hides /usr/share/emacs/31.0.50/lisp/progmodes/idlw-shell
/var/home/sph/.emacs.d/elpa/idlwave-6.5.1/idlw-help hides /usr/share/emacs/31.0.50/lisp/progmodes/idlw-help
/var/home/sph/.emacs.d/elpa/idlwave-6.5.1/idlw-complete-structtag hides /usr/share/emacs/31.0.50/lisp/progmodes/idlw-complete-structtag
/var/home/sph/.emacs.d/elpa/heex-ts-mode-20240113.1104/heex-ts-mode hides /usr/share/emacs/31.0.50/lisp/progmodes/heex-ts-mode
/var/home/sph/.emacs.d/elpa/elixir-ts-mode-20240116.645/elixir-ts-mode hides /usr/share/emacs/31.0.50/lisp/progmodes/elixir-ts-mode
/var/home/sph/.emacs.d/elpa/faceup-20170925.1946/faceup hides /usr/share/emacs/31.0.50/lisp/emacs-lisp/faceup

Features:
(shadow sort mail-extr emacsbug avy-zap mule-util helpful cc-langs trace
cl-print edebug f elisp-refs s ps-mode vc-svn two-column
vertico-directory vc-git vc-dispatcher flymake-shellcheck misearch
multi-isearch flymake-cc elec-pair cap-words superword subword
dtrt-indent advice company-yasnippet company-files company-capf company
make-mode org-indent oc-basic org-element org-persist org-id org-refile
org-element-ast inline avl-tree ol-eww eww url-queue mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view
mml-smime smime dig gnus-sum shr pixel-fill kinsoku url-file svg
gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail
mail-source utf7 nnoo gnus-spec gnus-int gnus-range gnus-win gnus
nnheader range ol-docview doc-view jka-compr image-mode exif ol-bibtex
bibtex ol-bbdb ol-w3m ol-doi org-link-doi crux sph-src-boon
sph-src-completion vertico-prescient prescient char-fold hotfuzz
marginalia vertico sph-src-consult sph-src-denote consult-notes-denote
consult-notes consult denote sph-dired dired-x sph-editing ws-butler
whole-line-or-region avy sph-src-eglot eglot external-completion jsonrpc
flymake ert ewoc debug backtrace sph-src-evil sph-src-format
sph-src-keybinds sph-src-lang-c sph-src-lang-elixir sph-src-lang-go
go-ts-mode go-mode find-file ffap sph-src-lang-html sgml-mode facemenu
dom sph-src-lang-javascript sph-src-lang-nim nim-mode commenter nim-fill
nim-smie nim-helper nim-util nim-syntax nim-rx nim-vars
sph-src-lang-odin odin-mode js c-ts-common cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
sph-src-lang-php sph-src-lang-rust sph-src-langs sph-src-paredit
geiser-mit geiser-guile info-look geiser geiser-debug geiser-repl
geiser-image geiser-capf geiser-doc geiser-menu geiser-autodoc
geiser-edit etags fileloop generator xref geiser-completion geiser-eval
geiser-connection tq geiser-syntax scheme geiser-impl help-fns
radix-tree geiser-log geiser-popup view geiser-custom geiser-base
parinfer-rust-mode parinfer-rust-changes parinfer-rust
parinfer-rust-helper sph-src-magit forge-repos forge-tablist hl-line
forge-topics forge-commands forge-semi forge-bitbucket buck forge-gogs
gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy
gsexp ghub url-http url-gw nsm url-auth let-alist gnutls forge-notify
forge-revnote forge-pullreq forge-issue forge-topic yaml eieio-custom
bug-reference forge-post markdown-mode edit-indirect forge-repo forge
forge-core forge-db closql emacsql-sqlite-common emacsql
emacsql-compiler eieio-base magit-bookmark magit-submodule magit-blame
magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch
magit-clone magit-remote magit-commit magit-sequence magit-notes
magit-worktree magit-tag magit-merge magit-branch magit-reset
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log which-func imenu magit-diff smerge-mode diff
git-commit log-edit message sendmail yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils
mailheader pcvs-util add-log magit-core magit-autorevert magit-margin
magit-transient magit-process with-editor server magit-mode transient
benchmark magit-git magit-base magit-section cursor-sensor crm compat
sph-src-misc midnight vundo re-builder delsel autorevert filenotify
recentf tree-widget comp comp-cstr warnings super-save savehist
sph-src-org org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src sh-script smie treesit executable ob-comint org-pcomplete
org-list org-footnote org-faces org-entities noutline outline
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold
org-fold-core org-keys oc org-loaddefs thingatpt cal-menu calendar
cal-loaddefs org-version org-compat org-macs sph-src-programming
yasnippet direnv diff-mode track-changes dash sph-src-project project
sph-src-prose languagetool languagetool-server languagetool-console
languagetool-java languagetool-issue languagetool-correction
languagetool-core ispell sph-terminal vterm bookmark face-remap compile
text-property-search term disp-table ehelp find-func vterm-module
term/xterm xterm sph-src-theme modus-vivendi-tritanopia-theme
modus-operandi-tritanopia-theme modus-vivendi-deuteranopia-theme
modus-operandi-deuteranopia-theme modus-vivendi-tinted-theme
modus-operandi-tinted-theme modus-vivendi-theme modus-operandi-theme
modus-themes dbus comp-run comp-common xml sph-src-tramp tramp trampver
tramp-integration files-x tramp-message tramp-compat xdg shell pcomplete
comint ansi-osc parse-time iso8601 time-date format-spec ansi-color
tramp-loaddefs sph-src-tree-sitter sph-src-ui pulsar pulse color
which-key winner pixel-scroll cua-base ring zoom edmacro kmacro
use-package-bind-key bind-key easy-mmode rx sph-workspaces
sph-core-config sph-core-prelude gcmh cl-extra help-mode vc-use-package
use-package-ensure use-package-core cus-edit pp cus-load wid-edit
finder-inf avy-zap-autoloads avy-autoloads boon-autoloads
bufferlo-autoloads company-autoloads consult-notes-autoloads
consult-project-extra-autoloads consult-autoloads crux-autoloads
deft-autoloads denote-autoloads dired-sidebar-autoloads
dired-subtree-autoloads dired-hacks-utils-autoloads direnv-autoloads
dtrt-indent-autoloads eat-autoloads ef-themes-autoloads
eglot-booster-autoloads elixir-ts-mode-autoloads expand-region-autoloads
faceup-autoloads flymake-shellcheck-autoloads forge-autoloads
closql-autoloads emacsql-autoloads format-all-autoloads
forth-mode-autoloads gcmh-autoloads geiser-guile-autoloads
geiser-mit-autoloads geiser-autoloads ghub-autoloads go-mode-autoloads
heex-ts-mode-autoloads helpful-autoloads elisp-refs-autoloads
f-autoloads hotfuzz-autoloads howm-autoloads idlwave-autoloads
inheritenv-autoloads just-mode-autoloads langtool-autoloads
language-id-autoloads languagetool-autoloads lua-mode-autoloads
magit-autoloads pcase git-commit-autoloads magit-section-autoloads
dash-autoloads marginalia-autoloads markdown-mode-autoloads
modus-themes-autoloads multiple-cursors-autoloads nim-mode-autoloads
flycheck-nimsuggest-autoloads flycheck-autoloads commenter-autoloads
epc-autoloads ctable-autoloads concurrent-autoloads deferred-autoloads
olivetti-autoloads paredit-autoloads parinfer-rust-mode-autoloads
php-mode-autoloads pulsar-autoloads rust-mode-autoloads s-autoloads
super-save-autoloads transient-autoloads treepy-autoloads try-autoloads
use-package-autoloads bind-key-autoloads vc-use-package-autoloads
vertico-prescient-autoloads vertico-autoloads prescient-autoloads
vterm-autoloads vue-mode-autoloads edit-indirect-autoloads
ssass-mode-autoloads vue-html-mode-autoloads mmm-mode-autoloads
vundo-autoloads web-mode-autoloads which-key-autoloads
whole-line-or-region-autoloads info with-editor-autoloads
ws-butler-autoloads yaml-autoloads yaml-mode-autoloads
yasnippet-autoloads zoom-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
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 emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)

Memory information:
((conses 16 1142139 1538133) (symbols 48 70089 4)
(strings 32 338997 58702) (string-bytes 1 9668153)
(vectors 16 206510) (vector-slots 8 4151356 115944)
(floats 8 1793 5011) (intervals 56 1711 666) (buffers 992 20))

[-- Attachment #2: Type: text/html, Size: 18061 bytes --]

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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-02  9:18 bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version Stephane Travostino
@ 2024-09-02 12:05 ` Eli Zaretskii
  2024-09-02 12:12   ` Stephane Travostino
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-09-02 12:05 UTC (permalink / raw)
  To: Stephane Travostino; +Cc: 72960

> Date: Mon, 02 Sep 2024 10:18:03 +0100
> From: "Stephane Travostino" <sph@combo.cc>
> 
> Heavy operations, such as scrolling back and forth in a buffer, are
> noticeably laggier, for lack of better word, in the PGTK/Wayland version
> than the X11, both tested on KDE in Wayland mode. 
> 
> Affects both 29.2 and the latest HEAD compiled a few days ago.
> 
> I am unsure whether it is a KDE or Emacs problem.
> 
> Running on an AMD RX 6800 XT graphics card on a HiDPI 4k screen at 2x
> scaling.

AFAIU, this is a problem with GTK input methods.  From PROBLEMS:

  *** Emacs built with GTK lags in its response to keyboard input.
  This can happen when input methods are used.  It happens because Emacs
  behaves in an unconventional way with respect to GTK input methods: it
  registers to receive keyboard input as unprocessed key events with
  metadata (as opposed to receiving them as text strings).  Most GTK
  programs use the latter approach, so some modern input methods have
  bugs and misbehave when faced with the way Emacs does it.

  A workaround is to set GTK_IM_MODULE=none in the environment, or maybe
  find a different input method without these problems.





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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-02 12:05 ` Eli Zaretskii
@ 2024-09-02 12:12   ` Stephane Travostino
  2024-09-03 11:27     ` Stephane Travostino
  0 siblings, 1 reply; 9+ messages in thread
From: Stephane Travostino @ 2024-09-02 12:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72960

On Mon, 2 Sep 2024, at 13:05, Eli Zaretskii wrote:
>> Date: Mon, 02 Sep 2024 10:18:03 +0100
>> From: "Stephane Travostino" <sph@combo.cc>
>> 
>> Heavy operations, such as scrolling back and forth in a buffer, are
>> noticeably laggier, for lack of better word, in the PGTK/Wayland version
>> than the X11, both tested on KDE in Wayland mode. 
>> 
>> Affects both 29.2 and the latest HEAD compiled a few days ago.
>> 
>> I am unsure whether it is a KDE or Emacs problem.
>> 
>> Running on an AMD RX 6800 XT graphics card on a HiDPI 4k screen at 2x
>> scaling.
>
> AFAIU, this is a problem with GTK input methods.  From PROBLEMS:
>
>   *** Emacs built with GTK lags in its response to keyboard input.
>   This can happen when input methods are used.  It happens because Emacs
>   behaves in an unconventional way with respect to GTK input methods: it
>   registers to receive keyboard input as unprocessed key events with
>   metadata (as opposed to receiving them as text strings).  Most GTK
>   programs use the latter approach, so some modern input methods have
>   bugs and misbehave when faced with the way Emacs does it.
>
>   A workaround is to set GTK_IM_MODULE=none in the environment, or maybe
>   find a different input method without these problems.

Thank you, though without more scientific methods of measuring latency I can't tell if that helps or not. 

I noticed I had pixel precision scrolling mode on and that contributed a large part to that feeling of lag compared to other programs. If Firefox is able to smooth scroll at 60 Hz, I would say empirically Emacs PGTK would scroll at 15 Hz, making navigation in the buffer a choppy affair. 





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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-02 12:12   ` Stephane Travostino
@ 2024-09-03 11:27     ` Stephane Travostino
  2024-09-03 12:52       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stephane Travostino @ 2024-09-03 11:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72960

On Mon, 2 Sep 2024, at 13:12, Stephane Travostino wrote:
> On Mon, 2 Sep 2024, at 13:05, Eli Zaretskii wrote:
>>> Date: Mon, 02 Sep 2024 10:18:03 +0100
>>> From: "Stephane Travostino" <sph@combo.cc>
>>> 
>>> Heavy operations, such as scrolling back and forth in a buffer, are
>>> noticeably laggier, for lack of better word, in the PGTK/Wayland version
>>> than the X11, both tested on KDE in Wayland mode. 
>>> 
>>> Affects both 29.2 and the latest HEAD compiled a few days ago.
>>> 
>>> I am unsure whether it is a KDE or Emacs problem.
>>> 
>>> Running on an AMD RX 6800 XT graphics card on a HiDPI 4k screen at 2x
>>> scaling.
>>
>> AFAIU, this is a problem with GTK input methods.  From PROBLEMS:
>>
>>   *** Emacs built with GTK lags in its response to keyboard input.
>>   This can happen when input methods are used.  It happens because Emacs
>>   behaves in an unconventional way with respect to GTK input methods: it
>>   registers to receive keyboard input as unprocessed key events with
>>   metadata (as opposed to receiving them as text strings).  Most GTK
>>   programs use the latter approach, so some modern input methods have
>>   bugs and misbehave when faced with the way Emacs does it.
>>
>>   A workaround is to set GTK_IM_MODULE=none in the environment, or maybe
>>   find a different input method without these problems.
>
> Thank you, though without more scientific methods of measuring latency 
> I can't tell if that helps or not. 
>
> I noticed I had pixel precision scrolling mode on and that contributed 
> a large part to that feeling of lag compared to other programs. If 
> Firefox is able to smooth scroll at 60 Hz, I would say empirically 
> Emacs PGTK would scroll at 15 Hz, making navigation in the buffer a 
> choppy affair.

Update: GTK_IM_MODULE=none does not make it any less laggier. It is mostly felt in typing and editing source code, and switching to the X11 build makes it immensely snappier and doesn't feel like I'm working through a remote connection.

FYI there are other reports online of people noticing major latency in HiDPI mode with the PGTK version, especially when the frame is fullscreen (so there's more pixels to update):  

https://old.reddit.com/r/emacs/comments/ucv0at/awful_performance_with_pgtk_on_wayland/

https://old.reddit.com/r/emacs/comments/1acdieh/pgtk_emacs_high_input_lag_at_large_frame_sizes_on/





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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-03 11:27     ` Stephane Travostino
@ 2024-09-03 12:52       ` Eli Zaretskii
  2024-09-03 15:36         ` Stephane Travostino
  2024-09-04  0:57         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 9+ messages in thread
From: Eli Zaretskii @ 2024-09-03 12:52 UTC (permalink / raw)
  To: Stephane Travostino, Po Lu; +Cc: 72960

> Date: Tue, 03 Sep 2024 12:27:09 +0100
> From: "Stephane Travostino" <sph@combo.cc>
> Cc: 72960@debbugs.gnu.org
> 
> On Mon, 2 Sep 2024, at 13:12, Stephane Travostino wrote:
> > On Mon, 2 Sep 2024, at 13:05, Eli Zaretskii wrote:
> >>> Date: Mon, 02 Sep 2024 10:18:03 +0100
> >>> From: "Stephane Travostino" <sph@combo.cc>
> >>> 
> >>> Heavy operations, such as scrolling back and forth in a buffer, are
> >>> noticeably laggier, for lack of better word, in the PGTK/Wayland version
> >>> than the X11, both tested on KDE in Wayland mode. 
> >>> 
> >>> Affects both 29.2 and the latest HEAD compiled a few days ago.
> >>> 
> >>> I am unsure whether it is a KDE or Emacs problem.
> >>> 
> >>> Running on an AMD RX 6800 XT graphics card on a HiDPI 4k screen at 2x
> >>> scaling.
> >>
> >> AFAIU, this is a problem with GTK input methods.  From PROBLEMS:
> >>
> >>   *** Emacs built with GTK lags in its response to keyboard input.
> >>   This can happen when input methods are used.  It happens because Emacs
> >>   behaves in an unconventional way with respect to GTK input methods: it
> >>   registers to receive keyboard input as unprocessed key events with
> >>   metadata (as opposed to receiving them as text strings).  Most GTK
> >>   programs use the latter approach, so some modern input methods have
> >>   bugs and misbehave when faced with the way Emacs does it.
> >>
> >>   A workaround is to set GTK_IM_MODULE=none in the environment, or maybe
> >>   find a different input method without these problems.
> >
> > Thank you, though without more scientific methods of measuring latency 
> > I can't tell if that helps or not. 
> >
> > I noticed I had pixel precision scrolling mode on and that contributed 
> > a large part to that feeling of lag compared to other programs. If 
> > Firefox is able to smooth scroll at 60 Hz, I would say empirically 
> > Emacs PGTK would scroll at 15 Hz, making navigation in the buffer a 
> > choppy affair.
> 
> Update: GTK_IM_MODULE=none does not make it any less laggier. It is mostly felt in typing and editing source code, and switching to the X11 build makes it immensely snappier and doesn't feel like I'm working through a remote connection.

Please try profiling the lagging cases with "M-x profiler", and post
the profile here.

Po Lu, any other ideas or suggestions?

> FYI there are other reports online of people noticing major latency in HiDPI mode with the PGTK version, especially when the frame is fullscreen (so there's more pixels to update):  
> 
> https://old.reddit.com/r/emacs/comments/ucv0at/awful_performance_with_pgtk_on_wayland/
> 
> https://old.reddit.com/r/emacs/comments/1acdieh/pgtk_emacs_high_input_lag_at_large_frame_sizes_on/

I don't doubt what you report is real.





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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-03 12:52       ` Eli Zaretskii
@ 2024-09-03 15:36         ` Stephane Travostino
  2024-09-03 16:01           ` Eli Zaretskii
  2024-09-04  0:57         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 9+ messages in thread
From: Stephane Travostino @ 2024-09-03 15:36 UTC (permalink / raw)
  To: Eli Zaretskii, Po Lu; +Cc: 72960

On Tue, 3 Sep 2024, at 13:52, Eli Zaretskii wrote:
>> Date: Tue, 03 Sep 2024 12:27:09 +0100
>> From: "Stephane Travostino" <sph@combo.cc>
>> Cc: 72960@debbugs.gnu.org
>> 
>> On Mon, 2 Sep 2024, at 13:12, Stephane Travostino wrote:
>> > On Mon, 2 Sep 2024, at 13:05, Eli Zaretskii wrote:
>> >>> Date: Mon, 02 Sep 2024 10:18:03 +0100
>> >>> From: "Stephane Travostino" <sph@combo.cc>
>> >>> 
>> >>> Heavy operations, such as scrolling back and forth in a buffer, are
>> >>> noticeably laggier, for lack of better word, in the PGTK/Wayland version
>> >>> than the X11, both tested on KDE in Wayland mode. 
>> >>> 
>> >>> Affects both 29.2 and the latest HEAD compiled a few days ago.
>> >>> 
>> >>> I am unsure whether it is a KDE or Emacs problem.
>> >>> 
>> >>> Running on an AMD RX 6800 XT graphics card on a HiDPI 4k screen at 2x
>> >>> scaling.
>> >>
>> >> AFAIU, this is a problem with GTK input methods.  From PROBLEMS:
>> >>
>> >>   *** Emacs built with GTK lags in its response to keyboard input.
>> >>   This can happen when input methods are used.  It happens because Emacs
>> >>   behaves in an unconventional way with respect to GTK input methods: it
>> >>   registers to receive keyboard input as unprocessed key events with
>> >>   metadata (as opposed to receiving them as text strings).  Most GTK
>> >>   programs use the latter approach, so some modern input methods have
>> >>   bugs and misbehave when faced with the way Emacs does it.
>> >>
>> >>   A workaround is to set GTK_IM_MODULE=none in the environment, or maybe
>> >>   find a different input method without these problems.
>> >
>> > Thank you, though without more scientific methods of measuring latency 
>> > I can't tell if that helps or not. 
>> >
>> > I noticed I had pixel precision scrolling mode on and that contributed 
>> > a large part to that feeling of lag compared to other programs. If 
>> > Firefox is able to smooth scroll at 60 Hz, I would say empirically 
>> > Emacs PGTK would scroll at 15 Hz, making navigation in the buffer a 
>> > choppy affair.
>> 
>> Update: GTK_IM_MODULE=none does not make it any less laggier. It is mostly felt in typing and editing source code, and switching to the X11 build makes it immensely snappier and doesn't feel like I'm working through a remote connection.
>
> Please try profiling the lagging cases with "M-x profiler", and post
> the profile here.

I don't know how to make a consistent test case. I have tried here to profile opening Emacs (same commit with and without PGTK) on the same 547-line Elixir file, and holding the Down key until it reaches the bottom and then back to the top of the buffer. I have (setopt scroll-conservatively 101) so after the first page the contents are continuously redrawn for every new line. 

The PGTK version feels like it's skipping frames while it's relatively smooth on X11:

X11:        
        8795  86% + redisplay_internal (C function)
        1141  11% + command-execute
          54   0% + direnv--maybe-update-environment
          49   0% + gcmh-register-idle-gc
          42   0% + winner-save-old-configurations
          20   0% + timer-event-handler
          18   0% + ...
          18   0% + jit-lock--antiblink-post-command


PGTK:
        9387  91% + redisplay_internal (C function)
         698   6% + command-execute
          19   0% + ...
          19   0% + timer-event-handler
          12   0% + direnv--maybe-update-environment
          11   0% + winner-save-old-configurations
 
I have run this a few times and in Wayland `redisplay_internal` takes always a few percent more time than on X11, though I am not sure these numbers can prove anything as they are quite close.

Is there some kind of consistent UI benchmark I can run? The frame skipping reminds me of missed vsync deadlines one might experience in games.





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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-03 15:36         ` Stephane Travostino
@ 2024-09-03 16:01           ` Eli Zaretskii
  2024-09-04  0:58             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-09-03 16:01 UTC (permalink / raw)
  To: Stephane Travostino; +Cc: luangruo, 72960

> Date: Tue, 03 Sep 2024 16:36:44 +0100
> From: "Stephane Travostino" <sph@combo.cc>
> Cc: 72960@debbugs.gnu.org
> 
> > Please try profiling the lagging cases with "M-x profiler", and post
> > the profile here.
> 
> I don't know how to make a consistent test case. I have tried here to profile opening Emacs (same commit with and without PGTK) on the same 547-line Elixir file, and holding the Down key until it reaches the bottom and then back to the top of the buffer. I have (setopt scroll-conservatively 101) so after the first page the contents are continuously redrawn for every new line. 
> 
> The PGTK version feels like it's skipping frames while it's relatively smooth on X11:
> 
> X11:        
>         8795  86% + redisplay_internal (C function)
>         1141  11% + command-execute
>           54   0% + direnv--maybe-update-environment
>           49   0% + gcmh-register-idle-gc
>           42   0% + winner-save-old-configurations
>           20   0% + timer-event-handler
>           18   0% + ...
>           18   0% + jit-lock--antiblink-post-command
> 
> 
> PGTK:
>         9387  91% + redisplay_internal (C function)
>          698   6% + command-execute
>           19   0% + ...
>           19   0% + timer-event-handler
>           12   0% + direnv--maybe-update-environment
>           11   0% + winner-save-old-configurations
>  
> I have run this a few times and in Wayland `redisplay_internal` takes always a few percent more time than on X11, though I am not sure these numbers can prove anything as they are quite close.

Thanks.  Maybe Po Lu will have some ideas.

> Is there some kind of consistent UI benchmark I can run? The frame skipping reminds me of missed vsync deadlines one might experience in games.

Try this:

  (defun scroll-up-benchmark ()
    (interactive)
    (let ((oldgc gcs-done)
	  (oldtime (float-time)))
      (condition-case nil (while t (scroll-up) (redisplay))
	(error (message "GCs: %d Elapsed time: %f seconds"
			(- gcs-done oldgc) (- (float-time) oldtime))))))

Evaluate this function, then visit a large file, like src/xdisp.c from
the Emacs sources, and invoke "M-x scroll-up-benchmark RET".  It will
show the time it took at the end.  Record the results and compare with
the other configuration.





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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-03 12:52       ` Eli Zaretskii
  2024-09-03 15:36         ` Stephane Travostino
@ 2024-09-04  0:57         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 9+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-04  0:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72960, Stephane Travostino

Eli Zaretskii <eliz@gnu.org> writes:

> Po Lu, any other ideas or suggestions?
>
>> FYI there are other reports online of people noticing major latency in HiDPI mode with the PGTK version, especially when the frame is fullscreen (so there's more pixels to update):  
>> 
>> https://old.reddit.com/r/emacs/comments/ucv0at/awful_performance_with_pgtk_on_wayland/
>> 
>> https://old.reddit.com/r/emacs/comments/1acdieh/pgtk_emacs_high_input_lag_at_large_frame_sizes_on/
>
> I don't doubt what you report is real.

I proposed a theory in a number of other tickets concerning this lag,
specifically that the GTK 3 toolkit cannot take advantage of hardware
accelerated graphics on Wayland, which produces perceptible delays on
large displays.





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

* bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version
  2024-09-03 16:01           ` Eli Zaretskii
@ 2024-09-04  0:58             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 9+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-04  0:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72960, Stephane Travostino

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks.  Maybe Po Lu will have some ideas.

I mentioned one.  I think a C profiler (e.g. gprof) would provide more
insightful data.





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

end of thread, other threads:[~2024-09-04  0:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02  9:18 bug#72960: 31.0.50; PGTK Wayland exhibits more lag than X11 version Stephane Travostino
2024-09-02 12:05 ` Eli Zaretskii
2024-09-02 12:12   ` Stephane Travostino
2024-09-03 11:27     ` Stephane Travostino
2024-09-03 12:52       ` Eli Zaretskii
2024-09-03 15:36         ` Stephane Travostino
2024-09-03 16:01           ` Eli Zaretskii
2024-09-04  0:58             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-04  0:57         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.