-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PyROOT] Update cppyy to a recent version #14507
Conversation
Test Results 11 files 11 suites 2d 8h 31m 25s ⏱️ For more details on these failures, see this check. Results for commit 9c4418a. ♻️ This comment has been updated with latest results. |
05accc6
to
0151066
Compare
6f98d6c
to
55c810c
Compare
master
55c810c
to
4f00b4f
Compare
60381d9
to
98e5ecc
Compare
Starting build on |
Hi @smuzaffar! This is a big upgrade, and testing it with CMSSW would give us more confidence, the ROOT tests are all green already. Can you give us a hand? Thanks! |
@guitargeek , cmssw tests via cms-sw#205 |
Thank you! |
@smuzaffar , thanks also from me - appreciated! |
FYI , cmssw tests passed cms-sw#205 (comment) |
This is great news! I'll stop making code changes to the PR now, so we keep the validated state. I'll just need to update a few more times for the commit history and bookkeeping of patches. |
98e5ecc
to
b3a666d
Compare
Starting build on |
Build failed on windows10/default. |
This reverts commit d5efd70. We are patching the automatic conversion to Python strings back in, so it's not necessary to Pythonize a `__str__` funciton implementing it in C++. Also, the `hasattr(foo, "___cpp__str")` caused a *huge* performance it in some cases, because looking up a non-existing attribute in cppyy can be quite expensive. All base classes are crawled too, and that invokes the interpreter and string manipulation.
The added script will be used to synchronize `cppyy` and `CPyCppyy`, applying some patches that are necessary for ROOT.
This was done with the `sync-upstream` script, introduced in the last commit.
Other than the `cppyy` Python library and the `CPyCppyy` CPython extension, the `cppyy-backend` can't easily be synchronized with upstream. The reason is that it depends both on patches to cling and to ROOT meta. There is no bookkeeping on the patches to ROOT meta which is complicating things, and the patches might also interfere with other ROOT functionality. A possible synchronization of ROOT meta is also not worth the effor for another reason: it will be replaced by libInterOp in the future in the context of cppyy and PyROOT. Furthermore, synchronizing the backend would not result in fixing any further reported ROOT issues. Therefore, only minimal changes were made to the `cppyy-backend` in the cppyy upgrade.
The reference count in Python is usually quite fragile to implementation changes, so it's not too surprising that some counts change with the `CPyCppyy` upgrade.
b3a666d
to
9c4418a
Compare
Starting build on |
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.
Thank you for this incredible piece of work! It's such a huge step towards the right direction! I believe this first PR is ready to be merged to move forward, but note the following comment.
I strongly believe we should have a similar approach as with our LLVM fork. We need to have some "source of truth" that is a certain cppyy/CPyCPPyy tag from upstream and then a clear way to reach the status of our fork from there, i.e. a series of patches that can be applied without conflicts. This PR goes in that direction but doesn't implement it fully as the sync script refers to a repository outside of our organisation. Ideally we would have separate repositories (one for cppyy and one for CPyCppyy) that we can refer to
@@ -77,7 +77,7 @@ def fn1(x): | |||
|
|||
self.assertTrue(hasattr(fn1, "__cpp_wrapper__")) | |||
self.assertTrue(type(fn1.__cpp_wrapper__) == str) | |||
self.assertEqual(sys.getrefcount(fn1.__cpp_wrapper__), 2) | |||
self.assertEqual(sys.getrefcount(fn1.__cpp_wrapper__), 3) |
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 are we even testing this? I believe it's not necessary and as your commit message rightly says, fragile. Let's just remove it
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'm not sure, I'm not familiar with the tests.
Right now things are quite stable with only this little change of the reference value, but if you agree that it can be removed I'm happy to do this as soon as the test fails somewhere again!
Thanks for raising this point. The situation will be improved in the next weeks, I'll try to get as many patches merged to upstream as possible. Then, based on how many differences are left, we can decide if we want to go with one (or multiple) separate repositories, or we stay with the patch files. |
Udate cppyy
Sister PR in
roottest
: root-project/roottest#1071Summary
Synchronizes the CPyCppyy CPython extension and cppyy Python library with upstream to fix bugs, add features, and avoid duplicate maintenance efforts.
Behavior changes
No implicit conversion from fixed-sized char buffers to null-terminated string
If you have a
char
buffer with constant size, people might use it for different things. For example, to store null-terminated short strings in a TTree. Therefore, the current PyROOT converts such buffers to Python strings. However, that means it's impossible to get the full buffer if it contains zeros, which can be useful if the buffer doesn't contain a string but for example some status bytes.Therefore, the used is not required to explicitly convert the buffer to a Python string with the
as_string()
method.Demo:
The output:
Associated GitHub issues
This will close the following GitHub issue:
std.vector
when using the wrong type #12230Upstream contributions to cppyy in the context of this synchronization
Utility::GetBuffer()
wlav/CPyCppyy#12std::string_view
converter and consider statefulness inInitializerListConverter
wlav/CPyCppyy#14CPPMethod::GetPrototype
wlav/CPyCppyy#16 (was in PyROOT before)CppyyLegacy
namespace in CPyCppyy optional wlav/CPyCppyy#18str
tochar[]
wlav/CPyCppyy#21control
flag to InstancePtrConverter wlav/CPyCppyy#22Performance validation
To validate the performance, I ran the Python tests in roottest and the PyROOT pythonization tests and compared runtimes with and without the cppyy upgrade. The total runtime of these tests reduced by about 4 % from 208 s to 287 s, so the performance impact of this PR is marginal. The runtime comparison for each test can be found in cppyy_upgrade_test_runtimes.txt.
The worst observed performance penalty is 24 %. However, significant speedups are observed in some of the longer tests. For convenience, the 20 tests with the longest runtime are listed here: