Subject: bug#23801: 25.0.95; term.el redraws extremely slow with bidi support enabled, and large buffers

From: Phil Sainty <[email-masked]>
Date: Tue, 21 Jun 2016 02:35:46 +1200

Progress...

I believe the terminal screen refreshes which exhibit the issue
are performed by inserting spaces (with a background colour).

It turns out that we can demonstrate this issue without any other
programs, simply by inserting spaces (or tabs).

Most critically, inserting non-whitespace characters does NOT
cause performance issues! (At least not the ones I've tried.)

(This presumably explains why midnight commander's initial draw
was so comparatively speedy, as it was drawing the final content
from the outset, rather than clearing the screen first and then
writing the content.)

Recipe:

emacs -Q (and maximise the terminal or GUI frame)
M-x term (and run a shell)
printf "%10000s" x

(to insert an 'x' preceded by 9,999 spaces.)

That's not as obvious without a background colour, but we can
provide that easily enough:

printf "\033[41m%10000s\033[47m" x

(Drawing in red, and reverting to a white background. Use 40m
in the final sequence if you need to revert to black instead.)

Bash supports numeric prefix arguments for repetition just like
Emacs, so you can also insert lots of spaces like so:

M-10000 SPC

You can insert 1,000 TABs with:
M-1000 C-v C-i

With this approach we are entering (but not yet submitting) a
command, and I further note that using C-u at this point to erase
our input is also really slow to complete -- but again, only when
it is whitespace being 'erased'.

e.g. M-10000 x C-u is perfectly speedy.