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

are dynamic windows really 60X slower than old windows?!



    Date: Tue, 28 Feb 89 16:45:45 EDT
    From: cogen@xn.ll.mit.edu (David Cogen)

    I measured the time to do draw 240 rectangles (with :DRAW-RECTANGLE) and 80
    strings (with :DRAW-STRING) to a DW:DYNAMIC-WINDOW. It took 20 seconds!

Hmm.  I don't get anything like those numbers.  The 240 rectangles take
about a second and the 80 strings take another second, i.e. an order of
magnitude faster than yours.  Are you sure you compiled your code?

You don't say how big your strings are.  I found that :DRAW-STRING to a
dynamic window has a fixed cost and a per-character cost.  It's probably
also dependent on whether the font is variable-width or not.  But the
per-character costs are probably only in the actual drawing, so they are
likely to be the same as for static windows.

    Then I did the same thing to a TV:WINDOW. It took .35 seconds.

    Could dynamic windows really be that slow? Surely not possible. I must be doing
    something wrong. Is there a trick to bring graphics speed to a dynamic window to
    at least within a factor of 2 of a static window?

There's quite a bit of consing going on in the dynamic case.  Unless you
turn output recording off, each rectangle that you draw conses the
following presentation instance:

#<DW::RECTANGLE-GRAPHICS-DISPLAYED-PRESENTATION 1NIL DW::GRAPHICS0 326656517>, an object of flavor DW::RECTANGLE-GRAPHICS-DISPLAYED-PRESENTATION,
 has instance variable values:
  DW::OBJECT:              NIL
  TYPE:                    DW::GRAPHICS
  DW::FORM-OR-LOCATION:    NIL
  DW::INFERIORS:           NIL
  DW::SUPERIOR:            NIL
  DW::HIGHLIGHTING-BOXES:   NIL
  DW::DISPLAYED-BOX:       #<DW::BOX /x 10:40, y 20:60/ 326656533>
  DW::FLAG-WORD:           11
  DW::OPERATION:           :DRAW-RECTANGLE
  DW::ARGUMENTS:           (30 40 10 20 :DRAW)
  DW::PRIORITY:            93
  Flags (#o13) decode as Single-box, Allow-sensitive-inferiors, Allow-sensitive-raw-text

This gets VECTOR-PUSHed onto the window's DISPLAYED-GRAPHICS array.  If
this grows beyond its currently allocated size a new one will have to be
consed and the contents copied.

According to TIME, it appears that :DRAW-RECTANGLE conses 22 words and
:DRAW-STRING conses 25 words.

Because the dynamic case conses, it's also likely to take page faults,
which are pretty unlikely in the static case, which is simply writing
directly into the console bit array.

All this consing can also cause an ephemeral GC flip to take place.

Wrapping DW:WITH-OUTPUT-RECORDING-DISABLED around the code speeds it up
quite a bit.  It doubles the speed of the rectangle code (and it speeds it
up by about 8-10 if the rectangle is off-screen, probably because it
notices early that a non-recorded off-screen graphic is a no-op), and
the string drawing is about 3-4 times faster.  Assuming your .35 second
figure for static windows is correct, this is about one-third the speed,
getting close to the factor of 2 you ask for.
                                                barmar