Skip to content
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

NLsolve significantly slower on 0.5 #49

Closed
KristofferC opened this issue Mar 18, 2016 · 3 comments
Closed

NLsolve significantly slower on 0.5 #49

KristofferC opened this issue Mar 18, 2016 · 3 comments

Comments

@KristofferC
Copy link
Collaborator

Making this to track regression in master and to make people aware

using NLsolve

    function f!(x::Vector, fvec::Vector)
        fvec[1] = 1 - x[1]
        fvec[2] = 10(x[2]-x[1]^2)
    end
    function g!(x::Vector, fjac::Matrix)
        fjac[1,1] = -1
        fjac[1,2] = 0
        fjac[2,1] = -20x[1]
        fjac[2,2] = 10
    end


df! = DifferentiableMultivariateFunction(f!, g!)
x0 = [-1.2; 1.]

@time for i in 1:10^4 nlsolve(df!, x0, method = :newton) end

On 0.4.3: 0.292429 seconds (5.31 M allocations: 123.749 MB, 10.00% gc time)

On master: 1.336571 seconds (5.53 M allocations: 101.471 MB, 2.06% gc time)

I believe this is because we are mutating a variable inside a closure which is slow in 0.5.. see JuliaLang/julia#15276

@KristofferC
Copy link
Collaborator Author

This is sligtly better now on master.

julia> @time for i in 1:10^4 nlsolve(df!, x0, method = :newton) end
  0.856573 seconds (5.28 M allocations: 96.436 MB, 2.41% gc time)

Still bad though.

@KristofferC
Copy link
Collaborator Author

KristofferC commented May 17, 2016

Commenting out these two lines which are the only problematic ones (inferred as Any) on master gives:

julia> @time for i in 1:10^4 nlsolve(df!, x0, method = :newton) end
  0.264198 seconds (4.62 M allocations: 97.046 MB, 4.19% gc time)

Without them commented out:

julia> @time for i in 1:10^4 nlsolve(df!, x0, method = :newton) end
  0.397250 seconds (4.67 M allocations: 98.114 MB, 2.91% gc time)

@KristofferC
Copy link
Collaborator Author

This is fixed now.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant