[plt-scheme] Ants from ICFP

From: Felix Klock's PLT scheme proxy (pltscheme at pnkfx.org)
Date: Thu Jun 10 09:58:59 EDT 2004

Ray-

Well, that speaks very well for MLton then.

I finally wrapped the scheme code that's actually making the call into 
the C code with a (time ...), and its clear that the cpu time for my C 
code (running 100K) is at most 530 ms  (again, this is on a dual 
processor 1 Ghz G4).  So the 2-5 seconds thing is time being taken by 
the Scheme code for running the fitness function and drawing the board 
(which I have taken out at times to improve the GA performance).

Pumping the optimization level for gcc to -O5, I get a cpu time of 
around 480 ms.  But can you really trust gcc at -O5?

Clearly what I really need is a way to interface ML with Scheme, so 
that I can get all the benefits of the fast code generated by tools 
like MLton, along with the type-safety guarantees and just the general 
good feeling you get programming in ML (as opposed to C), but still get 
to do the majority of my hacking in my favorite language.

As for switching to something like Chicken, as suggested by Alex Shinn 
earlier... I figure if I'm going to restrict myself to R5RS to get 
speed guarantees, I might as well do it the "Real Programmer" way and 
go all the way to C (and then assembly).  But then again, maybe 
Chicken's C interface is good enough that I could hack its code into 
interoperating with the MzScheme C interface.  I'll have to look into 
that.

-Felix

On Jun 10, 2004, at 8:18 AM, Raymond Racine wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> On Wed, 2004-06-09 at 23:30, Alex Shinn wrote:
>
>> I was also in the contest, using Gauche+Chicken Scheme.  The simulator
>> was almost pure R5RS + SRFI-9, so it ran under both.  Gauche took
>> hours, whereas after optimizations Chicken now takes 10 seconds on a
>> 700Mhz laptop.
>>
>> For next year you may want to consider pairing up PLT w/ a compiled
>> Scheme, rather than resorting to C.
>
> For what its worth I ended up writing the simulator in SML and a domain
> specific Ant language/compiler in MzScheme with macros to generate ant
> brains.  I was very happy with both languages at the respective tasks.
>
> SML simulator compiled via MLton.
> 100K run => 400 ms on my 2 gig laptop, around 300 ms on a 2 gig PC.
>
> Ray
>
>

----
"Can you think of anything better to do with your
  Saturday night than elliptical functions?? Instead
  of your orgies!"  -G.C. Rota (10/31/97)



Posted on the users mailing list.