From b3addd058760924c42ac86fbd14ff1ae83d7dcd7 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 7 Jan 2025 13:55:55 -0100 Subject: [PATCH] Fix the inference error by removing assume_effects We can't actually assume foldable, and it's probably deep enough in the stack that it confuses the compiler. Measuring performance doesn't seem to show a decrease, so we eat the cost... --- GeometryOpsCore/src/apply.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GeometryOpsCore/src/apply.jl b/GeometryOpsCore/src/apply.jl index d7713195d..06e2ae545 100644 --- a/GeometryOpsCore/src/apply.jl +++ b/GeometryOpsCore/src/apply.jl @@ -343,9 +343,12 @@ using Base.Threads: nthreads, @threads, @spawn return mapreduce(fetch, vcat, tasks) end #= -Here we use the compiler directive `@assume_effects :foldable` to force the compiler +Here we used to use the compiler directive `@assume_effects :foldable` to force the compiler to lookup through the closure. This alone makes e.g. `flip` 2.5x faster! + +But it caused inference to fail, so we've removed it. No effect on runtime so far as we can tell, +at least in Julia 1.11. =# -Base.@assume_effects :foldable @inline function _maptasks(f::F, taskrange, threaded::_False)::Vector where F +@inline function _maptasks(f::F, taskrange, threaded::_False)::Vector where F map(f, taskrange) end \ No newline at end of file