-
-
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: Higher order function memory usage #10954
Comments
Possibly a dup of #10898 |
the alloc_*w functions were changed to refer to size not including tag, but these functions were not updated.
perhaps the less compact pool? or perhaps it's just a change in the accounting (for the wasted space after rounding various allocation boundaries)? |
This mostly boxes Int64s and Float64s, which should still take exactly 16 bytes each right? |
the alloc_*w functions were changed to refer to size not including tag, but these functions were not updated.
the alloc_*w functions were changed to refer to size not including tag, but these functions were not updated.
Checked in on this; situation hasn't changed. Still a bit of a mystery. |
unless --track-allocation is confused, edit: it's not confused. replacing the function with an untyped value shows the same change in allocation |
the difference is that the 0.4 inliner became good enough to shoot itself in the foot. instead of calling:
and paying for dynamic dispatch on setindex!, it instead calls:
and pays for dynamic dispatch on convert, and boxing for the result and for i to call the runtime jl_f_arrayset function |
Was there a patch for this, @vtjnash, or did this accidentally close? |
We should improve codegen for We should also maybe not inline with an |
the bug report of above states: "Regression: Higher order function memory usage". but there was no regression in the higher order function memory application, just a different set of optimizations elsewhere. You can recover the original allocations (although for a different reason) with the following patch: diff --git a/base/array.jl b/base/array.jl
index 2694964..733eb00 100644
--- a/base/array.jl
+++ b/base/array.jl
@@ -310,10 +310,10 @@ function getindex{T<:Real}(A::Array, I::Range{T})
end
## Indexing: setindex! ##
-setindex!{T}(A::Array{T}, x, i1::Real) = arrayset(A, convert(T,x), to_index(i1))
-setindex!{T}(A::Array{T}, x, i1::Real, i2::Real, I::Real...) = arrayset(A, convert(T,x), to_index(i1), to_index(i2), to_indexes(I...)...)
+setindex!{T}(A::Array{T}, x, i1::Real) = arrayset(A, convert(T,x)::T, to_index(i1))
+setindex!{T}(A::Array{T}, x, i1::Real, i2::Real, I::Real...) = arrayset(A, convert(T,x)::T, to_index(i1), to_index(i2), to_indexes(I...)...)
-unsafe_setindex!{T}(A::Array{T}, x, i1::Real, I::Real...) = @inbounds return arrayset(A, convert(T,x), to_index(i1), to_indexes(I...)...)
+unsafe_setindex!{T}(A::Array{T}, x, i1::Real, I::Real...) = @inbounds return arrayset(A, convert(T,x)::T, to_index(i1), to_indexes(I...)...)
# These are redundant with the abstract fallbacks but needed for bootstrap
function setindex!(A::Array, x, I::AbstractVector{Int}) |
The issue title could just as well say "this piece of code now uses more memory"; doesn't matter whether it's specific to higher-order functions. If it points to possible improvements in the system, we should make them if reasonable. I don't think this is super high priority though. |
backport this or no? |
I won't actually backport this unless someone responds that I should, but I'm adding the label for now so it doesn't get forgotten. |
Bump. Could use an opinion on whether or not to backport this. |
This should impact quite a few numerical algorithms, for instance ODE solvers which call their objective functions many times. So, I'd be happy to see it in 0.4 but it is far from being a show-stopper. |
I would love to see the backport too. |
In 0.4 higher order functions allocate up to 2x as much memory as in 0.3.
0.4:
0.3:
Another test:
returns on 0.4:
and on 0.3:
The text was updated successfully, but these errors were encountered: