[Top][All Lists]

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

Re: [Texmacs-dev] Re: TeXmacs+Axiom

From: Josef Weidendorfer
Subject: Re: [Texmacs-dev] Re: TeXmacs+Axiom
Date: Thu, 24 May 2007 19:13:26 +0200
User-agent: KMail/1.9.6

Hi Joris,

On Thursday 24 May 2007, Joris van der Hoeven wrote:
> > Could you detail a bit? Or where do I find a description of how the 
> > delay process works. Please don't let me read code, I will probably not 
> > understand the essence.
> Basically, local retypesetting is done after every change.
> When typesetting is done, we render, text close to the cursor first.
> The rendering process is interrupted on a new keyboard event,
> even though a minimal number of boxes are always redisplayed.

I tried to come up with an extreme case to be able to reproduce how
this works. I made up one single paragraph with around 100 lines and
_lots_ of font changes (around 6 per line).
Finally I got a latency of around 1/3 of a second from typing one char
to display. This made some observations possible.
(I really do not think this is a "typical" paragraph).

This is from a fresh CVS checkout today.

IMHO there are a few optimizations possible:

* Most of the time, you append characters at the end of the paragraph.
I imagined that this should be faster than typing in the middle, but
this assumption obviously is wrong; the whole paragraph is relayouted
even in this case. Of course, this is totally correct.

We could cheat here: do only a relayout from the typing position to
the end of the paragraph after every key, and a complete relayout
only when idle.
However, I did not check the code if this is easily possible at all.

* When typing faster than display latency, it can last a few seconds
before you see anything of your typing. This means that:
 (1) relayouting seems to be done for key press (otherwise it should
     last a maximum of 0.3 seconds to display after fast typing)
 (2) any redrawing gets completely suppressed when texmacs is busy

(2) is really bad in conjunction with (1). Texmacs should check before
any relayout is triggered whether there is a further key press already
in the input queue, and avoid useless relayouts.
(2) seems to be a bug in the current version according to your

> I tested this strategy on several computers and installations and
> it seems to be the best possible. The only thing which can still be
> essentially improved is locality of the typesetting process.
> Nevertheless, for an ordinary paragraph, a complete typesetting
> is of the order of 0.01ms, so this is not the main bottleneck.

In strange cases, typesetting seems to become a bottleneck.

Just for the record, here is a small oprofile report for this "relayout
bottleneck", only texmacs.bin process, for events "CPU_CLK_UNHALTED"
(= time) and INSTR_RETIRED (number of executed assembly instructions,
not so important).

      samples|      %|  samples|      %|
        25343 81.7648     31711 85.0001 texmacs.bin
         3887 12.5407      3924 10.5181 libguile.so.17.0.1
          942  3.0392       925  2.4794 libc-2.5.so
          552  1.7809       664  1.7798 libpthread-2.5.so

And in more detail...

[Note that there is really nothing to optimize in the following
functions if the above suggested optimizations can be done!]

samples  %        samples  %        image name         symbol name
5353     16.2473  6921     17.9561  texmacs.bin        hashmap_rep<string, 
3192      9.6883  3599      9.3374  texmacs.bin        string::operator()(int, 
2371      7.1964  3002      7.7885  texmacs.bin        get_hyphens(string, 
hashmap<string, string>)
1717      5.2114  2521      6.5406  texmacs.bin        hash(string)
1007      3.0564  1521      3.9461  texmacs.bin        operator new(unsigned 
972       2.9502  1128      2.9265  texmacs.bin        
812       2.4646  902       2.3402  texmacs.bin        string::operator==(char*)
804       2.4403  1379      3.5777  texmacs.bin        operator delete(void*)
775       2.3523  1000      2.5944  libguile.so.17.0.1 deval
696       2.1125  420       1.0897  texmacs.bin        
tex_font_rep::get_extents(string, metric_struct (
671       2.0366  1194      3.0978  texmacs.bin        operator new[](unsigned 
608       1.8454  847       2.1975  texmacs.bin        string_rep::~string_rep()


reply via email to

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