D5438: rust-cpython: implementing Graph using C parents function

2018-12-27 Thread gracinet (Georges Racinet)
gracinet added a comment. @yuja, thanks for the queueing ! > Index could be backed by e.g. Rc> to allow any objects to own > copies, but I don't feel like this is a good design. If we want one day to have Mercurial work in a multi-threaded way, I guess that something like `Arc>`

D5438: rust-cpython: implementing Graph using C parents function

2018-12-24 Thread yuja (Yuya Nishihara)
yuja added a comment. > +/// # TODO find a solution to make it GIL safe again. > +/// > +/// This is non trivial, and can wait until we have a clearer picture with > +/// more Rust Mercurial constructs. > +/// > +/// One possibility would be to a `GILProtectedIndex` wrapper enclo

Re: D5438: rust-cpython: implementing Graph using C parents function

2018-12-24 Thread Yuya Nishihara
> +/// # TODO find a solution to make it GIL safe again. > +/// > +/// This is non trivial, and can wait until we have a clearer picture with > +/// more Rust Mercurial constructs. > +/// > +/// One possibility would be to a `GILProtectedIndex` wrapper enclosing > +/// a `Python<'p>` marker and hav

D5438: rust-cpython: implementing Graph using C parents function

2018-12-23 Thread gracinet (Georges Racinet)
This revision was automatically updated to reflect the committed changes. Closed by commit rHG4c25038c112c: rust-cpython: implement Graph using C parents function (authored by gracinet, committed by ). CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D5438?vs=12949&id=12967#toc REPOSITOR

D5438: rust-cpython: implementing Graph using C parents function

2018-12-22 Thread gracinet (Georges Racinet)
gracinet updated this revision to Diff 12949. gracinet edited the summary of this revision. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5438?vs=12875&id=12949 REVISION DETAIL https://phab.mercurial-scm.org/D5438 AFFECTED FILES mercurial/cext/revlog

D5438: rust-cpython: implementing Graph using C parents function

2018-12-17 Thread yuja (Yuya Nishihara)
yuja added a comment. > About protecting parents() with the GIL `Python<'p>`, I'll have to think more about it, but the solution that comes to mind is as you suggest a two-step wrapping: the long lived `Index` would wrap the actual index object and the function pointer retrieved from the c

Re: D5438: rust-cpython: implementing Graph using C parents function

2018-12-17 Thread Yuya Nishihara
> About protecting parents() with the GIL `Python<'p>`, I'll have to think > more about it, but the solution that comes to mind is as you suggest a > two-step wrapping: the long lived `Index` would wrap the actual index object > and the function pointer retrieved from the capsule, but would no

D5438: rust-cpython: implementing Graph using C parents function

2018-12-17 Thread gracinet (Georges Racinet)
gracinet added a comment. I gave the solution to reacquire the GIL explicitely from Index a quick try, without even releasing it from the callers (which is ok according to https://docs.python.org/2.7/c-api/init.html#c.PyGILState_Ensure), and it is more than a 20% penalty. I'm measuring

D5438: rust-cpython: implementing Graph using C parents function

2018-12-17 Thread gracinet (Georges Racinet)
gracinet added a comment. @yuja yes sorry, forgot to adapt to the new signature. That'll be fixed in next version, and in `revlog.c`, the capsule pointer declaration is now at the top. About protecting parents() with the GIL `Python<'p>`, I'll have to think more about it, but the soluti

D5438: rust-cpython: implementing Graph using C parents function

2018-12-15 Thread yuja (Yuya Nishihara)
yuja added a comment. > +type IndexParentsFn = unsafe extern "C" fn( > +index: *mut python_sys::PyObject, > +rev: ssize_t, > +ps: *mut [c_int; 2], > +max_rev: c_int, > +) -> c_int; The type differs from the private function. It's `int HgRevlogIndex_GetParen

Re: D5438: rust-cpython: implementing Graph using C parents function

2018-12-15 Thread Yuya Nishihara
> +type IndexParentsFn = unsafe extern "C" fn( > +index: *mut python_sys::PyObject, > +rev: ssize_t, > +ps: *mut [c_int; 2], > +max_rev: c_int, > +) -> c_int; The type differs from the private function. It's `int HgRevlogIndex_GetParents(PyObject *op, int rev, int *ps)`. > +impl G

D5438: rust-cpython: implementing Graph using C parents function

2018-12-15 Thread gracinet (Georges Racinet)
gracinet added a comment. Here, I'd be tempted to submit a `py_capsule_fn` macro to rust-cpython, but I guess it can wait. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5438 To: gracinet, #hg-reviewers Cc: durin42, kevincox, mercurial-devel ___

D5438: rust-cpython: implementing Graph using C parents function

2018-12-15 Thread gracinet (Georges Racinet)
gracinet created this revision. Herald added subscribers: mercurial-devel, kevincox, durin42. Herald added a reviewer: hg-reviewers. REVISION SUMMARY A pointer to the parents function is stored on the parsers C extension module as a capsule object. This is the recommended way to export a