Skip to content

Commit

Permalink
Attribution for "insert_backedges" invalidations (JuliaLang#41913)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timholy authored and LilithHafner committed Feb 22, 2022
1 parent a2fbb2a commit d7e5ef3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,8 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
size_t i, l = jl_array_len(targets) / 2;
jl_array_t *valids = jl_alloc_array_1d(jl_array_uint8_type, l);
memset(jl_array_data(valids), 1, l);
jl_value_t *loctag = NULL;
JL_GC_PUSH1(&loctag);
*pvalids = valids;
for (i = 0; i < l; i++) {
jl_value_t *callee = jl_array_ptr_ref(targets, i * 2);
Expand Down Expand Up @@ -2004,7 +2006,13 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
}
}
jl_array_uint8_set(valids, i, valid);
if (!valid && _jl_debug_method_invalidation) {
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)callee);
loctag = jl_cstr_to_string("insert_backedges_callee");
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
}
}
JL_GC_POP();
}

static void jl_insert_backedges(jl_array_t *list, jl_array_t *targets)
Expand Down

0 comments on commit d7e5ef3

Please sign in to comment.