Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## tb/overlay-invalidation #1037 +/- ##
===========================================================
- Coverage 92.55% 92.39% -0.16%
===========================================================
Files 31 31
Lines 7337 7394 +57
===========================================================
+ Hits 6791 6832 +41
- Misses 546 562 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`code_lowered`, `code_typed` and `code_warntype` looked up the method for the signature of `job.source` again, in Base's method table (and on 1.12+ through the interpreter for `code_typed`). When the job compiles an overlay method, that showed different code from what is compiled. Use `job.source` directly.
Back-ends look up the method instance for a kernel with `methodinstance(ft, tt)`, which only considers Base's method table, so an overlay method for the kernel function itself was never compiled (#208). Looking it up in the job's method tables requires the config, as the tables may depend on it, so add `methodinstance(job)` that resolves `job.source` again through `method_table_view(job)`, for back-ends to call after constructing the job. Use it for deferred compilation and in the native test helper. On Julia versions with JuliaLang/julia#60718 this uses Julia's dispatch cache for every table; otherwise it falls back to a slower generic lookup.
Julia doesn't cache lookups that fail, and those take about 70 ns per overlay table, against 10 ns for a cached lookup. Kernels rarely have an overlay method, so `methodinstance(job)` would add 140 ns or more to every launch for a back-end with a couple of tables. Remember the misses for the world they happened in, which brings that back to around 30 ns in total.
maleadt
force-pushed
the
tb/overlay-kernel
branch
from
October 22, 2026 10:07
1101450 to
e6f56b2
Compare
maleadt
marked this pull request as draft
October 25, 2026 06:54
Member
Author
|
Marked draft because there's a significant cost here, and Jameson is convinced we need to handle this differently ourselves. |
Member
Author
|
Superseded by #1149, which resolves kernels through the job's method-table view instead of a separate lookup with a miss cache. |
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.
Fixes #208: an overlay method for the kernel function itself was ignored.
Back-ends look up
job.sourcewithmethodinstance(ft, tt), which only considers Base's method table, so the job compiles the global method. The rest of the pipeline already handles an overlay method instance fine. This PR addsmethodinstance(job), which looks the job's source up again in the job's method tables (method_table_view(job)). It takes a job because the table stack may depend on the configuration. Back-ends opt in after constructing the job:GPUCompiler uses it for deferred compilation and in the native test helper.
CompilerJob(mi, config)keeps meaning "compile this method instance". Because the lookup happens in the job's world, an overlay added after the kernel was first compiled is picked up as well.methodinstance(job)is meant for the launch path. With Julia 1.11.9+, 1.12.5+ or 1.13.0-beta2+ (JuliaLang/julia#60718) it uses Julia's dispatch cache for every table; otherwise it falls back to a generic lookup. Julia doesn't cache failed lookups, which cost ~70 ns per table against ~10 ns for a hit, so the misses are remembered for the world they happened in. For a back-end with its own overlay table plusSHARED_METHOD_TABLE, callingmethodinstance(job)for a kernel without an overlay takes ~30 ns (without remembering the misses, ~140 ns);methodinstance(ft, tt)itself takes 10–18 ns. These were measured on a loaded machine.Reflection (
code_lowered,code_typed,code_warntype) looked the method up again by the signature ofjob.source, so it showed the global method even for a job compiling the overlay. It now usesjob.sourcedirectly.Stacked on #1035, which fixes the related invalidation problem (#207) and introduces the
overlay_tableshelper used here.Not covered: a kernel that only has an overlay method and no method in Base's table, since
methodinstance(ft, tt)throws before there is a job.