I made a blog post on the new cancellation feature in Julia 1.14, here:
The post describes what the cancellation system is for, how to use it, and how it works. Please let me know what you think! Especially let me know if I got something wrong.
I made a blog post on the new cancellation feature in Julia 1.14, here:
The post describes what the cancellation system is for, how to use it, and how it works. Please let me know what you think! Especially let me know if I got something wrong.
Great read! Thanks for that! ![]()
I found it very clearly written overall. I just noticed that I had 2 small points of confusion when reading.
The compiler reasonably assumes that no code that is :effect_free can cause the code to enter an illegal state.
Took me a while to parse. I think for me it would be easier to get with the negation in a different place.
Suggestion:
The compiler reasonably assumes that no code that is :effect_free can not cause the code to enter an illegal state.
Then, you can make a new token source, and pass its derived token to the child task:
And the example. I only got what you meant later on. In hindsight, the example is now clear to me. I think what confused me is that you talk about parent and child but in this example the parent lifetime is not so clear? Not sure.
Maybe for me a clearer demonstration would have been be to create 2 children coupled to the same source and explaining that this couples their lifetimes in the sense that both are cancled at the same time.
Thanks for the write up! I like how the implementation allows for cancellation inside of a @ccall. I’m guessing we are responsible for making sure that the external code is effect free? So if we declare it and a lock is taken somewhere, we could end up with a deadlock.
Cancel sounds complex.
How about:
end
end?
end!
Now postponed to 1.15.
I can’t believe they cancelled cancellation. Cancel culture has gotten out of control
Do I get it right that cancellation tokens cannot interrupt simple loops without explicit cancel checks?
i = 0
for j in 1:10_000_000_000 # takes some time
i += j
end
This does not contain any blocking operations, so no implicit cancel checks either. However, it is somehow interruptable in current Julia.
Yes, you’re correct, that example at top level is currently not interruptible on the 1.15 nightly. In a function, however, it’d compile down directly to a constant and there’d be nothing to interrupt in the first place. But it’s true; it’s probably not uncommon for someone to write a while true at the REPL expecting to interrupt it, and it’d be good to ensure that can happen without needing the explicit @cancel_check.