[racket] gc and vectors

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jan 4 12:51:39 EST 2011

You could use flvectors instead of vectors. If you feed numbers
extracted from `flvector-ref' directly into `fl' arithmetic, and if you
push numbers directly from `fl' arithmetic back into `flvector-set!',
that might save allocation and speed things up.

Otherwise, if you're spending so much time on GC, you might tuning the
GC by allocating and retaining a big byte array on the side (which
convinces the GC that it doesn't need to collect so frequently, since
you're willing to spend all that memory on a byte array anyway).

At Tue, 4 Jan 2011 18:36:35 +0100, "Jos Koot" wrote:
> I have a simple program using vectors of inexact numbers.
> Half the time goes to garbage collection.
> I suppose that's because vectors effectively are internally arrays of
> pointers to the numbers.
> So reassigning an element to a vector may leave garbage.
> Do unsafe floating point vectors and operations use arrays without
> intermediate pointers?
> If that is the case I could speed up my program by a factor of 2.
> But before trying that I would appreciate advice.




Posted on the users mailing list.