[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: API pair_content() call is about 7x slower on Fedora 29 vs Bionic

From: Bryan Christ
Subject: Re: API pair_content() call is about 7x slower on Fedora 29 vs Bionic
Date: Fri, 28 Dec 2018 10:11:35 -0600


This really isn't a case of how pspg is coded... that's just a program running inside of my
terminal emulator.  When libvterm starts up, it announces itself as RXVT by setting the env TERM
variable.  As best I can tell the terminfo for RXVT hasn't changed from Bionic to F29 and it
remains defined with 64 total pairs.  So in this example, my emulator is just responding to
whatever pspg emits.  In the case of the problematic code, my CSI SGR handler for reset
fg/bg looks basically like this:

// reset bg color
if(param[i] == 49)
    vterm->pair_split(vterm, v_desc->colors, &fg, &bg);

and the default callback for pair_split looks like this:

// default callback, wrapper for pair_content()
_native_pair_splitter_1(vterm_t *vterm, short pair, short *fg, short *bg)
    (void)vterm;        // make compiler happy

    pair_content(pair, fg, bg);

    return 0;

I "fixed" the problem that Pavel reported to me by plugging in a
replacement for pair_content() with a function that has more
intimate knowledge of how libvterm maps color for itself.

It's not really a fix.  I'm just hiding the problem.

I'll do a quick build using the default callback and provide the callgrind

On Thu, Dec 27, 2018 at 7:43 PM Thomas Dickey <address@hidden> wrote:
On Thu, Dec 27, 2018 at 07:09:09PM -0600, Bryan Christ wrote:
> I was testing the performance of pair_content() 2 different ways.
> 1.  The very unscientific, observation that "pspg" (a db pager) was
> scrolling


> very slowly horizontally when testing my emulator on F29 but not on Bionic.
> 2.  I placed both instances under callgrind which surfaced pair_content() as
> being quite consuming on F29 but not Bionic.

Then that would show the number of calls (as well as some measure of time).

> Since my terminal emulator really has no idea how the caller setup their
> color pair matrix/bindings, the only reliable thing I can do is iterate
> through the enumerated pairs looking for the fg / bg set they specified.
> Albeit, I was already planning to write and interface that allows the
> implementer to supply their own interface equivalent to pair_content() with
> the assumption that the caller has intimate knowledge of the mappings.  For
> my own demo program, I did that, and the performance I expected returned.

I see.  I had in mind something that would iterate over a few million
calls (enough to get some useful timing on the pair_content logic).

> The observations/differences were noted in both xfce4-terminal and
> gnome-terminal in F29 vs Bionic.  A quick peek at both shows that in all
> cases TERM is set to xterm-color256 so I doubt there's a big difference
> there.

sure there is: one has twice as many color pairs.

You can see that using infocmp.  I did that, and also checked the
curses.h header file to see which features were enabled.

Bionic has the _source_ for ncurses 6.1, but uses ABI 5 (pre-2015).
Offhand, with ABI 6 you'll use more memory but for the same calls,
probably get roughly the same performance.  A small benchmark
would prove that one way or the other :-)

The problem with some random program is that there's usually little
care about managing large numbers of color pairs.

> On Thu, Dec 27, 2018 at 6:44 PM Thomas Dickey <address@hidden> wrote:
> > On Thu, Dec 27, 2018 at 05:30:55PM -0600, Bryan Christ wrote:
> > > I spent quite a bit of time tracing down performance issues on Fedora 29.
> > > It turns out, that for whatever reason, pair_content() is about 7x slower
> > > in the ncurses build that comes with Fedora 29 vs the build included with
> > > Bionic Beaver.
> >
> > In a quick check, it seems that Fedora 29's using ABI 6 (infocmp hints that
> > supports 6.1's extended pairs) while Bionic is still using ABI 5:
> >         + no wheel-mouse
> >         + limited to 16 colors
> >
> > Is this for the same terminal description?  How are you testing
> > pair_content?
> > With ABI 6 (whether or not using 6.1), you can have a lot more color pairs,
> > which may be misleading.
> >
> > fwiw, Debian/testing seems fairly comparable to Fedora29.  Ubuntu lags
> > that by a year or two -ymmv

Thomas E. Dickey <address@hidden>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]