all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Mitigating the long-lines penalty in vundo
@ 2023-12-16 16:19 JD Smith
  2023-12-16 16:45 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: JD Smith @ 2023-12-16 16:19 UTC (permalink / raw)
  To: emacs-devel; +Cc: Yuan Fu

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

Yuan’s excellent ELPA package vundo[1] uses `buffer-undo-list’ and `undo-equiv-table’ to visualize and flexibly navigate the entire tree of edits/undos/redos (see the beautiful explanation how[2]).  We’ve been improving it lately with saved state visibility and diff functionality.  It displays the tree of edits sideways in just a few lines of text or unicode chars in a small buffer at the bottom of the frame.  This works nicely, until you accumulate undo branches >~300 levels deep, which is easy to achieve in long editing sessions, or if you save undo state (e.g. with undo-fu-session).  This leads to displayed lines which are >1000 columns wide.  And then Emacs' dreaded long-line display/edit slowness starts creeping in, imposing a quadratic time penalty [3]:



I verified that this is due to long lines and not some vundo issue per se by simply breaking the tree-drawing algorithm so it wraps to a new line after some max number of columns:



But obviously such “broken” trees aren’t terribly useful as-is.  What creative solutions can people suggest?  The tree draw algorithm [4] is relatively simple, and depth-first.  Only a total of 6 distinct characters are displayed.  It has to do things like “bend” a branch down if it runs into a preexisting branch deeper in the tree.  I didn’t see any improvement by enabling so-long-minor-mode.

Since we don’t need access to more than a window-width worth of tree at a time, is there a simple way to display only some range of columns of a very wide buffer, and have the full structure live in a non-displayed “backing data store”?  Would that even help with the long-line penalty, or does that penalty come in with any sort of character insertion, looking-at, etc. within long lines?  Do we have to resort to our own “backing store” like a ragged array of long vectors, redrawing when the left/right column boundaries change (sounds complicated!)?

Thanks for your insights.

[1] https://github.com/casouri/vundo
[2] https://archive.casouri.cat/note/2021/visual-undo-tree
[3] https://github.com/casouri/vundo/issues/68#issuecomment-1848992975
[4] https://github.com/casouri/vundo/blob/824be351527f7a606b25637f6ba2a00cceade338/vundo.el#L591

[-- Attachment #2.1: Type: text/html, Size: 3376 bytes --]

[-- Attachment #2.2: image.png --]
[-- Type: image/png, Size: 406873 bytes --]

[-- Attachment #2.3: image.png --]
[-- Type: image/png, Size: 143077 bytes --]

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

end of thread, other threads:[~2023-12-17 19:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-16 16:19 Mitigating the long-lines penalty in vundo JD Smith
2023-12-16 16:45 ` Eli Zaretskii
2023-12-16 18:54   ` JD Smith
2023-12-16 19:13     ` Eli Zaretskii
2023-12-16 20:32       ` Stephen Berman
2023-12-16 22:00       ` JD Smith
2023-12-17  7:28         ` Eli Zaretskii
2023-12-17 17:49           ` JD Smith
2023-12-17 18:07             ` Eli Zaretskii
2023-12-17 19:26               ` JD Smith
2023-12-17 19:43                 ` Eli Zaretskii

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.