-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in deepcopy of nested structures #39534
Comments
Interesting; I can't reproduce this on x86_64. Is there also a regression in e.g. |
The vector case has not regressed. Also the named tuple case seems to only regress when I load Pumas. The vector case doesn't regress even with Pumas loaded. julia> using BenchmarkTools
julia> a = (a = rand(1000),);
julia> @btime deepcopy($a);
466.235 ns (6 allocations: 8.42 KiB)
julia> using Revise
julia> @btime deepcopy($a);
479.694 ns (6 allocations: 8.42 KiB)
julia> using Pumas
julia> @btime deepcopy($a);
886.905 ns (6 allocations: 8.42 KiB) The above benchmarks were using the nightly build of Julia from Feb 2. But the slowdown after loading Pumas seems to happen in all the Julia versions I tested. But some get slower than others. This slowdown is also happening outside the VM on MacOS Julia on Rosetta 2. So that may rule out VM weirdness. I still need to see if any of the deps of Pumas causes this individually. |
A similar slowdown is observed when loading Catalyst.jl instead of Pumas. |
Reduced to Catlab.jl. But none of Catlab's dependencies causes the slowdown. So the culprit is probably Catlab. |
The culprit is this definition in Catlab's function Base.getproperty(AD::Type{T},i::Symbol) where
{Ob,Hom,Dom,Codom,T<:CatDesc{Ob,Hom,Dom,Codom}}
@match i begin
:ob => Ob
:hom => Hom
:dom => Dom
:codom => Codom
_ => getfield(AD,i)
end
end |
Type piracy is indeed highly discouraged, particularly over getproperty and for Type{T} |
But it's not type piracy because Catlab owns |
You also override it for julia> struct MyType end
julia> foo(::Type{T}) where T <: MyType = print("foo")
foo (generic function with 1 method)
julia> foo(MyType)
foo
julia> foo(Union{})
foo Also you don't own |
Aha so with that logic, all uses of |
You can detect & fix this by measuring invalidations. Catlab is pretty bad: 1753 invalidations for me. The last few entries are:
|
Should help avoid issues like #39534.
Should help avoid issues like #39534.
Should help avoid issues like #39534.
Should help avoid issues like #39534.
Was fixed by AlgebraicJulia/Catlab.jl#382 |
Hi,
The following seems like a regression when
deepcopy
ing nested structures.I am running Julia for Linux Arm on a Ubuntu 20 virtual machine on an Apple M1 processor so my platform prints:
The text was updated successfully, but these errors were encountered: