Skip to content

Commit 2cb8e17

Browse files
authored
Attribution for "insert_backedges" invalidations (#41913)
Invalidations can be immediate (when an existing MethodInstance gets invalidated by a new method definition) or delayed. The latter occurs during deserialization: when a package was built, a particular call dispatches to Method 1, but when loaded (due to different loading orders and dependencies) it should instead dispatch to Method 2. These delayed invalidations are not particularly common, and perhaps because of this SnoopCompile has never supported them well: they have merely been dumped to the console during `invalidation_tree` construction. However, in larger software stacks they seem to become more common, and can dramatically affect precompilation success. This simple PR identifies "causes" for such delayed invalidations, allowing SnoopCompile to determine (in most cases) the particular definition or deletion that triggered the change in dispatch.
1 parent 746734c commit 2cb8e17

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/dump.c

+8
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,8 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
19631963
size_t i, l = jl_array_len(targets) / 2;
19641964
jl_array_t *valids = jl_alloc_array_1d(jl_array_uint8_type, l);
19651965
memset(jl_array_data(valids), 1, l);
1966+
jl_value_t *loctag = NULL;
1967+
JL_GC_PUSH1(&loctag);
19661968
*pvalids = valids;
19671969
for (i = 0; i < l; i++) {
19681970
jl_value_t *callee = jl_array_ptr_ref(targets, i * 2);
@@ -2004,7 +2006,13 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
20042006
}
20052007
}
20062008
jl_array_uint8_set(valids, i, valid);
2009+
if (!valid && _jl_debug_method_invalidation) {
2010+
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)callee);
2011+
loctag = jl_cstr_to_string("insert_backedges_callee");
2012+
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
2013+
}
20072014
}
2015+
JL_GC_POP();
20082016
}
20092017

20102018
static void jl_insert_backedges(jl_array_t *list, jl_array_t *targets)

0 commit comments

Comments
 (0)