Repository navigation
[1.12] Defer global caching of CodeInstance to post-optimization step - #63080
Merged
Merged
Conversation
) This PR extracts the caching improvements from #56687, implemented by @aviatesk. It essentially defers global caching to the post-optimization step, giving a temporary cache to the optimizer instead of relying on the global cache. The issue with caching globally before optimization is that any errors occurring within the optimizer may leave a partially initialized `CodeInstance` in the cache, which was meant to be updated post-optimization. Exceptions should not be thrown in the native compilation pipeline, but abstract interpreters extending optimization routines will frequently encounter some during an iterative development (see JuliaComputing/DAECompiler.jl#25). An extra benefit from deferring global caching is that the optimizer can then more safely update `CodeInstance`s with new inference information, as is the intent of #56687. --------- Co-authored-by: Shuhei Kadowaki <aviatesk@gmail.com> Co-authored-by: Cody Tapscott <84105208+topolarity@users.noreply.github.com> (cherry picked from commit 24d2f4a)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #58343 to release-1.12.
On 1.12,
finishinfer!publishes theCodeInstanceof an inferred method tocode_cache(interp)before optimization runs, and
finish!completes it afterwards withjl_update_codeinst, which alsooverwrites
analysis_resultswholesale. Between those two points theCodeInstanceis visible toother tasks through the code cache with a valid world range, so anything attached to
analysis_resultsin that window is silently discarded. 1.11 and 1.13+ publish only afterfinish!, so the window exists only on 1.12.Packages that hang per-consumer data off
analysis_resultsof cachedCodeInstances(CompilerCaching.jl, used by CUDA.jl and cuTile.jl) assume that a
CodeInstancereturned bythe code cache with a valid world range is final. On 1.12, a concurrent cold compilation
attaches to a
CodeInstancethat another task is still finalizing, and the attachment islost (JuliaGPU/cuTile.jl#311).
#58343 originally carried the backport-1.12 label, which was dropped in June 2025 because it did
not apply cleanly. The cherry-pick had three trivial conflicts in
finish!(divsdebuginfonaming), and the result matches the 1.13 code. JET already overloads both theold and new
finishinfer!signatures.Assisted by: Fable 5.1