Refactor disable_invalidation to force_compiletime_default#92
Conversation
This makes the argument always return the default value to avoid invalidating the compilation cache.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #92 +/- ##
==========================================
+ Coverage 93.82% 93.88% +0.06%
==========================================
Files 2 2
Lines 178 180 +2
==========================================
+ Hits 167 169 +2
Misses 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Can you explain a bit about how this works for your use case @JamesWrigley ? My understanding of JuliaLang/IJulia.jl#1215 is that Preferences allow users to specify the IJulia path when the default is non-functional. Doesn't this change mean that those users will fail to pre-compile IJulia, since the preference will not report the user-provided path when you run |
|
Nope, we can't run the command at all during precompilation because it's not guaranteed that Jupyter is installed anyway (it's also a bit awkward to launch a non-terminating command during precompilation). I'll probably add a special case that exits The actual path doesn't matter for the purposes of precompilation, it could also be the path to |
|
That makes some sense, but why is IJulia querying the path if it's not going to use it? |
|
It's purely for the sake of precompilation to reduce TTFX; because IJulia is used so widely I try to reduce TTFX as much possible. Most of my work on that so far has been to reduce TTFX for the kernel itself, but I can't think of many more ways to reduce the kernel TTFX so I'm tackling the |
|
What are you trying to precompile, the I'm having trouble seeing the value in calling |
|
Ah no, it's the downstream code. I'm not sure what you mean by using the default value, do you mean adding an argument like |
|
Yeah, that would be one way to do it. The basic argument is: Since you're already adding special cases to exit before |
|
One special case is better than two 😛 But more generally I think having code being amenable to precompilation without refactoring is really useful. In the case of |
|
Sorry, but I don't agree. Users are welcome to provide this functionality manually using something like: path = default
if !Base.generating_output()
path = load_preference(...)
endbut I don't think it makes sense to provide this logic in the standard API. Preferences should assume that, by default, the values it returns do matter, including at pre-compile time.
Not by very much IMHO - Users are already having to customize their code to handle the fact that Preferences doesn't return the "right" thing here - I don't think the API should paper over that. It should make it obvious, and expect the user to implement their special case pre-compile logic, even if that means editing multiple places. |
Agreed, and this PR doesn't change that. It only adds an optional (and I think fairly obvious) way to opt-out, which is something users will have to do one way or another. That's why I think it makes sense to have in the package. I understand your reasoning though, and I don't think I have much more to add. If you and the other maintainers agree then I can make a PR to revert #90. |
|
I think the kwarg is fine and a reasonable way to express semantic intent |
I agree that this should be the default, but providing a way to disable this here makes sense to me. As a code organization decision, I think having a way to prevent a preference from invalidating you belongs with the preferences code rather than in the caller's code. In this specific instance the difference in lines of code is negligible, but I think it is ever so slightly cleaner to have things like |
This makes the argument always return the default value to avoid invalidating the compilation cache.
See #90.