1.5 API for Parallel Builds

► |  | raco: Racket Command-Line Tools

1 | raco make: Compiling Source to Bytecode
2 | raco exe: Creating Stand-Alone Executables
3 | raco distribute: Sharing Stand-Alone Executables
4 | raco planet: Automatic Package Distribution
5 | raco pkg: Package Management
6 | raco setup: Installation Management
7 | raco decompile: Decompiling Bytecode
8 | raco demod: Demodularizing Programs
9 | raco link: Library Collection Links
10 | raco pack: Packing Library Collections
11 | raco unpack: Unpacking Library Collections
12 | raco ctool: Working with C Code
13 | raco test: Run tests
14 | raco docs: Documentation Search
15 | raco expand: Macro Expansion
16 | raco read: Reading and Pretty-Printing
17 | raco scribble: Building Documentation
18 | Adding a raco Command
19 | Installation Configuration and Search Paths

▼ | 1 | raco make: Compiling Source to Bytecode

1.1 | Running raco make
1.2 | Bytecode Files
1.3 | Dependency Files
1.4 | API for Making Bytecode
1.5 | API for Parallel Builds
1.6 | Compilation Manager Hook for Syntax Transformers
1.7 | API for Simple Bytecode Creation
1.8 | API for Bytecode Paths
1.9 | Compiling to Raw Bytecode
1.10 | API for Raw Compilation
1.11 | API for Reading Compilation Dependencies

On this page:

parallel-compile-files
parallel-compile

top ← prev up next →

#### 1.5`` API for Parallel Builds

(require setup/parallel-build) | package: base

The setup/parallel-build library provides the parallel-compilation functionality of raco setup and raco make.

Both parallel-compile-files and parallel-compile log messages to the topic 'setup/parallel-build at the level 'info. These messages are instances of a parallel-compile-event prefab structure:

> (struct parallel-compile-event (worker event) #:prefab)

The worker field is the index of the worker that the created the event. The event field is a compile-event as documented in make-compilation-manager-load/use-compiled-handler.

> > procedure
> > (parallel-compile-files |  | list-of-files |
> > | [ | #:worker-count worker-count |
> > |  | #:use-places? use-places? |
> > |  | #:handler handler]) |
> → (or/c void? #f)
> list-of-files : (listof path-string?)
> worker-count : exact-positive-integer? = (processor-count)
> use-places? : any/c = #t
> | handler |  | : |  |
> (->i ([worker-id exact-integer?]
> [handler-type symbol?]
> [path path-string?]
> [msg string?]
> [out string?]
> [err string?])
> void?)
> |  | = |  | void

The parallel-compile-files utility function is used by raco make to compile a list of paths in parallel. The optional #:worker-count argument specifies the number of compile workers to spawn during parallel compilation. The compile workers are implemented as Racket places if use-places? is true, otherwise the compile workers are implemented as separate Racket processes. The callback, handler, is called with the symbol 'done as the handler-type argument for each successfully compiled file, 'output when a successful compilation produces stdout/stderr output, 'error when a compilation error has occurred, or 'fatal-error when a unrecoverable error occurs. The other arguments give more information for each status update. The return value is (void) if it was successful, or #f if there was an error.

> (parallel-compile-files
> source-files
> #:worker-count 4
> #:handler (lambda (type work msg out err)
> (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)])))

Changed in version 7.0.0.19 of package base: Added the #:use-places? argument.

> > procedure
> > (parallel-compile |  | worker-count |  |  |  |
> > |  | setup-fprintf |  |  |  |
> > |  | append-error |  |  |  |
> > |  | collects-tree |  |  |  |
> > | [ | #:use-places? use-places?]) |  | → |  | (void)
> worker-count : non-negative-integer?
> | setup-fprintf |  | : |  |
> (->i ([stage string?] [format string?])
> ()
> #:rest (listof any/c) void)
> | append-error |  | : |  |
> (->i ([cc cc?]
> [prefix string?]
> [exn (or/c exn? (cons/c string? string?) #f)]
> [out string?]
> [err string?]
> [message string?])
> void?)
> collects-tree : (listof any/c)
> use-places? : any/c = #t

The parallel-compile function is used by raco setup to compile collections in parallel. The worker-count argument specifies the number of compilation workers to spawn during parallel compilation. The use-places? argument specified whether to use places, otherwise separate processes are used. The setup-fprintf and append-error functions communicate intermediate compilation results and errors. The collects-tree argument is a compound data structure containing an in-memory tree representation of the collects directory.

When the exn argument to append-error is a pair of strings, the first string is a long form of the error message, and the second string is a short form (omitting evaluation context information, for example).

Changed in version 6.1.1.8 of package base: Changed append-error to allow a pair of error strings.
Changed in version 7.0.0.19: Added the #:use-places? argument.

top ← prev up next →