Open IndrajeetPatil opened 2 months ago
> system.time(lintr::lint_dir("~/Documents/GitHub/lintr/R", cache = TRUE))
|====================================================================================================================| 100%
user system elapsed
49.759 1.422 52.014
> system.time(lintr::lint_dir("~/Documents/GitHub/lintr/R"))
|====================================================================================================================| 100%
user system elapsed
58.436 1.401 61.078
Does it work when specifying cache = TRUE
both times?
This is WAI IMO, cache=FALSE
should never try and read an existing cache (which may have been invalidated):
https://github.com/r-lib/lintr/blob/f2da882ce6d8889842b8b46294b367ff734f6513/R/cache.R#L28
Possibly, we could consider allowing cache=NULL
to mean "use cache if found at default path", and further consider making that the default, but the current behavior for FALSE
is correct.
Okay, I clearly have an incorrect mental model of {lintr}
’s caching algorithm.
As a user, here is how I thought it worked:
cache = FALSE
and realize it takes a whilecache = TRUE
and assume that unless the source code files, {lintr}
package version, base-R version, etc. change, or I run cache_clear()
, {lintr}
is going to use this cachecache
argument and expect it to run faster because it’s using previously generated cache Admittedly, this UX expectation comes from how caching works in {styler}
, and I find it to be much more intuitive than what’s going on in {lintr}
.
But I am happy to be challenged on that point :)
I'm happy with revisiting the cache UX.
Noting: if cache = 'my_dir'
, I don't know that we have any way to recover that in the nest invocation. You'll have to keep calling with cache='my_dir'
.
Anyone, +1 to revisiting. We don't have a cache_clear()
function now, is important context for my reasoning. So if we add one, that changes things.
I was expecting that the second call here would be faster because it would use cache, but that's not what I see (at least locally).
Either I am doing something wrong, or the caching is not working as expected.