[racket] gc and vectors

From: Jos Koot (jos.koot at telefonica.net)
Date: Tue Jan 4 13:09:20 EST 2011

Thanks for your response, very quick as always.
I'll try flvectors first.
It will be like writing fortran with racket syntax.
I don't yet understand how a byte array can help me.
I'll have to study the docs on this.
Thanks, Jos

> -----Original Message-----
> From: Matthew Flatt [mailto:mflatt at cs.utah.edu] 
> Sent: 04 January 2011 18:52
> To: Jos Koot
> Cc: users at racket-lang.org
> Subject: Re: [racket] gc and vectors
> 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.