ForwardDiff.jl icon indicating copy to clipboard operation
ForwardDiff.jl copied to clipboard

RFC: Shorten tags by using the objectid of the function instead of di…

Open ChrisRackauckas opened this issue 3 years ago • 1 comments

…rectly 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> 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?

ChrisRackauckas avatar Dec 23 '21 14:12 ChrisRackauckas

Since I have a few nested differentiations occurring in my codes, I am supportive of a change that shortens tags and makes stacktraces more readable as a result - is there an improvement possible in the sense that we do not completely lose the significance of the tag (i.e., stays human readable), while it's still shorter? Would that not carry the best of both worlds?

thomvet avatar Feb 06 '22 14:02 thomvet

It's been a while but shall we do this? As one more change to lump into 0.11 or 1.0 or whatever the next release ends up being.

Are we reasonably sure it's zero-cost?

mcabbott avatar Apr 29 '24 10:04 mcabbott

Julia v1.10 made stack traces smaller, I think this isn't needed anymore.

ChrisRackauckas avatar Apr 29 '24 12:04 ChrisRackauckas