-
Notifications
You must be signed in to change notification settings - Fork 4
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
Why is this allocating at all? #2
Comments
What code? Did you mean to post an example? |
Any code using E.g. example from the readme.
|
So the location some of the allocations come from is in creating the Context, (thanks @vchuravy).
|
It doesn't do it in 1.2, only 1.3+ In 1.3:
in 1.2:
64 is just the cost of creating the context. |
This was not fixed by JuliaLabs/Cassette.jl#166 |
I think this is related to all the splatting that happens in the definition of using SpecializeVarargs
@specialize_vararg 5 recurse(ctx::Context, ::typeof(Core._apply), f, args...) = Core._apply(recurse, (ctx, f), args...) and I find that the allocations in using AutoPreallocation, BenchmarkTools
foo() = ones(1, 2096) * ones(2096, 1024) * ones(1024,1)
let
foo_res, foo_record = record_allocations(foo)
@btime avoid_allocations($foo_record, $foo)
end goes from |
To clarify what I mean, I think that if overdub(OVERDUB_CONTEXT_NAME::Context)
overdub(OVERDUB_CONTEXT_NAME::Context, arg1::T1) where {T1}
overdub(OVERDUB_CONTEXT_NAME::Context, arg1::T1, arg2::T2) where {T1, T2}
overdub(OVERDUB_CONTEXT_NAME::Context, arg1::T1, arg2::T2, arg3::T3) where {T1, T2, T3}
overdub(OVERDUB_CONTEXT_NAME::Context, arg1::T1, arg2::T2, arg3::T3, arg4::T4) where {T1, T2, T3, T4} instead of just overdub(OVERDUB_CONTEXT_NAME::Context, args...) the allocations might be avoided here. The explicit specializations on |
There is no real reason this code should allocate AFIACT.
I think something is going wrong with Cassette.
The text was updated successfully, but these errors were encountered: