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
Add boost-histogram #2174
Add boost-histogram #2174
Conversation
e9e6a09
to
0cefb4b
Compare
0cefb4b
to
95f8bbf
Compare
53296db
to
aec9bb8
Compare
d4f623c
to
c832d65
Compare
There's a reproducer. ;) |
Thanks! |
4cfa25e
to
dbd5085
Compare
Ouch, during the rollout, we just discovered a bad regression in 1.3.0. Looks like there will be a 1.3.1 very soon; if this patch works, I can include it too, so we won't need a patch here. If you are curious as to what happens in pyodide when you get a segfault, I can tell you how to segfault 1.3.0. 🤦 |
I am interested if Pyodide doesn't give a fatal error message. wasm32_emscripten has no memory protection so if you try to dereference a bad pointer it won't instantly crash unless the pointer is larger than the total size of the memory. Likewise, dereferencing null works just fine. So we have to manually detect segfaults and report them otherwise the runtime will try to keep going after corrupting its state. There is some luck required, it is possible the bad memory access will never propagate into anything that causes a trap and will just lead to weird stuff. But in most cases an actual wasm trap occurs a bit later and we can notice it and kill the runtime. Any case like #2178 where we fail to do this is very interesting. |
Hmm okay that looks interesting, I'll have to reproduce it locally and see if I can improve our handling of these errors. Thanks so much for all your help! |
If it could turn into proper KeyError like in CPython (even for just the latest browsers), that would be ideal/amazing. :) |
Yeah, that'd be great. There's a similar issue with panic unwinds on #2081 which would also be nice to fix, though they may or may not be related. I will try to investigate this soon. |
Okay I think #2178 fixes all of the examples you've given of bad fatal errors. On that branch your segfault shows up as:
|
I figured out how to get the exception handling working. @henryiii should I push it here? It increases the size of the main Pyodide module by about 150kb or about 1%, which is probably acceptable. I am not sure about impact on benchmarks, will have to see if it causes a noticeable performance regression. |
That sounds fantastic for pybind11 libraries (and probably others). Can be here or another PR, I can combine both and try it out locally if needed. |
I think we can avoid any overhead in the main module other than the 150kb size increase. |
I've triggered the release of 1.3.1, will update here when the release happens (2-3 hours). The |
Does your work on exception handling help with the Rust panic unwinds, do you know? Also, does it fall back to the old behavior on older browsers? |
It will work correctly on all browsers -- I'm using the Javascript exceptions not the wasm exceptions because there isn't enough browser support for wasm exceptions still. I have not investigated how it relates to Rust. |
Okay, great. 1.3.1 is just out, so after this builds, I'll bump to 1.3.1 and add a test expecting |
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
I compared the benchmarks to the ones on the main branch and there is no apparent difference, so I think they support my claim that this change doesn't impose any cost on the main module. |
Is there something I need to rebuild? I'm trying this locally and I get: From what I understand (and from passing tests above), this should actually produce the Python error now ( |
20f7c81
to
720e24d
Compare
I think |
(I also just realized I don't need to be in the docker container to run |
From a simple copy-paste performance test, boost-histogram in the browser is 3.0x slower than native (python 3.10). For a 1D regularly binned histogram, boost-histogram in a browser still beats native NumPy by a few percent. 🤣 Native NumPy 1D histograming is 3.2x slower in the browser. 2D histograms are 1.8x slower in boost-histogram and 1.3x slower in NumPy (but there boost-histogram has a 10x starting lead). The numbers from time are oddly rounded, maybe there's a clock accuracy limitation? Looks like it stops at milliseconds, perhaps. |
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
See https://developer.mozilla.org/en-US/docs/Web/API/Performance/now:
|
Don't think that one's on me. But I've been wrong before. 🤣 |
No, that's a sporadic failure, I restarted CI. |
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
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.
Looks good to me, but ideally either @rth or @ryanking13 should review the changes I made to enable exceptions.
Thanks @henryiii it was fun working with you on this.
Note that my emscripten patch has been accepted: emscripten-core/emscripten#16309
In the corresponding issue the emscripten folks confirmed that this approach should not degrade performance in the main models.
Okay, I think what we should do is move the exception-related changes to the Makefiles over to #2178 and merge that first, then merge this. |
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.
Thanks, merging. |
Actually I think the best option is to add |
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com> Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
This reverts commit 30225d4.
Description
This adds boost-histogram, one of three key compiled libraries in the
Scikit-HEP ecosystem (and like all three, useful beyond HEP). It was featured
at SciPy 2020. The other two packages (iMinuit and Awkward) use setuptools CMake in the build
process, so might be more challenging to add.
I wasn't able to run the build again after updating to 1.3.0, since on updating
pyodide I now get:
when trying to build.
Pretty sure I didn't do that.Actually, I did, as I made a venv to put pyodide-build in.See #2167.
Checklists