From 9332018e089b4857ae1e575d1f458555a73c3aed Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 12 Mar 2023 04:45:47 -0500 Subject: [PATCH 1/3] Ensure accurate invalidation logging data This modifies #48841 to restore the required logging data. By collecting at least one additional match, we retain the possibility of identifying at least one trigger of invalidation. --- src/staticdata_utils.c | 3 ++- test/precompile.jl | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/staticdata_utils.c b/src/staticdata_utils.c index 4ec60b26a11b4..a4953c907c773 100644 --- a/src/staticdata_utils.c +++ b/src/staticdata_utils.c @@ -869,8 +869,9 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld) assert(jl_is_array(expected)); int ambig = 0; // TODO: possibly need to included ambiguities too (for the optimizer correctness)? + // len + 1 is to allow us to log causes of invalidation (SnoopCompile's @snoopr) matches = jl_matching_methods((jl_tupletype_t*)sig, jl_nothing, - jl_array_len(expected), 0, minworld, &min_valid, &max_valid, &ambig); + jl_array_len(expected) + 1, 0, minworld, &min_valid, &max_valid, &ambig); if (matches == jl_nothing) { max_valid = 0; } diff --git a/test/precompile.jl b/test/precompile.jl index 1ee32cb39e37d..059e6943efa60 100644 --- a/test/precompile.jl +++ b/test/precompile.jl @@ -915,7 +915,7 @@ precompile_test_harness("code caching") do dir mi = m.specializations[1] @test hasvalid(mi, world) # was compiled with the new method - # Reporting test + # Reporting test (ensure SnoopCompile works) @test all(i -> isassigned(invalidations, i), eachindex(invalidations)) m = only(methods(MB.call_nbits)) for mi in m.specializations @@ -936,7 +936,7 @@ precompile_test_harness("code caching") do dir j = findfirst(==(tagbad), invalidations) @test invalidations[j-1] == "insert_backedges_callee" @test isa(invalidations[j-2], Type) - @test invalidations[j+1] === nothing || isa(invalidations[j+1], Vector{Any}) # [nbits(::UInt8)] + @test isa(invalidations[j+1], Vector{Any}) # [nbits(::UInt8)] m = only(methods(MB.map_nbits)) @test !hasvalid(m.specializations[1], world+1) # insert_backedges invalidations also trigger their backedges From 79392b94f734a03b0ef2120e29997963ecae566d Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Wed, 15 Mar 2023 16:03:38 -0500 Subject: [PATCH 2/3] Bump number of invalidation causes --- src/staticdata_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/staticdata_utils.c b/src/staticdata_utils.c index a4953c907c773..408b280f6d0f2 100644 --- a/src/staticdata_utils.c +++ b/src/staticdata_utils.c @@ -871,7 +871,7 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld) // TODO: possibly need to included ambiguities too (for the optimizer correctness)? // len + 1 is to allow us to log causes of invalidation (SnoopCompile's @snoopr) matches = jl_matching_methods((jl_tupletype_t*)sig, jl_nothing, - jl_array_len(expected) + 1, 0, minworld, &min_valid, &max_valid, &ambig); + INT32_MAX, 0, minworld, &min_valid, &max_valid, &ambig); if (matches == jl_nothing) { max_valid = 0; } From 53c53fffd7dccf0c8e73cb7daca062b735f29469 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Thu, 16 Mar 2023 14:30:34 -0500 Subject: [PATCH 3/3] Update src/staticdata_utils.c Co-authored-by: Jameson Nash --- src/staticdata_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/staticdata_utils.c b/src/staticdata_utils.c index 408b280f6d0f2..df6bcfd61d9f6 100644 --- a/src/staticdata_utils.c +++ b/src/staticdata_utils.c @@ -871,7 +871,8 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld) // TODO: possibly need to included ambiguities too (for the optimizer correctness)? // len + 1 is to allow us to log causes of invalidation (SnoopCompile's @snoopr) matches = jl_matching_methods((jl_tupletype_t*)sig, jl_nothing, - INT32_MAX, 0, minworld, &min_valid, &max_valid, &ambig); + _jl_debug_method_invalidation ? INT32_MAX : jl_array_len(expected), + 0, minworld, &min_valid, &max_valid, &ambig); if (matches == jl_nothing) { max_valid = 0; }