Skip to content

Commit 162179a

Browse files
committed
Revert "First activity cache (#2594)"
This reverts commit 71a5afd.
1 parent aaa5a36 commit 162179a

File tree

2 files changed

+2
-56
lines changed

2 files changed

+2
-56
lines changed

src/analyses/activity.jl

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -393,58 +393,9 @@ Base.@nospecializeinfer @inline function active_reg_inner(
393393
return ty
394394
end
395395

396-
const ActivityCache = Dict{Tuple{Type, Bool, Bool, Bool}, ActivityState}()
397-
398-
const ActivityWorldCache = Ref(0)
399-
400-
const ActivityMethodCache = Core.MethodMatch[]
401-
# given the current worldage of compilation, check if there are any methods
402-
# of inactive_type which may invalidate the cache, and if so clear it.
403-
function check_activity_cache_invalidations(world::UInt)
404-
# We've already guaranteed that this world doesn't have any stale caches
405-
if world <= ActivityWorldCache[]
406-
return
407-
end
408-
409-
invalid = true
410-
411-
tt = Tuple{typeof(EnzymeRules.inactive_type), Type}
412-
413-
methods = Core.MethodMatch[]
414-
matches = Base._methods_by_ftype(tt, -1, world)
415-
if matches === nothing
416-
@assert ActivityCache.size() == 0
417-
return
418-
end
419-
420-
methods = Core.MethodMatch[]
421-
for match in matches::Vector
422-
push!(methods, match::Core.MethodMatch)
423-
end
424-
425-
if methods == ActivityMethodCache
426-
return
427-
end
428-
429-
empty!(ActivityCache)
430-
empty!(ActivityMethodCache)
431-
for match in matches::Vector
432-
push!(ActivityMethodCache, match::Core.MethodMatch)
433-
end
434-
435-
ActivityWorldCache[] = world
436-
437-
end
438-
439396
Base.@nospecializeinfer @inline function active_reg(@nospecialize(ST::Type), world::UInt; justActive=false, UnionSret = false, AbstractIsMixed = false)
440-
key = (ST, justActive, UnionSret, AbstractIsMixed)
441-
if haskey(ActivityCache, key)
442-
return ActivityCache[key]
443-
end
444397
set = Base.IdSet{Type}()
445-
result = active_reg_inner(ST, set, world, justActive, UnionSret, AbstractIsMixed)
446-
ActivityCache[key] = result
447-
return result
398+
return active_reg_inner(ST, set, world, justActive, UnionSret, AbstractIsMixed)
448399
end
449400

450401
function active_reg_nothrow_generator(world::UInt, source::LineNumberNode, T, self, _)
@@ -462,7 +413,6 @@ function active_reg_nothrow_generator(world::UInt, source::LineNumberNode, T, se
462413
Core.Compiler.LineInfoNode(@__MODULE__, :active_reg_nothrow, source.file, Int32(source.line), Int32(0))
463414
]
464415
end
465-
check_activity_cache_invalidations(world)
466416
ci.min_world = world
467417
ci.max_world = typemax(UInt)
468418

src/compiler.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6049,9 +6049,7 @@ end
60496049
StrongZero
60506050
) #=abiwrap=#
60516051
tmp_job = if World isa Nothing
6052-
jb = Compiler.CompilerJob(mi, CompilerConfig(target, params; kernel = false))
6053-
check_activity_cache_invalidations(jb.world)
6054-
jb
6052+
Compiler.CompilerJob(mi, CompilerConfig(target, params; kernel = false))
60556053
else
60566054
Compiler.CompilerJob(mi, CompilerConfig(target, params; kernel = false), World)
60576055
end
@@ -6245,8 +6243,6 @@ function thunk_generator(world::UInt, source::Union{Method, LineNumberNode}, @no
62456243

62466244
mi === nothing && return stub(world, source, method_error)
62476245

6248-
check_activity_cache_invalidations(world)
6249-
62506246
min_world2 = Ref{UInt}(typemin(UInt))
62516247
max_world2 = Ref{UInt}(typemax(UInt))
62526248

0 commit comments

Comments
 (0)