From 7001ef7a4885097750abd5cbf14602fe4454d589 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 23 Dec 2021 09:44:42 -0500 Subject: [PATCH] RFC: Shorten tags by using the objectid of the function instead of directly the function Right now duals of duals of duals have an exponential growth in the type name because the functions then to have closures which hold values with the values, so as you begin to nest you see the previous nest in the function type (multiple times). This makes the tag always the same size. `julia> objectid(typeof(f)) #0x0000000006be1dbe`. Now instead of a massive tag you just get a small tag, but it's some essentially random number. But it's not random in the sense of always being different: it is a deterministic hash: ```julia julia> f(x) = x f (generic function with 1 method) julia> objectid(typeof(f)) 0x0000000006be1dbe ``` so it plays the same as before with precompilation. Is this a good idea? --- src/config.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.jl b/src/config.jl index 30f02ae5..eb97a0c6 100644 --- a/src/config.jl +++ b/src/config.jl @@ -14,8 +14,8 @@ const TAGCOUNT = Threads.Atomic{UInt}(0) end function Tag(f::F, ::Type{V}) where {F,V} - tagcount(Tag{F,V}) # trigger generated function - Tag{F,V}() + tagcount(Tag{objectid(F),V}) # trigger generated function + Tag{objectid(F),V}() end Tag(::Nothing, ::Type{V}) where {V} = nothing