Hi all!

Some of my libraries take a while to load: just adding a (require mylib) to an 
empty #lang racket/base file bumps the compile time from 0.5s to 1.5s, even if 
no bindings from the library are used. After experimenting a bit, it seems that 
the overhead is mainly due to other modules which are transitively required 
(typed/racket, syntax/parse, …).

Assuming that all the files except the main one are already byte-compiled with 
raco make, what are the factors which affect compile times when a library is 
(possibly transitively) required? Note that we're talking about milliseconds 
here, but when a lot of modules are required, these can add up.

1. Number of bindings directly provided?
2. Number of bindings provided by transitively-required modules (including 
those which are not re-provided, and are not in the main file's namespace)
3. Number of files which are transitively required?
4. Size of the fully expanded code (or size of the bytecode)?
5. Compile-time operations, e.g. within a begin-for-syntax in a 
(transitively-)required module?
6. When a module is required at several meta-levels, does it affect the compile 
time significantly, or is it roughly the same cost than requiring it only once?
7. Something else?

Point 5 seems to matter, as compiling a.rkt still prints "Hello" even if b.rkt 
is already compiled:

a.rkt:
#lang racket/base
(require "b.rkt")

b.rkt:
#lang racket/base
(require (for-syntax racket/base))
(begin-for-syntax (displayln "Hello"))

However, I'm not sure what operations can cause compile-time code to be run in 
this situation. My (possibly incorrect) understanding is that macros are 
executed only once (when expanding the code), but the code to the 
right-hand-side of a (define-syntax foo costly-operation), and the code within 
a (begin-for-syntax …) will both be run each time the module is required.

What I would like is to learn a few "good practices" and gotchas concerning 
compile-time performance.

-- 
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