Skip to content
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

Also import ScopeStorage from Base with Julia >= 1.11 #14

Open
Drvi opened this issue Oct 18, 2023 · 5 comments
Open

Also import ScopeStorage from Base with Julia >= 1.11 #14

Drvi opened this issue Oct 18, 2023 · 5 comments

Comments

@Drvi
Copy link

Drvi commented Oct 18, 2023

While migrating from ContextVariablesX.jl, we needed an "empty scope" in place of empty ContextSnapshot{T}. To do that in a way that is works both before and after Julia 1.11, we needed this hack:

const _EMPTY_SCOPE = ScopedValues.Scope(
    isdefined(ScopedValues, :ScopeStorage) ?
        ScopedValues.ScopeStorage() :
        Base.ScopedValues.ScopeStorage()
)

Since ScopeStorage is not imported to the package from Base in 1.11.
Could we please import it?:)

@vchuravy
Copy link
Owner

Why do you need an empty Scope? Scope is not something user-facing and I would like to examine the pattern first,
before we commit to supporting something.

@Drvi
Copy link
Author

Drvi commented Oct 19, 2023

Hey Valentin, sure -- we have a TaskGroup construct that runs "TaskQueueEntries" (which are similar to Base.Tasks) according to their priority, and we store the scope in each of these TaskQueueEntries like this:

task_scope = @something(ScopedValues.current_scope(), _EMPTY_SCOPE)

When running our task, we reconstruct the scope using enter_scope (and its variant for Julia 1.11+).

@vchuravy
Copy link
Owner

Enter_scope is not public and we need to be careful with the semantics here. Long-term I want to be able to support compiler optimization over scoped values and letting the user manipulate the scope directly would break those.

We can discuss snapshotting (x-ref #6), but I am not comfortable with user packages directly manipulating the internals.

@Drvi
Copy link
Author

Drvi commented Oct 19, 2023

Gotcha, thanks, too bad there seems to be no way to implement snapshotting in userspace. Any time estimate for the snapshotting feature to be finalized? Once done, would it be possible to snapshot the current_scope()? Any way I could help?

@vchuravy
Copy link
Owner

vchuravy commented Oct 24, 2023

@Drvi I think the best thing would be to help with #6

E.g. if we implement snapshotting here instead in your code basis we can make sure that it doesn't break semantics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants