[PATCH] nogc: do disable gc for CPython

Jun Wu quark at fb.com
Wed May 24 17:07:25 EDT 2017


Excerpts from Gregory Szorc's message of 2017-05-23 18:03:53 -0700:
> Since this patch sounds like it has more to do with PyPy, then
> implementation should check for =pypy, not !=cpython. Other than that, I'm
> fine keeping the GC in place on PyPy, as its JIT should mitigate impact
> from garbage spewing code.

I'll change it to PyPy.

> Also, regarding this whole no gc concept, I'll argue that any operation
> needing to disable GC should be implemented in C in such a way that it
> isn't instantiating thousands of CPython objects. So many of our C routines
> are relatively slow (revlog index, obsmarkers, dag walking, etc) because
> they operate on PyObject instead of raw C data structures. If we remove
> PyObject from critical path code, we eliminate most GC concerns and likely
> make execution at *least* 5x faster.

There are multiple ways to solve perf issues. For obsmarkers, building an
index is a time complexity change that reduces O(N) to O(1-ish). It'll
greatly reduce object count. After that, constant time changes (like not
creating Python tuples) may become less important.

Regardless, this nogc stuff is an easy win restoring what we have before
279cd80059.


More information about the Mercurial-devel mailing list