[gambit-list] Speed of u8vector-ref

Marc Feeley feeley at iro.umontreal.ca
Tue Oct 27 10:04:53 EDT 2009

On 2009-10-27, at 9:54 AM, Alex Queiroz wrote:

> Hallo,
>     According to statprof, I am spending nearly 40% of my running
> time in lines which call 'board-ref', which is simply defined as:
> (define board-ref u8vector-ref)
> 'u8vector-ref' seems a pretty low-level call, so I can't see how this
> can be improved further. It is just a macro around '##u8vector-ref'.

That's hard to believe... If u8vector-ref is really a *macro* you  
can't use "define" to set board-ref to that macro.

You'd need:

(define-macro (board-ref v i) `(u8vector-ref ,v ,i))

Alternatively, don't use a macro for u8vector-ref and give the  
declarations (declare (extended-bindings) (block)) so that the  
compiler can inline u8vector-ref (my guess is that your code is  
actually doing a procedure call to u8vector-ref, which will be slow).

When in doubt, use the -expansion option to gsc to see what is  
inlined.  If you are in serious doubt, use the -gvm option to view the  
GVM code produced (.gvm file).  If you can't believe what is  
happening, use the -keep-c option to  get the .c file and see if it is  
calling the ___U8VECTORREF C macro.  If the execution of the program  
contradicts the laws of physics, send email to Brad Lucier.


More information about the Gambit-list mailing list