-
Notifications
You must be signed in to change notification settings - Fork 3.9k
ARROW-2052: [C++ / Python] Rework OwnedRef, remove ScopedRef #1534
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
OwnedRef API cleaned up: - doesn't try to take the GIL in its destructor anymore - reset() decrefs the underlying pointer - detach() unowns the pointer without decrefing it Add OwnedRefNoGIL which forcefully takes the GIL in its destructor, at the expense of runtime performance.
|
This PR has an interesting performance impact here:
Probably because of less calls to |
|
On the subject of performance, our Airspeed / ASV setup is in a state of disrepair. We should start building a suite of microbenchmarks so we can monitor the performance of operations like these in a more systematic way. There are already some JIRAs open about getting this cleaned up and well-documented for other developers, would you be interested in taking a look? |
Definitely, can you give me some pointers? |
|
See https://issues.apache.org/jira/browse/ARROW-1861 There is already an asv.conf.json in https://github.com/apache/arrow/tree/master/python and a couple of benchmarks, but I tried to run it myself some time ago and ran into issues. It's not documented at all AFAICT. pandas has a pretty deep suite of benchmarks https://github.com/pandas-dev/pandas/tree/master/asv_bench |
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.
@pitrou LGTM
Is it correct to say that now callers must be more careful about acquiring the GIL before making calls into the Python C API (assuming use of OwnedRef)?
|
I need to take a closer look at our various usages of |
The PR already takes care of that, by using OwnedRefNoGIL in those places (perhaps I've missed some?). |
The GIL rules for OwnedRef are now the same as they were for ScopedRef. If you're not sure the GIL will remain held at the right times, you can use OwnedRefNoGIL instead. |
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.
+1, thanks for doing this, cleaner now!
OwnedRef API cleaned up:
Add OwnedRefNoGIL which forcefully takes the GIL in its destructor, at the expense of runtime performance.