skip unnecessary steps for non-interactive sessions

dev-nonsettable
Matthew Butterick 5 years ago
parent 7163f9bc77
commit 149f2cc389

@ -61,20 +61,29 @@
(define-namespace-anchor cache-utils-module-ns)
(define my-caching-compile-proc (make-caching-managed-compile-zo))
;; check 'gc not 'vm because 'gc is supported before 6.7
(define running-on-cs? (eq? (system-type 'gc) 'cs))
;; faster than the usual `managed-compile-zo`
(define caching-zo-compiler (make-caching-managed-compile-zo))
(define (path->hash path)
(for ([p (in-list (or (get-directory-require-files path) null))])
(my-caching-compile-proc p))
(when running-on-cs?
;; this makes builds faster,
;; but a bytecode-caching bug in Racket BC
;; restricts it to CS for now
(my-caching-compile-proc path))
(apply hasheq
(let ([doc-key (setup:main-export)] [meta-key (setup:meta-export)])
(define compilation-namespace
(cond
[(current-session-interactive?)
;; in interactive mode, we need a fresh namespace every time
;; and can't use bytecode, because it's possible that path
;; or any dependency (say, "pollen.rkt") has changed
(define bns (make-base-namespace))
(define outer-ns (namespace-anchor->namespace cache-utils-module-ns))
;; bring in currently instantiated params (unlike namespace-require)
(namespace-attach-module outer-ns 'pollen/setup bns)
bns]
[else
;; make bytecode, because we know that in a non-interactive sesssion
;; the sources won't change in the midst
(for-each caching-zo-compiler (cons path (or (get-directory-require-files path) null)))
; recycle namespace
(current-namespace)]))
(define doc-key (setup:main-export))
(define meta-key (setup:meta-export))
(unless (and (symbol? doc-key) (symbol? meta-key))
(raise-argument-error 'path->hash "symbols for doc and meta key" (cons doc-key meta-key)))
;; I monkeyed around with using the metas submodule to pull out the metas (for speed)
@ -84,15 +93,12 @@
;; the benefit of not reloading doc when you just need metas.
;; new namespace forces `dynamic-require` to re-instantiate `path`
;; otherwise it gets cached in current namespace.
(parameterize ([current-namespace (make-base-namespace)]
[current-directory (dirname path)])
;; brings in currently instantiated params (unlike namespace-require)
(define outer-ns (namespace-anchor->namespace cache-utils-module-ns))
(namespace-attach-module outer-ns 'pollen/setup)
(define doc-missing-thunk (λ () ""))
(define metas-missing-thunk (λ () (hasheq)))
(list doc-key (dynamic-require path doc-key doc-missing-thunk)
meta-key (dynamic-require path meta-key metas-missing-thunk))))))
(parameterize ([current-namespace compilation-namespace]
[current-directory (dirname path)])
(hasheq doc-key (dynamic-require path doc-key doc-missing-thunk)
meta-key (dynamic-require path meta-key metas-missing-thunk))))
(define (my-make-directory* dir)
(define base (dirname dir))

@ -192,7 +192,8 @@ version print the version" (current-server-port) (make-publish-di
(error (format "~a is not a valid port number" http-port)))
(parameterize ([current-project-root dir]
[current-server-port (or http-port (setup:project-server-port))]
[current-server-listen-ip (and localhost-wanted "127.0.0.1")])
[current-server-listen-ip (and localhost-wanted "127.0.0.1")]
[current-session-interactive? #true])
(message "starting project server ...")
((dynamic-require 'pollen/private/project-server 'start-server) (format "/~a" (setup:main-pagetree dir)) launch-wanted)))

@ -1 +1 @@
1588786944
1588815041

@ -106,6 +106,11 @@
(define+provide current-render-source (make-parameter #f))
;; used to distinguish one-shot rendering (e.g., using `raco pollen setup` or `render`
;; from an interactive session with the project server (using `raco pollen start`)
;; in one-shot mode, certain features needed for dynamic recompilation are disabled for speed.
(define+provide current-session-interactive? (make-parameter #false))
(define-settable dashboard-css "poldash.css")
(define-runtime-path server-extras-dir "private/server-extras")

@ -16,7 +16,8 @@
;; test makes sure that file render changes after pollen.rkt changes
(parameterize ([current-output-port (open-output-string)]
[current-directory rerequire-dir]
[current-project-root rerequire-dir])
[current-project-root rerequire-dir]
[current-session-interactive? #true])
(display-to-file @string-append{#lang racket/base
(provide id)

Loading…
Cancel
Save