speed improvements in render (cache project requires)

pull/9/head
Matthew Butterick 11 years ago
parent 0804ffe53c
commit eee3abb0a9

@ -15,10 +15,7 @@
(define (make-mod-dates-key paths) (define (make-mod-dates-key paths)
;; project require files are appended to the mod-date path key. (flatten paths))
;; Why? So a change in a require file will trigger a render
(define project-require-files (or (get-project-require-files) empty))
(flatten (append paths project-require-files)))
(define (path->mod-date-value path) (define (path->mod-date-value path)
@ -32,8 +29,7 @@
(define (store-render-in-mod-dates . rest-paths) (define (store-render-in-mod-dates . rest-paths)
(define key (make-mod-dates-key rest-paths)) (define key (make-mod-dates-key rest-paths))
(report key) (hash-set! mod-dates key (map path->mod-date-value key)))
(hash-set! mod-dates key (report (map path->mod-date-value key))))
(module+ test (module+ test
(reset-mod-dates) (reset-mod-dates)
@ -137,7 +133,7 @@
(or (or
force-render force-render
(not (file-exists? output-path)) (not (file-exists? output-path))
(report (mod-date-expired? source-path)) (mod-date-expired? source-path)
(let ([source-reloaded? (handle-source-rerequire source-path)]) (let ([source-reloaded? (handle-source-rerequire source-path)])
source-reloaded?))) source-reloaded?)))
@ -232,6 +228,10 @@
;; not pollen/top, because we don't want it in the current ns ;; not pollen/top, because we don't want it in the current ns
pollen/world pollen/world
pollen/project-requires) pollen/project-requires)
;; cache project requires in this ns.
;; This means changes to project requires require server restart.
;; But this seems mandatory anyhow because no dynamic-rerequire for whole module.
(require-project-require-files)
(define original-ns (current-namespace)) (define original-ns (current-namespace))
(define (render-through-eval base-dir eval-string) (define (render-through-eval base-dir eval-string)
@ -241,7 +241,7 @@
[current-ptree (make-project-ptree (world:current-project-root))] [current-ptree (make-project-ptree (world:current-project-root))]
[current-url-context (world:current-project-root)]) [current-url-context (world:current-project-root)])
(for-each (λ(mod-name) (namespace-attach-module original-ns mod-name)) (for-each (λ(mod-name) (namespace-attach-module original-ns mod-name))
'(web-server/templates `(web-server/templates
xml xml
racket/port racket/port
racket/file racket/file
@ -260,7 +260,8 @@
pollen/template pollen/template
pollen/tools pollen/tools
pollen/world pollen/world
pollen/project-requires)) pollen/project-requires
,@(get-project-require-files)))
(eval eval-string (current-namespace)))) (eval eval-string (current-namespace))))

Loading…
Cancel
Save