Separate compilation/caching for Scribble?

21 views
Skip to first unread message

William J. Bowman

unread,
Mar 25, 2020, 2:56:37 PM3/25/20
to Racket Users
Does Scribble support separate compilation or some kind of caching and I'm just
missing it?

I'm building a multi-page website using Scribble, with many @examples that take
a while to run.
If I touch *any page*, all the other pages have to rebuild, re-running the long
running examples.

I've hacked up a caching system for examples using make-log-based-eval and
with-cache, but it's completely unreliable, occasionally giving 'could not
replay log' when nothing has changed in that file.

Am I missing something?

--
William J. Bowman

Ryan Culpepper

unread,
Mar 25, 2020, 3:51:33 PM3/25/20
to William J. Bowman, Racket Users
You can use `raco make` (or `raco setup` for docs of installed packages) to compile the Scribble files, but that won't compile the examples. Those are dynamically evaluated when the Scribble documents are run.

For `make-log-based-eval`, are you using a separate evaluator (and separate log file) for each Scribble file?

Ryan

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/20200325185631.GK26958%40williamjbowman.com.

William J. Bowman

unread,
Mar 25, 2020, 3:57:30 PM3/25/20
to ry...@racket-lang.org, Racket Users
On Wed, Mar 25, 2020 at 08:51:18PM +0100, Ryan Culpepper wrote:
> You can use `raco make` (or `raco setup` for docs of installed packages) to
> compile the Scribble files, but that won't compile the examples. Those are
> dynamically evaluated when the Scribble documents are run.
Yeah, I was thinking of "compilation" as in caching the output document from
each module.

> For `make-log-based-eval`, are you using a separate evaluator (and separate
> log file) for each Scribble file?
Yes. However, I'm using `with-cache` and a wrapper to detect whether a cache
file exists (separate cache file each evaluator), and use 'replay mode if the
cache file exists, so I don't have to manually switch to 'replay mode, or
manually re-record if I alter an example (instead, just clear the cache).

Ryan Culpepper

unread,
Mar 25, 2020, 4:59:30 PM3/25/20
to William J. Bowman, Ryan Culpepper, Racket Users
I'm not clear on what `with-cache` is doing in this setup, but it seems like a potential source of errors. If the goal is to automatically use `'replay` if the log file exists and `'record` otherwise, why not do the following?

    (make-log-based-eval the-log-file (if (file-exists? the-log-file) 'replay 'record))

Ryan

William J. Bowman

unread,
Mar 25, 2020, 6:03:00 PM3/25/20
to ry...@racket-lang.org, Racket Users
We're getting a little far from my real question, since caching the examples is
IMHO a hack to cache the most expensive part of the computation, while the whole
'doc ought to be cachable, but....

I forgot what my own code was doing.
That's basically what I'm doing:
(define (make-cached-eval name . rest)
(define ev
(make-log-based-eval
(cachefile name)
(if (file-exists? (cachefile name))
'replay
'record)))
(for ([r rest])
(ev r))
ev)

I'm using with-cache's `cachefile` just to generate and manage the file path, so
it ends up in have a good place.
I was trying to do something more complex earlier, but it didn't work.
Reply all
Reply to author
Forward
0 new messages