[chimera-dev] Coloring speed

Thomas Goddard goddard at cgl.ucsf.edu
Fri Jun 20 10:50:48 PDT 2003


Hi, 

  I did some timing of Chimera coloring PDB 2btv (~50,000 atoms) in
wire mode on my home Redhat 8.0 system.  All atoms and bonds were
given the same color.

  Coloring and drawing with Actions menu:	1.70 seconds
  Breakdown:
    Building molecule display list:		 .88 seconds
    Python loop setting atom/bond colors:        .66 seconds
    Clearing track changes object:		 .11 seconds

After being colored the model renders at 89 frames per second, or about
.01 seconds.  Code much simpler than Chimera would get the new color
drawn in about .05 seconds instead of 1.70 seconds, about 30 times faster.

  The biggest chunk of time is spent rebuilding the display list.  I
believe an OpenGL immediate mode rendering (no display list) could be
done in about .05 seconds.  The frame rate would be slower without the
display list (about 3 times slower in volume display tests).  In this
case it would still rotate perfectly smoothly.  If the user is moving
a slider to flip through many colors the current 1.7 seconds per new
color is horrible.  I made a volume surface display optimization that
draws in immediate mode on the first rendering and builds a display
list on the second rendering that may be helpful here.  It's not clear
since then you get the .88 second pause when you try to rotate the
model.  The Chimera DisplayList() object has an immediate mode flag.
Turning it on reduced the .88 seconds to .31 seconds.  It is still
building a new set of intermediate objects which is why it takes much
longer than my estimated .05 seconds.  This display list overhead
effects every Molecule display change.  It costs .88 seconds to change
the color of a single atom.  If the user is making long sequence of
hand initiated changes (so they don't get batched into one redraw)
these delays are painful.

  The time consumed by setting the atom and bond colors in Python was
.52 seconds with the following "for" loop code:

     for a in m.atoms:
          a.color = blue
     for b in m.bonds:
          b.color = blue

The Chimera actions.py code is a little slower (.66 seconds) because
the color setting in the "for" loop is done with a function call.
Using C++ set_atom_color(atom, color) and set_bond_color(bond, color)
routines reduced the .52 seconds to .27 seconds.  Apparently the
attribute setting in Python is somewhat slow.  With C++
color_atoms(atoms, color) and color_bonds(bonds, color) routines which
took the list of atoms and bonds so the Python "for" loop is not
needed, the time dropped to .18 seconds.  Setting atom and bond colors
entirely in C++ took .08 seconds.  Essentially all of the .08 seconds
is taken by inserting the atoms/bonds into the TrackChanges
stl::set<>.  That happens with all the above methods, so to judge
the Python overhead, the .08 should be subtracted off.  Without TrackChanges
the time would be much less than .01 seconds.

  Most of the remaining time is taken when clearing the TrackChanges
object, .11 seconds.  This traverses the stl::set<>, decrements the
reference count of all the Python atoms and bonds, and clears the set.
The total TrackChanges overhead is .08 + .11 = .19 seconds which is
quite high.

  The code used for these timings in

	socrates:/usr/local/src/staff/goddard/chimera/devel/color_timing

  Tom


More information about the Chimera-dev mailing list