raco make: improve parallelism

The `require` macro now logs "prefetch" messages when it sees a `require`
with multiple module paths. The prefix information is approximate, since
parsing a `require` subform might depend on imports from a previous subform,
but in the common case, there are many obvious module paths to prefetch.

The parallel mode of `raco make` watches for prefetch messages and
records the suggested "prefetch" paths so they can be compiled by other
processes.

original commit: 9e3b984463
This commit is contained in:
Matthew Flatt 2014-05-26 18:17:45 +01:00
parent 633ec1faf5
commit 03a0dbd9fd

View File

@ -5,6 +5,7 @@
compiler/compiler
dynext/file
setup/parallel-build
setup/path-to-relative
racket/match)
(module test racket/base)
@ -97,15 +98,19 @@
(if did-one? "output to" "already up-to-date at")
dest)))))))]
;; Parallel make:
[else
[else
(define path-cache (make-hash))
(or (parallel-compile-files
source-files
#:worker-count (worker-count)
#:handler (lambda (type work msg out err)
#:handler (lambda (id type work msg out err)
(define (->rel p)
(path->relative-string/library p #:cache path-cache))
(match type
['done (when (verbose) (printf " Made ~a\n" work))]
['output (printf " Output from: ~a\n~a~a" work out err)]
[else (printf " Error compiling ~a\n~a\n~a~a" work msg out err)]))
['start (when (verbose) (printf " ~a making ~a\n" id (->rel work)))]
['done (when (verbose) (printf " ~a made ~a\n" id (->rel work)))]
['output (printf " ~a output from: ~a\n~a~a" id work out err)]
[else (printf " ~a error compiling ~a\n~a\n~a~a" id work msg out err)]))
#:options (let ([cons-if-true (lambda (bool carv cdrv)
(if bool
(cons carv cdrv)