3b/cl-opengl

glaref and (setf glaref) are slow

3b opened this issue · 0 comments

3b commented

GLAREF and (SETF GLAREF) pass types to CFFI at runtime, so are mush slower than they should be.

Need to write some benchmarks to figure out how slow, and try to improve it (and test on multiple Lisps).

Possible fixes:

  • dispatch on common types passing constant types to CFFI in each branch
    Much faster than letting CFFI do lookups at runtime, but a bit verbose and probably ends up inlining a bunch of unused code.
  • compile specialized thunks to store in the array types, and call those to read/write the values
    Less dead code, but not sure how expensive the extra function calls will be (probably still much better than runtime CFFI types though)
  • change the API to allow specifying a static type
    Should produce the fastest/smallest code, but not sure if it would be convenient to use. Breaking the existing API would probably be bad too, so would want one of the other solutions for existing code anyway.