[racket] typed racket slow?

From: Ray Racine (ray.racine at gmail.com)
Date: Wed May 8 10:27:09 EDT 2013

On a tangent, if you run your Racket on Linux (like anyone would use
anything else :0 ) you can "install" *.rkt files as executables with
binfmt.

Very Short (no validation) Path

1) Create a shell script runracket.rkt in your racket installation bin.
i.e. /usr/local/racket/bin/runracket
#! /bin/sh

racket -tm $1

2) Use your package manager to install binfmt.

3) Register .rkt files as executables handled by runracket.  As root:

a) cd /proc/sys/fs/binfmt_misc/
b) echo ':RunRacket:E::rkt::/usr/local/racket/bin/runracket:' > register

4) Have a sherbet.

Then assuming you have a simple helloworld.rkt file with a "main" your
Racket file is now just another shell or executable.

ray at rpr:~$ ./helloworld.rkt
Hello there.

Obviously the above should be made more robust, adjusted be installed on
bootup etc, but that is the basic idea.

Decent odds a Mac can do this as well.  Better odds Eli has something done
along these lines polished to perfection. : )

To remove the entry echo -1 to the entry.

$ echo -1 RunRacket











On Wed, May 8, 2013 at 8:21 AM, Sean McBeth <sean.mcbeth at gmail.com> wrote:

> Perhaps the EXEs take longer because they are not using a shared image of
> Racket, thus the OS must load code that is 99% equivalent from two
> different disk locations.
>
>
> On Wed, May 8, 2013 at 7:55 AM, Manfred Lotz <manfred.lotz at arcor.de>wrote:
>
>> On Wed, 8 May 2013 07:31:37 -0400
>> Carl Eastlund <cce at ccs.neu.edu> wrote:
>>
>> > On Wed, May 8, 2013 at 7:04 AM, Manfred Lotz
>> > <manfred.lotz at arcor.de> wrote:
>> >
>> > > On Wed, 8 May 2013 06:19:27 -0400
>> > > Carl Eastlund <cce at ccs.neu.edu> wrote:
>> > >
>> > > > I'm seeing similar results on my end; I timed by first running
>> > > > "raco make" on both files, then timing "racket" on both.  I think
>> > > > what we're seeing is a small startup time cost on Typed Racket.
>> > > > I ran a longer benchmark and Typed Racket edges out untyped
>> > > > Racket if I run a few million iterations (given this is such a
>> > > > short computation).  The expressions I used are:
>> > > >
>> > > > ;; utest.rkt
>> > > > (void
>> > > >   (for/list {[i (in-range (* 10 1000 1000))]}
>> > > >     (distance
>> > > >       (pt (+ i 1.2) (+ i 2.1))
>> > > >       (pt (+ i 4.3) (+ i 5.6)))))
>> > > >
>> > > > and
>> > > >
>> > > > ;; test.rkt
>> > > > (void
>> > > >   (for/list: : (Listof Float) {[i (in-range (* 10 1000 1000))]}
>> > > >     (distance
>> > > >       (pt (+ i 1.2) (+ i 2.1))
>> > > >       (pt (+ i 4.3) (+ i 5.6)))))
>> > > >
>> > > >
>> > > > I see just under 5 seconds for test.rkt and just over 5 seconds
>> > > > for utest.rkt.  So there's a fraction of a second extra startup
>> > > > time for Typed Racket, but it takes less time for each subsequent
>> > > > computation, so the difference depends on how much "real" work
>> > > > you do after startup.  I don't know what causes that startup
>> > > > cost, but hopefully this kind of benchmark will be useful to the
>> > > > Typed Racket maintainers in closing the gap for future versions.
>> > > > So, thanks for the example, Manfred!
>> > > >
>> > >
>> > > Hi Carl,
>> > > This is interesting. If I run it I have around 5 seconds for the
>> > > typed version and around 4 seconds for the untyped version. My
>> > > system is a 64bit Linux.
>> > >
>> > > --
>> > > Manfred
>> > >
>> >
>> > What I ran was:
>> >
>> >   raco make test.rkt utest.rkt && time racket test.rkt && time racket
>> > utest.rkt
>> >
>> > Just to make sure we're comparing apples to apples, does that give
>> > you the same results you saw before?
>> >
>> >
>>
>> Yep, I did something different:
>>
>> Now going your way I get 3.7 sec for typed and 4.1 sec for untyped. It
>> is interesting to note that if I do raco exe for both the executables
>> run longer: 4 sec for typed and 4.7 sec for untyped.
>>
>>
>>
>> > > > On Wed, May 8, 2013 at 5:32 AM, Manfred Lotz
>> > >  > <manfred.lotz at arcor.de> wrote:
>> > > >
>> > > > > Hi there,
>> > > > > I did a small test using typed racket.
>> > > > >
>> > > > > This is an example from the documentation:
>> > > > >
>> > > > > #lang typed/racket
>> > > > > ;; test.rkt
>> > > > >
>> > > > > (struct: pt ([x : Float] [y : Float]))
>> > > > >
>> > > > > (: distance (pt pt -> Float))
>> > > > > (define (distance p1 p2)
>> > > > >   (sqrt (+ (sqr (- (pt-x p2) (pt-x p1)))
>> > > > >            (sqr (- (pt-y p2) (pt-y p1))))))
>> > > > >
>> > > > > (distance (pt 1.2 2.1) (pt 4.3 5.6))
>> > > > >
>> > > > > This is the untyped version:
>> > > > > #lang racket
>> > > > > ;; utest.rkt
>> > > > >
>> > > > > (struct pt (x y))
>> > > > >
>> > > > > (define (distance p1 p2)
>> > > > >   (sqrt (+ (sqr (- (pt-x p2) (pt-x p1)))
>> > > > >            (sqr (- (pt-y p2) (pt-y p1))))))
>> > > > >
>> > > > > (distance (pt 1.2 2.1) (pt 4.3 5.6))
>> > > > >
>> > > > >
>> > > > > Now running both:
>> > > > > time racket test.rkt
>> > > > > 4.675467891024383
>> > > > > racket test.rkt  1.24s user 0.08s system 99% cpu 1.333 total
>> > > > >
>> > > > >
>> > > > > time racket utest.rkt
>> > > > > 4.675467891024383
>> > > > > racket utest.rkt  0.22s user 0.03s system 99% cpu 0.248 total
>> > > > >
>> > > > >
>> > > > > It seems the typed version needs a lot of time for the type
>> > > > > checking. The time for time checking could be cut mostly by:
>> > > > >
>> > > > > raco exe test.rkt
>> > > > > time ./test
>> > > > > 4.675467891024383
>> > > > > ./test  0.49s user 0.03s system 99% cpu 0.531 total
>> > > > >
>> > > > > But still runtime is more than twice as long. I could get the
>> > > > > impression that typed racket is generally slower.
>> > > > >
>> > > > >
>> > > > > Question: Is there any conclusion to be drawn from this (like
>> > > > > that typed racket is slower than 'normal' racket)? Or is my
>> > > > > test just a bad test?
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Manfred
>> > >
>> >
>>
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130508/5cd3573a/attachment-0001.html>

Posted on the users mailing list.