Subject: 29.1; Performance regression using pipe for subprocess

From: Chris Hanson <[email-masked]>
Date: Sat, 30 Sep 2023 20:57:31 -0400

When using "xscheme.el" to start and interact with MIT/GNU Scheme in a
subprocess, the performance significantly degraded in Emacs 29.1.  It
worked well in older releases.

Here is a recipe:

     emacs -Q
     M-x load-library RET xscheme RET
     M-x run-scheme RET

     and see how slowly the process output is printed as Scheme starts.
     Compare this to Emacs 28.2 or earlier.

I've played around quite a bit to figure out what's going on, and found
that changing xscheme-start-process so that start-process used a pty
instead of a pipe eliminated the performance regression.  That isn't
really a solution since there's some complicated interrupt stuff going
on that crashes the subprocess when a pty is used.  I'm trying to track
that down and fix it but have not succeeded so far.

In GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
  version 1.16.0, Xaw3d scroll bars) of 2023-08-03 built on kleph
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.3 LTS

Configured using:
  'configure --with-x-toolkit=athena --with-tree-sitter
  --with-native-compilation'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XAW3D
XDBE XIM XINPUT2 XPM LUCID ZLIB

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

Major mode: Scheme Interaction

Minor modes in effect:
   diff-auto-refine-mode: t
   windmove-mode: t
   which-function-mode: t
   which-key-mode: t
   savehist-mode: t
   global-git-commit-mode: t
   shell-dirtrack-mode: t
   server-mode: t
   global-edit-server-edit-mode: t
   desktop-save-mode: t
   global-auto-revert-mode: t
   override-global-mode: t
   global-eldoc-mode: t
   show-paren-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   line-number-mode: t
   transient-mark-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t

Load-path shadows:
/home/cph/.emacs.d/elpa/transient-20230919.2146/transient hides 
/usr/local/share/emacs/29.1/lisp/transient
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package hides 
/usr/local/share/emacs/29.1/lisp/use-package/use-package
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package-jump hides 
/usr/local/share/emacs/29.1/lisp/use-package/use-package-jump
/home/cph/.emacs.d/elpa/bind-key-20230203.2004/bind-key hides 
/usr/local/share/emacs/29.1/lisp/use-package/bind-key
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package-bind-key 
hides /usr/local/share/emacs/29.1/lisp/use-package/use-package-bind-key
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package-delight 
hides /usr/local/share/emacs/29.1/lisp/use-package/use-package-delight
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package-lint hides 
/usr/local/share/emacs/29.1/lisp/use-package/use-package-lint
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package-core hides 
/usr/local/share/emacs/29.1/lisp/use-package/use-package-core
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package-diminish 
hides /usr/local/share/emacs/29.1/lisp/use-package/use-package-diminish
/home/cph/.emacs.d/elpa/use-package-20230426.2324/use-package-ensure 
hides /usr/local/share/emacs/29.1/lisp/use-package/use-package-ensure
/home/cph/elisp/xscheme hides 
/usr/local/share/emacs/29.1/lisp/progmodes/xscheme
/home/cph/.emacs.d/elpa/flim-20230808.1153/sasl hides 
/usr/local/share/emacs/29.1/lisp/net/sasl
/home/cph/.emacs.d/elpa/seq-2.24/seq hides 
/usr/local/share/emacs/29.1/lisp/emacs-lisp/seq

Features:
(shadow mail-extr emacsbug pcmpl-gnu goto-addr perl-mode two-column
delsel rect view ucs-normalize novice ibuf-ext wdired macros fileloop
git-rebase markdown-mode eglot external-completion array jsonrpc ert
ewoc flymake-proc flymake c-ts-mode arc-mode archive-mode sort
pcmpl-unix vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference
magit-extras face-remap 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
magit-diff smerge-mode diff magit-core magit-autorevert magit-margin
magit-transient magit-process magit-mode git-timemachine tramp-cmds
rfc2104 conf-mode compare-w pp ispell ibuffer ibuffer-loaddefs vc-hg
vc-bzr tramp-cache time-stamp tramp-sh tramp tramp-loaddefs trampver
tramp-integration tramp-compat tabify man pulse grep compile
display-line-numbers shortdoc misearch multi-isearch help-fns radix-tree
cl-print debug backtrace sh-script executable xscheme files-x mule-util
org-indent org-element org-persist org-id org-refile avl-tree generator
oc-basic ol-eww ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art
mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group
gnus-undo gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source
utf7 nnoo parse-time gnus-spec gnus-int gnus-range gnus-win ol-docview
doc-view jka-compr image-mode exif ol-bibtex bibtex iso8601 ol-bbdb
ol-w3m ol-doi org-link-doi org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-src 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
find-func cal-menu calendar cal-loaddefs org-version org-compat org-macs
mhtml-mode css-mode smie eww xdg url-queue thingatpt shr pixel-fill
kinsoku url-file svg xml mm-url gnus nnheader range wid-edit color
rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri
rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap sgml-mode facemenu dom nxml-util nxml-enc
xmltok scheme js c-ts-common treesit cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs dired-aux vc-git
diff-mode vc-dispatcher whitespace zenburn-theme windmove which-func
imenu which-key savehist git-commit magit-git magit-base magit-section
cursor-sensor crm with-editor comp comp-cstr warnings icons shell
pcomplete comint ansi-osc ansi-color transient format-spec server rx
log-edit message sendmail yank-media puny rfc822 mml mml-sec epa derived
epg rfc6068 epg-config gnus-util text-property-search time-date
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 compat finder-inf exec-path-from-shell edit-server
advice dumb-jump popup dash s xref project ring dired-x dired
dired-loaddefs desktop frameset cph-commands autorevert filenotify
cl-extra help-mode edmacro kmacro use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core dumb-jump-autoloads edit-server-autoloads
exec-path-from-shell-autoloads git-timemachine-autoloads magit-autoloads
pcase git-commit-autoloads magit-section-autoloads dash-autoloads
markdown-mode-autoloads nov-autoloads esxml-autoloads kv-autoloads
popup-autoloads s-autoloads transient-autoloads w3m-load w3m-autoloads
wanderlust-autoloads semi-autoloads flim-autoloads oauth2-autoloads
apel-autoloads which-key-autoloads with-editor-autoloads info
compat-autoloads seq-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 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 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 dynamic-setting system-font-setting
font-render-setting cairo x-toolkit xinput2 x multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 1000671 332582)
  (symbols 48 42644 63)
  (strings 32 178355 25408)
  (string-bytes 1 6621053)
  (vectors 16 113786)
  (vector-slots 8 2668289 163190)
  (floats 8 662 413)
  (intervals 56 41165 25081)
  (buffers 984 86))