-
-
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
sparse findnext findprev hash performance improved #31354
Conversation
AppVeyor fault seems unrelated. |
@KlausC All your PRs seem to have a lot of commits that seem to be unrelated and clearly don't show up when I merge. I wonder if you are doing something differently with |
He just always use merge to sync with master and never rebased. |
@yuyichao That is right. I would like to insert a git rebase, if I'd know how to do that.
|
When you are ready to submit the PR, you may want to do |
The workflow should be something like:
Once done with a PR it is often nice to condense the PR into one or several important commits (each commit should pass the tests). For this use To get out of your current affliction, it's probably easiest if you copy your
|
@mauro3 , thank you very much! git looks clean now. I will change my work flow according to your recommendation. @ViralBShah,
|
Thanks @KlausC. This looks so much cleaner. And thanks everyone for the help here. |
Can we have some tests for the sparse cases for findprev/next/etc? Also, while it basically looks good to me, it would be good to get an extra pair of eyes on this PR. |
I thought, the existing tests might be sufficient: Lines 126 to 147 in 10141d3
findnext/findprev: julia/stdlib/SparseArrays/test/sparse.jl Lines 2248 to 2258 in 10141d3
|
@andreasnoack, who would be interested? |
Maybe one of @KristofferC or @mbauman ? |
AFAICT tests should include something like |
return nothing | ||
end | ||
|
||
function _idx_to_cartesian(A::SparseMatrixCSC, idx::Integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why define this here rather than above with other _idx
functions?
@@ -1369,6 +1369,79 @@ function sparse_sortedlinearindices!(I::Vector{Ti}, V::Vector, m::Int, n::Int) w | |||
return SparseMatrixCSC(m, n, colptr, I, V) | |||
end | |||
|
|||
# findfirst/next/prev/last | |||
import Base: findfirst, findnext, findprev, findlast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findfirst
and findlast
aren't overloaded here. Also, this file seems to use Base.f
rather than import Base: f
.
Thanks for the review - I added the missing tests and made recommended changes. |
bump :-) |
Yes, this looks quite good to me. My only review comment would be in the naming of some of those Thanks @KlausC! |
Hi there -- this pull request seems related to a noticeable slowdown I'm observing in my own use case. Could you help me see if we can fix that? My use case is sparse matrices of polynomials, but the same issue exists for sparse matrices of e.g.
Any reason not to use
In my case, both of these things work together in such a way that the allocation of Disclose, I wrote the previous incarnations of this in #23317, so in that sense it's not a surprise that my use case works better with the code I optimized for it. Would you mind helping me to make both cases work? Two more profiling screenshots to illustrate this: (FWIW, this looks like it fulfills a very similar function to |
It actually might make sense to look a bit deeper and see what's the difference between this PR and #23317 at all. It seems like they're both very similar and duplicate behaviour. My gut feeling is that it should have been possible to reach the stated objective of hash performance with only minor fixes to that other one. |
…#31354)" This seems to duplicate work from JuliaLang#23317 and it causes performance degradation in the cases that one was designed for. See JuliaLang#31354 (comment) This reverts commit e0bef65.
…#31354)" This seems to duplicate work from JuliaLang#23317 and it causes performance degradation in the cases that one was designed for. See JuliaLang#31354 (comment) This reverts commit e0bef65.
I feel really bad, but I just submitted a revert of this pull request + a "fixed" (from my point of view) implementation in #32007 . I'd appreciate any thoughts you have either here or there. |
…artesian coordinates (#32007) Revert "sparse findnext findprev hash performance improved (#31354)" This seems to duplicate work from #23317 and it causes performance degradation in the cases that one was designed for. See #31354 (comment) This reverts commit e0bef65. Thanks to @mbauman for spotting this issue in #32007 (comment).
…artesian coordinates (#32007) Revert "sparse findnext findprev hash performance improved (#31354)" This seems to duplicate work from #23317 and it causes performance degradation in the cases that one was designed for. See #31354 (comment) This reverts commit e0bef65. Thanks to @mbauman for spotting this issue in #32007 (comment). (cherry picked from commit ec797ef)
…artesian coordinates (#32007) Revert "sparse findnext findprev hash performance improved (#31354)" This seems to duplicate work from #23317 and it causes performance degradation in the cases that one was designed for. See JuliaLang/julia#31354 (comment) This reverts commit 8623d9a. Thanks to @mbauman for spotting this issue in JuliaLang/julia#32007 (comment).
Specialized version of several find functions and
hash
.To demonstrate the difference,
hash
is called for different sparse matrices.hash
is callingfindprev
multiple times.Before - the time is growing with decreasing fill ratio.
After - the time is decreasing with decreasing fill ratio and generally lower.