[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4 Performance tips

If you want to display millions of polygons in 30 fps, Gauche-gl is not for you. Consider using implementations that compiles into native code. The purpose of Gauche-gl is to provide reasonable performance for interactive development and experiment.

However, if you know some tips, actually you can go quite far, especially with recent processors and graphics chips.

Avoid alocation within the inner loop.

The functional (non-destructive) operations tend to return newly-allocated objects. Use linear-update (destructive) versions instead, such as matrix-mul!, u8vector-add!, etc, whenever possible. Pre-allocating temporary vectors is also effective.

Reduce the number of calls within the inner loop.

Vertex arrays are much better than calling gl-vertex over and over. Also consider using display lists if you're displaying rigid objects.

Keep numbers within a uniform vector.

Every time you take a number out of a uniform vector (or <vector4f> etc.), Gauche has to wrap the number by a tag (boxing). Also when you store a number into a uniform vector, Gauche has to check the type of the object, then strip a tag (unboxing). Those are all overhead you wouldn't have if you operate directly on uniform vectors (or <vector4f> etc).

Write extensions to accelerate.

If the above strategies are not enough, consider writing computation-intensive part in C as an extension. The easier way is to make C routines operate on uniform vectors, which is essentially a pointer to an array of numbers from C, and let Scheme handle higher-level data structures. (It could be viewed like relations between a coprocessor and a processor; the former does simple, iterative calculations fast, and the latter handles complicated logic).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Shiro Kawai on June, 7 2008 using texi2html 1.78.