-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
what world should Tasks run in? #35690
Comments
Would it make task-local logger inferrable? cc @c42f |
Oh really good question. I think the answer is no: even regardless of task spawning, dynamically scoped loggers currently can't be inferred at the use site. If we did want them to be fully inferred that's similar to passing them via contextual dispatch and has somewhat similar tradeoffs: extremely good runtime performance, but a lot more recompilation. I think there's a middle ground between no specialization and full contextual dispatch... something like "taking dynamically scoped variables seriously": the error handling and logging cases have a similar structure where you may want to pass the context down a deep call stack without specializing the intermediate frames. But then specialize any leaf function calls which actually make use of the dynamic context. Anyway, this is quite different from what Jeff is proposing here. Regarding the world age of |
Another advantage with this approach is that this lets the chain/tree of calls started from Demo (from #35844 (comment)): foo() = "First implementation of foo"
function bar()
Base.invoke_in_world(_entry_point_world, foo)
end
afoo() = fetch(@async foo())
function abar()
Base.invoke_in_world(_entry_point_world, afoo)
end
# Note `@async` creates a closure so the counter has to be fetched after that.
_entry_point_world = Base.get_world_counter()
@show bar()
@show abar()
println("Now, revise foo:")
foo() = "Second implementation of foo"
@show bar()
@show abar() prints
Ideally, the last |
This seems like a pretty compelling “minor change” ie technically breaking but probably undisruptive enough to be done in a minor release. |
Here is my very hacky POC for inferable Discussion: https://discourse.julialang.org/t/can-we-have-inferable-fetch-task/45541 |
How should we initialize the world age for a task? It's really easy to initialize from the parent In particular, it would be insufficient to make Instead it seems we'd need a composite |
This kind of issue makes me wonder if world-age could be more like a partial order or lattice rather than an integer. The parent task defines |
N.B. This means serialized tasks will discard this stateful information and pick up new/different information. Closes JuliaLang#35690 Closes JuliaLang#41332
N.B. This means serialized tasks will discard this stateful information and pick up new/different information. Closes JuliaLang#35690 Closes JuliaLang#41332
Currently, we start Task execution in the newest world, like
invokelatest
. However, we might instead want them to capture the world they were created in. That would potentially enable us to infer the result offetch(@spawn ...)
.The text was updated successfully, but these errors were encountered: