Asger Ottar Alstrup wrote:
Abdelrazak Younes wrote:
As my painting investigation continue, it seems that this problem has _nothing_ to do with painting on screen at all. Modifying a text line between two huge formula exhibits the slow behaviour even if only the text line is repainted on screen (you can use "-dbg painting" to make sure of that.

You are running to conclusions. Math is painted using a different mechanism than text - it goes through MathHullInset. The # debug painting only works for text.

I know but I was talking about this other debug info at line 240 of QLPainter that is also using PAINTING:

if (isDrawingEnabled()) {
        lyxerr[Debug::PAINTING] << "draw " << std::string(str.toUtf8())
                << " at " << x << "," << y << std::endl;
        drawText(x, y, str);
}

So I think I am right there... Well at least for 1.5.


Insert debugging info in the QLPainter around line 253, and you will see that math indeed draws text on the screen.

?? Line 253 is about underlined text:

        if (f.underbar() == LyXFont::ON) {
                underline(f, x, y, textwidth);
        }


"So, for example, if LyX were running
with debug enabled, the debug lines being written to the LyX console
window might cause a noticeable jump in csrss load.  But I haven't
tested that."

csrss.exe handles output to the console. If you are printing stuff to stderr or stdout, this might show in csrss spending a lot of CPU on some systems.

Another bad thing to do is to have lines line

  lyxerr[Debug::PAINTING] << (something here);

because even if Debug::PAINTING is NOT turned on, the (something here) will be evaluated.

You need to rewrite such things to

  if (lyxerr.debugging(Debug::PAINTING)) {
     lyxerr << (something here);
  }

This was my initial idea also but I am not sure if this is useful because is the test is done in any case in the lyxerr << operator. More exactly this test is done at line 97 of debugstream.h:

        std::basic_ostream<charT, traits> & operator[](Type t) {
                if (debug::match(dt, t))
                        return *this;
                return nullstream;

Try running LyX with a command line parameter "-dbg any" and inspect the output when redrawing. If lots of stuff is coming out, review that output to make sure it is not done like the above.

I started my LyX process 45 minutes ago with -dbg any, and the main window has not come up yet - it's still reading the layout files and dumping everything character by character.

So it's fair to conclude that debugstream is a piece of crap. I suspect that even the tiniest lyxerr << statement costs a billion cycles.

Maybe you have a point here. I haven't analysed this code in depth.

Abdel.

Reply via email to