-
-
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
sort! return type not inferred properly #12833
Comments
cc @kmsquire |
Looking into this... |
It seems my sort changes introduced some type instability into S = sortperm(state.dists, rev=true) to S = sortperm(state.dists, rev=true)::Vector{Int} the performance regression goes away. Now I just need to figure out why that's happening. |
Thank you for looking into this, @kmsquire! |
Np. I don't like introducing performance regressions. ;-) |
Progress: the |
More progress: the |
Simple way to reproduce the problem: On master: julia> Base.return_types(sort, (Vector{Int},))
1-element Array{Any,1}:
Any After fixing: julia> Base.return_types(sort, (Vector{Int},))
1-element Array{Any,1}:
Array{Int64,1} Submitting a patch in a few minutes. |
Again, many thanks for tracking this down. I'm looking forward to the merge. I'm also a bit puzzled as to why I was the first to find this (34 days after it happened). Is there no other performance-critical code using |
PS:
Fixes the regression, time-wise, but still results in massive overallocation:
|
Remove specialized sort! method for PartialQuickSort{Int} (fixes #12833)
What was the allocation previously (or with the merged patch)? |
Nevermind, I see it above. What is it with the new patch? |
The full log is in the initial message, but
|
Looks the same... (roughly) |
Dunno - I'm still building the new version - the git bisect left me in a weird state so I had to do a make distcleanall. |
New commit:
|
Let me try my proposed change to that commit and I'll let you know what comes up. |
Nope, it didn't fix it:
|
I'm not sure that's something that needs fixing. The total amount of allocation that is happening isn't happening all at once--it's being allocated, released, and garbage collected throughout that call. |
(As you of course know), excessive allocation usually mean that there is a type instability somewhere. Unless that is the case, why would the code suddenly allocate so much more? |
But it doesn't allocate so much more. It's allocating about the same amount. (The printing of that allocation has gone through a few iterations, though...) |
Oh, this is my mistake. Math units are HARD. |
Oh, then forget what I said. |
:-) No worries! |
It's not like I was the last one who touched the printing of allocation numbers and sizes or something... *whistle. |
…t{Int} (fixes JuliaLang#12833)" This reverts commit 9e8fcd3, except for the test. The underlying issue(s) causing JuliaLang#12833 seem to have been fixed with recent changes in inference.
…t{Int} (fixes JuliaLang#12833)" This reverts commit 9e8fcd3, except for the test. The underlying issue(s) causing JuliaLang#12833 seem to have been fixed with recent changes in inference.
…t{Int} (fixes JuliaLang#12833)" This reverts commit 9e8fcd3, except for the test. The underlying issue(s) causing JuliaLang#12833 seem to have been fixed with recent changes in inference.
Git bisect results:
Yields the following difference:
Bad:
Good:
Relevant code here: https://github.com/JuliaGraphs/LightGraphs.jl/blob/master/src/centrality/betweenness.jl#L99-L111
I believe this is caused by the call to
sortperm()
.The text was updated successfully, but these errors were encountered: