This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: speed and consing (Re: DHARMI project)


Telford Tendys <telford@triangle.triode.net.au> writes:

> Hmmm, using arrays sounds painful and exactly the reason I moved away
> from C. I have a matrix SMOB that is reasonable quick and efficient for
> data that I can index by integer however, in this case my data is a stack
> and surely if you can't use a list to implement a stack then the list
> is a useless structure (and we should all go home).

Erm... yeah.  It might be worth looking at the performance of
something similar in C.  It's probably allocation-dominated too. 

> I didn't know about set-car! and set-cdr!, I gave these a go so that
> the stack keeps it's top value whenever possible and just adjusts the
> contents of the cons cell (rather than popping and pushing).
> That helps quite a bit but using gprof still shows the mark and sweep
> phases of garbage collection to be the two largest consumers of CPU time.

Depending on your problem, you may find hash consing helps.  Hash
consing keeps track (weakly) of what's been allocated, so that if you
cons two things that are eq? twice, the resulting conses are eq?.
This would mean saving some allocation if, say, what you're consing is
just one of four or five different things (say, FSM states...).  hash
consing can be found in (ice-9 hcons) which should work in current
snapshots.  (This week or so)

Andrew
aarchiba@csclub.uwaterloo.ca