-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Scratch Spaces #1833
Implement Scratch Spaces #1833
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on the docs
Thanks for the review guys, I think I have addressed all comments so far. |
These functions provide a nice interface for determining the currently-running package's UUID and VersionNumber, identified by loaded `Module`. We explicitly do not include a lookup by name, in expectation of potential future naming clashes due to having multiple packages with the same name but different UUIDs.
9b9a0f4
to
f8856ab
Compare
7a2f6fc
to
155f76d
Compare
This is good to go on my end. :) |
Can this be used as a stable place for external "virtual environment" for each Julia project? I'm thinking to optionally create a conda environment or Python venv for each project_slug = Base.slug(Base._crc32c(Base.active_project()), 5)
scratch_name = "$other_things-$project_slug"
scratch_path = @get_scratch!(scratch_name) work? |
docs/src/scratchspaces.md
Outdated
|
||
* Caching downloads of files that must be routinely accessed and modified by a package. Files that must be modified are a bad fit for the immutable [Artifacts](@ref) abstraction, and files can always be re-downloaded if the cache is wiped by the user. | ||
|
||
* Generated data that depends on the characteristics of the host system. Examples are compiled binaries, fontcache system font folder inspection output, generated CUDA bitcode files, etc... Objects that would be difficult to compute off of the user's machine, and that can be recreated without user intervention are a great fit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"compiled binaries" is the usecase I'd have in mind; but I am somewhat worried about the eager GC behavior, as recompilation can take a non-trivial amount of time. I guess I could print a message like "parts of this package were garbage collected and need to be regenerated, please wait" ?
UPDATE: OK, sorry, I should have read more first: I guess in that case, I might be better of creating an artifact with the compiled data on the fly
Yes! You can see that I actually do this in my compile time preferences package. |
I think the main sticking point on this PR is the GC time; I move that we discuss this on the next Pkg call (this coming Tuesday, at 2:15pm EST) and figure out what we do and don't want to support. Possibilities include:
|
This seems like it might be the right default.
When would there be no owning package? |
In the event that someone uses |
What is "owning package" in this context? For example, if
then, does PkgA own a scratch space? Also, why not let projects own the scratch space? Wouldn't it work with above scenario? It'd mean |
Right, so that means the scratch space would persist until ALL versions of PkgA are removed. We don't want scratch spaces to be project-specific unless the user wants them to be; that would unnecessarily cripple them. The files within the |
I don't know the implementation detail but, in principle, isn't it possible to reference the same scratch space from multiple projects? With Julia as an analogy, I'm imagining something like # Analogy
scratch = Ref(:scratch) # @get_scratch!(scratch_name) from PkgA
julia_logs = Dict() # ~/.julia/logs/manifest_usage.toml
julia_logs[:Project_A] = [] # PATH/TO/Project_A/Manifest.toml with PkgA
push!(julia_logs[:Project_A], # PkgA uses/creates the scratch space
:PkgA => scratch)
julia_logs[:Project_B] = [] # PATH/TO/Project_B/Manifest.toml with PkgA
push!(julia_logs[:Project_B], # PkgA re-uses the scratch space
:PkgA => scratch)
julia_logs[:Project_C] = [] # PATH/TO/Project_C/Manifest.toml with PkgA
# push!(julia_logs[:Project_C], # (PkgA does not use the scratch space inside
# :PkgA => scratch) # Project C.)
scratch = nothing So, at this point, reference graph is:
So, removing Project A and B would remove the scratch space: pop!(julia_logs, :Project_A) # Project A removed
GC.gc() # => `scratch` still exists
pop!(julia_logs, :Project_B) # Project B removed
GC.gc() # => `scratch` can be CG'ed This is in contrast with the model where PkgA = [Ref(:scratch)]
julia_logs = Dict()
julia_logs[:Project_A] = [PkgA]
julia_logs[:Project_B] = [PkgA]
julia_logs[:Project_C] = [PkgA]
pop!(julia_logs, :Project_A) # Project A removed
GC.gc() # => `scratch` still exists
pop!(julia_logs, :Project_B) # Project B removed
GC.gc() # => `scratch` still exists due to :Project_C |
We discussed on the Pkg call how to make the lifecycle more reliable here, and we came to the decision that it would be best to just persist scratch spaces for as long as the owning manifest exists. This makes it easy and should reduce fear of package authors, while still allowing old versions of packages whose scratch spaces are no longer used by newer versions of packages to get GC'ed. |
This implements functionality and tests for a new `Scratch` subsystem in `Pkg`; analogous to the `Artifacts` added in 1.3, this provides an abstraction for a mutable datastore that can be explicitly lifecycled to an owning package, or shared among multiple packages. Closes #796
I have altered the docs and implementation, so this is ready for final review. |
This implements functionality and tests for a new
Spaces
subsystem in
Pkg
; analogous to theArtifacts
added in 1.3, thisprovides an abstraction for a mutable datastore that can be explicitly
lifecycled to an owning package, or shared among multiple packages.
Closes #796