[racket] The performance of fannkuch-redux

From: Haiwei Zhou (highfly22 at gmail.com)
Date: Fri Feb 22 23:00:55 EST 2013

On 22 February 2013 21:18, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:

> On Fri, Feb 22, 2013 at 4:51 AM, Haiwei Zhou <highfly22 at gmail.com> wrote:
> > Hi,
> >
> >   I wrote a simple script for fannkuch redux.
> >
> https://github.com/highfly22/fannkuch-redux/blob/master/fannkuch-redux.rkt
> >
> >   The result of this script is about 10 minutes in my i7 machine, which
> is
> > better than Python, lua and ruby. Is the result expected? Do I miss
> > something?
>
> That seems reasonable, and if you're getting the right answers, I
> wouldn't worry.
>
> >   I have tried to use unsafe op. That may reduces about 30 seconds.
>
> Which unsafe operations?  Vectors, fixnums, both?
>
Only for vectors. This algorithm uses vector operations heavily.

>
> >   The optimizer couch complains the missed inline on the most time spent
> > functions - flip and flip-count. I tried to re-write the functions to
> > macros. But it doesn't change anything.
> >
> >   I also tried to re-write in the typed/racket. It doesn't help either.
>
> I'd be interested in seeing the typed version -- maybe we can give it
> more restricted types that help the optimizer more.
>
 The typed version doesn't work well as I expected. I guess unsafe
operations does the same thing.

>
> >   Finally, I try to use future. There is not a blocking operation in the
> > future-visualizer. But it's twice slow than normal version. Maybe task
> (each
> > flip-count) is too trivial for this job.
>
> I'm sure that James would love to see the version with futures, but I
> find that futures work best if you don't create too many of them. How
> many times does `flip-count` get run?
>
For n = 7, flip-count got run 5039 times (7! - 1).

>  Sam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130223/305d3f1a/attachment.html>

Posted on the users mailing list.