Repository navigation
Keep more of the compiler concretely typed - #1053
Merged
Merged
Conversation
Like in the previous commits, code that operated on values inference couldn't type (names returned by `safe_name`, debug info file names, the signature in `classify_arguments`, entries of the `compiled` dictionary, runtime function declarations, loaded relocation targets, JLL library paths, and the result of a sibling compiler) was compiled with edges to the abstract signatures of generic Base methods. Packages that extend those (e.g. DataFrames' dependencies or FilePathsBase) then made Julia discard the precompiled code when loading GPUCompiler. Assert the known types, and hide the remaining dynamic call.
This was referenced Oct 21, 2026
`julia_type_words` recurses through `@nospecialize`d arguments, so its result wasn't inferred, and building the type names of struct arguments for their metadata was compiled with edges to generic concatenation methods (`vcat` of values of unknown type, `Base.tail(::Any)`), which ChainRulesCore invalidates. With it loaded first, that discarded the precompiled `finish_ir!` of the Metal back-end, and the first Metal kernel (e.g. the one `fill!` launches) took ~2 s longer to compile. Declare the result type and collect the words as `String`s.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## tb/invalidations #1053 +/- ##
====================================================
- Coverage 92.50% 92.49% -0.01%
====================================================
Files 31 31
Lines 7342 7346 +4
====================================================
+ Hits 6792 6795 +3
- Misses 550 551 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Follow-up to #1052. With the first round of fixes, ChainRulesCore no longer invalidates the compilation pipeline when it's loaded before GPUCompiler, but other common packages still do, through different generic methods. This asserts types that are known but that inference can't see, in code that's on the path of every compilation:
safe_namewhile mangling, which are alwaysStrings;backtrace, which areStrings ornothing;classify_arguments, like incheck_invocation;compiled, the runtime function declared bycall!, the address of a relocated C global, and the library paths of the lazily loaded JLLs inExternalBackend;merge!-ing the result of a sibling compiler, which is aDict{Any,Any}in practice and is otherwise merged behind an inference barrier;The triggers here are e.g. FilePathsBase's
joinpathandarg_gen, InlineStrings'convert(String, ...)and DataStructures'merge!, all of which are loaded by DataFrames or plotting packages.Tested with the full test suite. Measurements (together with JuliaLLVM/LLVM.jl#703 and the other follow-ups) are in JuliaLLVM/LLVM.jl#703; e.g., the first CUDA kernel with DataFrames loaded first goes from 6.42 s on main to 2.76 s (2.12 s with nothing loaded first).