From: JD Smith <jdtsmith@gmail.com>
To: emacs-devel@gnu.org
Cc: Yuan Fu <casouri@gmail.com>
Subject: Mitigating the long-lines penalty in vundo
Date: Sat, 16 Dec 2023 11:19:51 -0500 [thread overview]
Message-ID: <76DF29CF-0B94-4405-BC8A-4CC80FCC88B5@gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2023-12-16 16:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-16 16:19 JD Smith [this message]
2023-12-16 16:45 ` Mitigating the long-lines penalty in vundo 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76DF29CF-0B94-4405-BC8A-4CC80FCC88B5@gmail.com \
--to=jdtsmith@gmail.com \
--cc=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).