I have a performance problem with loading a Racket program dynamically.

I measure the time taken to execute a program in two different ways:

1. raco make <myprogram>; time racket <myprogram>

2. raco make my-runner.rkt; raco make <myprogram>; time racket my-runner.rkt 

In the first case, execution takes ~1 second, in the second case ~4 seconds.
(The time to run 'raco make' is not measured.)
I checked Racket 6.10 and Racket 6.11 on Linux.

Some additional observations (very basic, since I know little about Racket
module loading mechanism):

- Delay does not go anywhere if I run <myprogram> second time within the same
  my-runner.rkt instance.

- It I omit 'raco make' and remove all the 'compiled' folders from my source
  code tree, running the program takes ~18 seconds in both cases, so there is
  no performance difference in that case.

<myprogram> is written in a non-Racket #lang with its own reader.
To load it dynamically in my-runner.rkt, I use the following function
kindly provided by Matthew Flatt a few years ago on this mailing list:

(define (require-input-port p [name (gensym)])
  (define module-name (make-resolved-module-path name))
  (parameterize ([current-module-declare-name module-name])
    (eval-syntax (check-module-form ; ensures that `module` is bound
                   (lambda ()
                     (read-syntax (object-name p) p)))
  (dynamic-require module-name #f))

Other than performance, it works great.
Is there a way to make it as fast as the "static" command-line runner?
Many thanks in advance.



You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to