Repository navigation
Conversation
Julia only records that a call depends on the absence of a method when the methods it found don't fully cover the call. A call that misses in the overlay tables and resolves to a method in a later table, or in Base's, has no dependency on the overlay tables, so adding an overlay later left stale code in the cache (#207). Record a missing-method edge for every lookup when GPUInterpreter finishes a frame: one global edge per signature on 1.12+, where these are checked on insertion into any table, and one per overlay table before. This roughly triples the number of edges and costs 5-15% inference time; it should move into Julia (JuliaLang/julia#63959).
maleadt
force-pushed
the
tb/overlay-edges
branch
from
December 3, 2026 15:37
2e7d20f to
b6ffc2b
Compare
This was referenced Dec 3, 2026
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 #207: adding an overlay method didn't invalidate code that called the method it overrides, so even a fresh
compilekept returning stale code.Julia only records that a call depends on the absence of a method (a "missing-method" edge) when the methods it found don't fully cover the call.
child()misses in the overlay table and is fully covered by Base's method, so the caller only gets an edge to that method, and inserting the overlay invalidates nothing. Redefining an overlay that already exists did work, through the edge to it. This affects Julia's ownOverlayMethodTablethe same way; I filed JuliaLang/julia#63959.This PR records a missing-method edge for every lookup when
GPUInterpreterfinishes a frame:(sig, Core.methodtable)pair per signature. These backedges are stored globally and checked on insertion into any table, including overlay tables, so one edge covers the whole stack;(mt, sig)pair per overlay table, because those backedges are stored per table.The check on insertion only invalidates when the new method is more specific than what that table already has for the signature, so defining unrelated methods in Base's table doesn't cause extra invalidations.
The cost is roughly three times as many edges, and correspondingly more time in Julia's
store_backedges. Inferring a set of Base functions (sort!,sum,string,repr, ...; about 3600 CodeInstances) on 1.12 went from 1.74 s to 1.82–2.0 s.Not covered: code in a package image that was precompiled while a lookup missed in an overlay table is still not invalidated by an overlay defined before the image is loaded. Edge verification at load time skips these edges and only looks at Base's method table (see the Julia issue). On 1.12+, an overlay defined after loading is handled, since the edges are re-registered when the image is loaded.
This is #1035 rebased onto current main, where lookups now go through
MethodTableStack;overlay_tableshandles that type too. x-ref #1035This is a stopgap. Upstream hasn't settled how external interpreters should be invalidated: Jameson argues they shouldn't add native backedges for non-native semantics and should verify their own forward edges instead (JuliaLang/julia#63959 (comment)), while the drafts JuliaLang/julia#64726 and JuliaLang/julia#64727 would have Julia record and re-verify lookups through overlay tables itself. The edges are recorded in one place, so this can follow whichever lands.