How to improve efficiency of LISP program?

From: Wang Yin (wy_at_wangyin.com)
Date: 10/31/03


Date: 31 Oct 2003 21:27:03 +0800


Hi,

I've rewrited one of my C programs which do computation geometry
algorithms into CL. I compiled the program with CMU CL.

At first it runs rather slowly. It takes 170s to get the results that
can be computed in less than 1s by the C program.

Later I inserted some (declare (type ...)) and (proclaim '(optimize
speed (space 0) (safety 0))) and I use fixnum for the integers and
'(vector double-float) for coordinate numbers in the defstruct's. And
I inlined some functions.

And I improved the program to run in 17s. But with a large input it
still takes about 40 times longer than the C version.

This is not resonable. I hope the LISP program can run only 2 times
slower than C programs. Can anyone suggest some method to improve the
efficiency? I've read some of CMU CL's but it doesn't help much.

I wonder if hash tables in CL cost much time? The C program doesn't
use hash table, but the data structures just got messy without it.

-- 
Yin Wang,
EDA Lab,
Deparment of Computer Science and Technology,
Tsinghua University,
100084
Beijing China

Quantcast