-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: GH10213 kth_smallest GIL release #10927
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
Conversation
can you add a asv benchmark (note that #10928 ) changes this so will merge this after. This should affect Further use the You can also add this issue to the GIL release issues in the whatsnew. |
|
||
if j < k: l = i | ||
if k < i: m = j | ||
return a[k] | ||
|
||
|
||
cdef inline kth_smallest_c(float64_t* a, Py_ssize_t k, Py_ssize_t n): |
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.
I don't think kth_smallest_c
is called anywhere in the codebase, see if you can take it out
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.
this group_median
calls
group_median
here,
which calls _median_linear
, which in turn calls kth_smallest_c
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.
ok, good start on this.....
OK, I will update after 10928. I had looked at The function alters the state of the array, so I needed one set-up per iteration (hence I will check what asv has. |
186df16
to
e970381
Compare
@@ -2078,6 +2079,48 @@ def inner(*args, **kwargs): | |||
return wrapper | |||
|
|||
|
|||
def test_parallel_diff_args(num_threads=2, args_list=None, kwargs_list=None): |
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.
Something like this is often needed for testing functions that alter the state of the input, such as some sorting algos and operations like drop_duplicates
. This could be combined with test_parallel
to reduce code duplication, but having it in a separate function saves some if-else that might affect timing.
As a side note I think import threading
should be done somewhere else, because a second function call would otherwise incur a lower cost, although I haven't really observed an appreciable difference yet.
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.
I would just add onto test_parallel
@kawochen can you update |
Will do. I haven't been able to get the |
e970381
to
56358f6
Compare
56358f6
to
6db459a
Compare
Updated. |
@kawochen ahh ok, when you have time can you expand the doc section on |
PERF: GH10213 kth_smallest GIL release
thanks! |
asv |
@pv forgive my hyperbole! It's a great package 😄 I looked at the code before and saw that repeat is passed into |
Repeat is indeed passed to timeit, but the setup function is not run by timeit, but is done separately. |
One tiny part of #10213
On master
On branch
Testing of
nsmallest
/nlargest
/median
(I don't thinkmedian
callskth_smallest
though)Master
nsmallest
Branch
nsmallest
Master
nlargest
Branch
nlargest
Master
median
Branch
median
Results are pretty in line with expectations --
nsmallest
does quite a bit more thankth_smallest
, such as copying and indexing.