[pypy-dev] fiber support
David Callahan
dcallahan at fb.com
Tue Oct 17 15:57:01 EDT 2017
Hi Maciej, thanks for the reply
I have been warned before about the performance of cpyext but we have hundreds of source dependencies and removing such reliance does not help us in the short term. Thus, performance is not a concern yet since we are not even at a point to run the code and know what is expensive and what is irrelevant.
At this point, it is not clear to me how to mimic this code using the cpyext later at all. Or if it is even necessary if PyPy has a different architecture for exception handling.
--david
On 10/17/17, 12:10 PM, "Maciej Fijalkowski" <fijall at gmail.com> wrote:
Hi David.
You're probably completely aware that such calls (using cpyext) would
completely kill performance, right? I didn't look in detail, but in
order to get performance, you would need to write such calls using
cffi.
Best regards,
Maciej Fijalkowski
On Mon, Oct 16, 2017 at 7:18 PM, David Callahan <dcallahan at fb.com> wrote:
> folly:fibers (https://github.com/facebook/folly/tree/master/folly/fibers )
> is a C++ package for lightweight, cooperatively scheduled threads. We have
> an application which extends this to CPython by adding the following
> save/restore code around task function invocation:
>
>
>
> auto tstate = PyThreadState_Get();
>
> CHECK_NOTNULL(tstate);
>
> auto savedFrame = tstate->frame;
>
> auto savedExcType = tstate->exc_type;
>
> auto savedExcValue = tstate->exc_value;
>
> auto savedExcTraceback = tstate->exc_traceback;
>
> func();
>
> tstate->frame = savedFrame;
>
> tstate->exc_type = savedExcType;
>
> tstate->exc_value = savedExcValue;
>
> tstate->exc_traceback = savedExcTraceback;
>
>
>
> (here func is a boost::python::object)
>
>
>
> This does not work in PyPy 5.9 immediately because the thread state object
> does not expose these fields nor are there accessor methods.
>
>
>
> Is there a way to get similar effect in PyPy?
>
>
>
> Thanks
>
> david
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.python.org_mailman_listinfo_pypy-2Ddev&d=DwIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=lFyiPUrFdOHdaobP7i4hoA&m=J_q51G31j5IKPKCE_2ZALuqBrWgdBs58pczmLTt_ml8&s=ZPehk3U44BJaOoWPII5iCNEv91mTCk_VoMR4Xq9Oh9k&e=
>
More information about the pypy-dev
mailing list