cache-watchlist generates wrong keys, effectively turning caching off
#192
Closed
opened 6 years ago by sorawee
·
11 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
In my project I have:
and the following setup:
When I render page
subA/a.html.pm
which callsget-doc
ofcommon/common.html.pm
, the key that is used for caching (as incache-file
incache-utils.rkt
) contains(subA/rkt/tags.rkt . 0)
.This is bad because:
tags.rkt
is inrkt
, notsubA/rkt
. The modified time is 0 becausesubA/rkt/tags.rkt
doesn't exist.subB/b.html.pm
which similarly callsget-doc
ofcommon/common.html.pm
. Even thoughcommon.html
is already cached, the cache is not getting hit because the keys are different. E.g.,(subA/rkt/tags.rkt . 0)
vs(subB/rkt/tags.rkt . 0)
.Empirically, in my project after I take
cache-watchlist
out,raco pollen reset; raco pollen render
speeds up by at least 20 seconds.I know I recommended the
resolve-module-path
technique in the Pollen docs. On reflection there seems to be a wrinkle: I see now that it resolves path strings like"rkt/tags.rkt"
relative to the current directory (which moves around during a pollen render). So maybe it’s not a reliable technique. Does this version of thesetup
module fix your problem?That works, thanks! However, I also discover another bug.
Consider the above situation except that I rename
subB/b.html.pm
tosubB/b.xml.pm
. When renderingsubB/b.xml.pm
, the cache key forcommon/common.html
seems to be:But when rendering
subA/a.html.pm
, the cache key forcommon/common.html
is:preventing the cache to get hit.
Is there any reason that the extension is a part of the cache key?
Right — for
poly
files the cache key includes thecurrent-poly-target
because it might affect how thedoc
ormetas
is rendered.Oh I see, it’s not a
poly
source. Well let me check.I’m not seeing the file extension in my cache key for
common.html
(assuming I’ve simulated your situation accurately)BTW
#lang multi-file
is a nice way of making test cases that need to generate multiple files & directories.It's actually a
poly
file. I simplified it to.html.pm
when I wrote the comment. So you are totally right. I guess it makes sense...Thanks for pointing out to
#lang multi-file
. This looks really useful.Would you mind updating the documentation regarding
resolve-module-path
? After that I would considered this issue resolved.A warning regarding the interaction between
poly
and caching in the documentation would also be nice.I ended up writing this macro:
so that I don't need to
define-runtime-path
over and over and need to come up with id names. Do you think that the library should provide a macro like this? It's also more safe (if you mistypedefine-cache-watchlist
, it would result in an unbound id error, rather than a silent "configuration doesn't work"... speaking of it, can't we convert all setups to use parameters to make them safer?)No, because the
define-runtime-path
technique is one possibility of many. Thecache-watchlist
doesn’t care how the complete path is generated. For instance,resolve-module-path
may still be the better choice, if you want to depend on an installed module.(PS this macro won’t work as written.)
How so? It seems to work for me.
Somewhere (either in the macro definition environment or the macro itself) there needs to be a
(require racket/runtime-path)
.Right, I did
require racket/runtime-path
outside of the macro.Thanks again for all your help!