[Twisted-Python] Embedding manhole interpreter into insults widget.

Maxim Lacrima lacrima.maxim at gmail.com
Thu Aug 7 03:00:20 MDT 2014


On 6 August 2014 22:48, Glyph Lefkowitz <glyph at twistedmatrix.com> wrote:

>
> Optimizing this will almost certainly involve patching Twisted.  Which you
> should definitely do :).
>
> The reason the entire screen is redrawn is that a *general* implementation
> of a widget, i.e. one that can be displayed anywhere on the terminal, you
> do just have to redraw the entire widget when certain things happen, like
> when the screen scrolls.  You can see this in other software by observing
> the fairly significant performance difference between a vertical split and
> a horizontal split in tmux.  Nothing to do with Twisted there, just a
> general limitation of terminals.
>

> The optimizations you could implement are one where inputting individual
> characters doesn't cause a full screen redraw, and avoiding a full screen
> redraw when scrolling if the edges of the widget touch the edges of the
> full terminal (setting up a scroll area for that case).
>

When manhole is used directly, then it is very responsive, and the
performance doesn't degrade with increase of screen size. It holds only
what user entered and writes the input line and command output directly to
its transport, without bothering itself with processing of the whole
screen. When I embed manhole into the widget like above, then the
performance suffers. I think this is due to `TerminalBuffer` having to hold
whole widget area (columns * rows) in memory, even if only a small portion
of it is actually occupied by user input and command output. Rendering the
whole buffer on each keystroke is slow. After experimenting a little bit, I
think optimizations that you described mostly apply to
`ManholeWidget.render` method, which shouldn't traverse the whole buffer on
each keystroke. Currently I don't see how this involves patching widget
implementation in Twisted. What is more important to me is that
`TerminalBuffer` implementation is slightly incomplete. I think it misses
color support, because I couldn't make it work with `ColoredManhole`.


>
> -glyph
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>


-- 
Regards,
Maxim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20140807/19bfd0ef/attachment-0002.html>


More information about the Twisted-Python mailing list