From dc64d0407499259dbc972f19a17d5656004cdaff Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 6 Apr 2020 13:51:23 -0700 Subject: [PATCH 1/3] cache with fasl --- pollen/private/cache-utils.rkt | 11 +++++++---- pollen/private/ts.rktd | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pollen/private/cache-utils.rkt b/pollen/private/cache-utils.rkt index 4537742..6801160 100644 --- a/pollen/private/cache-utils.rkt +++ b/pollen/private/cache-utils.rkt @@ -1,4 +1,4 @@ -#lang racket/base +#lang debug racket/base (require "file-utils.rkt" "../setup.rkt" "project.rkt" @@ -8,9 +8,9 @@ racket/path racket/list racket/match - racket/serialize sugar/coerce sugar/test + racket/fasl compiler/cm) (provide (all-defined-out)) @@ -109,7 +109,10 @@ (define dest-file (build-path cache-dir (format "~a.rktd" dest-path-filename))) (define (generate-dest-file) (message-debug (format "cache miss for ~a" dest-file)) - (write-to-file (serialize (path-hash-thunk)) dest-file #:exists 'replace)) + (define op (open-output-file dest-file)) + (with-output-to-file op + (λ () #R 'whee (s-exp->fasl #R (path-hash-thunk) (current-output-port))) + #:exists 'replace)) ;; `cache-file` looks for a file in private-cache-dir previously cached with key ;; (which in this case carries modification dates and POLLEN env). @@ -132,4 +135,4 @@ [(or "cache attempt failed: could not acquire exclusive lock" "cache attempt failed: could not acquire shared lock") (void)] [_ (log-pollen-error str)]))) - (deserialize (file->value dest-file))) + (fasl->s-exp (open-input-file dest-file))) diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index 287c017..ebde6f6 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1586184205 +1586206283 -- 2.25.1 From e7333f4fc632c6cfad002939748397999034b684 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 6 Apr 2020 14:06:29 -0700 Subject: [PATCH 2/3] correction --- pollen/private/cache-utils.rkt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pollen/private/cache-utils.rkt b/pollen/private/cache-utils.rkt index 6801160..8ce5b2c 100644 --- a/pollen/private/cache-utils.rkt +++ b/pollen/private/cache-utils.rkt @@ -1,4 +1,4 @@ -#lang debug racket/base +#lang racket/base (require "file-utils.rkt" "../setup.rkt" "project.rkt" @@ -109,9 +109,8 @@ (define dest-file (build-path cache-dir (format "~a.rktd" dest-path-filename))) (define (generate-dest-file) (message-debug (format "cache miss for ~a" dest-file)) - (define op (open-output-file dest-file)) - (with-output-to-file op - (λ () #R 'whee (s-exp->fasl #R (path-hash-thunk) (current-output-port))) + (with-output-to-file dest-file + (λ () (s-exp->fasl (path-hash-thunk) (current-output-port))) #:exists 'replace)) ;; `cache-file` looks for a file in private-cache-dir previously cached with key -- 2.25.1 From 091b3c693abfa0bbd996157572d8bc060e6c09f9 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 6 Apr 2020 14:28:39 -0700 Subject: [PATCH 3/3] wiff --- pollen/private/cache-utils.rkt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pollen/private/cache-utils.rkt b/pollen/private/cache-utils.rkt index 8ce5b2c..f95eab6 100644 --- a/pollen/private/cache-utils.rkt +++ b/pollen/private/cache-utils.rkt @@ -134,4 +134,5 @@ [(or "cache attempt failed: could not acquire exclusive lock" "cache attempt failed: could not acquire shared lock") (void)] [_ (log-pollen-error str)]))) - (fasl->s-exp (open-input-file dest-file))) + (with-input-from-file dest-file + (λ () (fasl->s-exp (current-input-port))))) -- 2.25.1