Skip to content

Commit cffa09d

Browse files
authored
Revert "First activity cache (#2594)"
This reverts commit 71a5afd.
1 parent 71a5afd commit cffa09d

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
@@ -5871,9 +5871,7 @@ end
58715871
StrongZero
58725872
) #=abiwrap=#
58735873
tmp_job = if World isa Nothing
5874-
jb = Compiler.CompilerJob(mi, CompilerConfig(target, params; kernel = false))
5875-
check_activity_cache_invalidations(jb.world)
5876-
jb
5874+
Compiler.CompilerJob(mi, CompilerConfig(target, params; kernel = false))
58775875
else
58785876
Compiler.CompilerJob(mi, CompilerConfig(target, params; kernel = false), World)
58795877
end
@@ -6067,8 +6065,6 @@ function thunk_generator(world::UInt, source::Union{Method, LineNumberNode}, @no
60676065

60686066
mi === nothing && return stub(world, source, method_error)
60696067

6070-
check_activity_cache_invalidations(world)
6071-
60726068
min_world2 = Ref{UInt}(typemin(UInt))
60736069
max_world2 = Ref{UInt}(typemax(UInt))
60746070

0 commit comments

Comments
 (0)