-
Notifications
You must be signed in to change notification settings - Fork 20
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
Upgrade to Cython 3+ in building #57
Conversation
Codecov Report
@@ Coverage Diff @@
## main #57 +/- ##
==========================================
+ Coverage 87.81% 88.07% +0.26%
==========================================
Files 21 21
Lines 1436 1434 -2
==========================================
+ Hits 1261 1263 +2
+ Misses 175 171 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
So this should be the results of the same MODIS operation I did in my #38 PR: I note that the memory profile looks about the same but increases more at the end than previously...but that is from other parts of Satpy, not the interpolation which is only the blue/green blocks near the beginning. I don't like the dips in CPU usage at the beginning even though execution time is about the same. |
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.
LGTM, even if I haven't checked the new features of Cython 3. Do you want to wait for an answer about the cython 3 issue you found before we merge this?
Yeah let's wait a bit. I'm more OK with trollimage being released than with this being merged given the issues. |
FYI the bug encountered in cython seems to have been fixed, but I don't think it is released yet. |
FYI I did a test compile with Cython's |
Nevermind, this is another major one: cython/cython#5688 |
Nevermind on that one, but this one is still a thing: cython/cython#5685 |
Also revert noexcept change on functions that return a memoryview. In current versions of Cython 3 this marks the function in a way that means it needs error checking and the GIL which can cause GIL usage in other parts of the module.
This PR upgrades the build dependencies to use Cython 3+. It also adds extra annotations required by Cython 3 to avoid extra Python-related checks and stay in C-land longer and with no GIL. As far as I can tell nothing of the generated code should be different to what it was.
Note I had concerns because the modis interpolation has some low-level functions with GIL-related when memory views are returned. I made a stackoverflow question about it and a Cython maintainer responded:
https://stackoverflow.com/questions/76972950/cython-returned-memoryview-is-always-considered-uninitialized
Basically, even though it is checking the memory view for validity/initialization, it is not actually acquiring the GIL except in the failure case which should never happen for us. We could restructure the code to not create a copy of the memory views used but instead adjust the indexing appropriately. The code would be harder to read but would not have the extra memoryview checks. I doubt it would have any performance difference.
I have not run a comparison of the performance, but given the logical changes appearing in the Cython I'm not too worried. I'll have to track down my old benchmarking from the last time the Cython was touched.
git diff origin/main **/*py | flake8 --diff