Pergunta

I've just finished and tested the core of a common lisp application and want to optimize it for speed now. It works with SBCL and makes use of CLOS.

Could someone outline the way to optimize my code for speed?

Where will I have to start? Will I just have to provide some global declaration or will I have to blow up my code with type information for each binding? Is there a way to find out which parts of my code could be compiled better with further type information?

The programm makes heavy use of a single 1-dimensional array 0..119 where it shifts CLOS-Instances around.

Thank you you Advance!

Foi útil?

Solução

It's not great to optimize in a vacuum, because there's no limit to the ugliness you can introduce to make things some fraction of a percent faster.

If it's not fast enough, it's helpful to define what success means so you know when to stop.

With that in mind, a good first pass is to run your project under the profiler (sb-sprof) to get an idea of where the time is spent. If it's in generic arithmetic, it can help to judiciously use modular arithmetic in inner loops. If it's in CLOS stuff, it might possibly help to switch to structures for key bits of data. Whatever's the most wasteful will direct where to spend your effort in optimization.

I think it could be helpful if, after profiling, you post a followup question along the lines of "A lot of my program's time is spent in <foo>, how do I make it faster?"

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top