[PATCH] performance: disable workaround for an old bug of Python

Maciej Fijalkowski fijall at gmail.com
Fri Aug 12 17:42:38 EDT 2016


Well, seems the comment is out of date. I know the issue - the GC got
triggered every X objects in 2.6, which caused O(n^2) performance when
allocating lots of objects. These days (since 2.7) it adapts the
threshold, which means it always amortizes to O(n).

Either way, I don't care if we disable it for pypy or for cpython too.

On Thu, Aug 11, 2016 at 12:36 AM, Matt Mackall <mpm at selenic.com> wrote:
> On Wed, 2016-08-10 at 15:54 +0100, Jun Wu wrote:
>> I guess some mercurial code is depending on this for perf reasons -
>> disabling it would make things slower for CPython.
>
> To quote the comment from this function:
>
>     Python's garbage collector triggers a GC each time a certain number of
>     container objects (the number being defined by gc.get_threshold()) are
>     allocated even when marked not to be tracked by the collector. Tracking has
>     no effect on when GCs are triggered, only on what objects the GC looks
>     into. As a workaround, disable GC while building complex (huge)
>     containers.
>
>     This garbage collector issue have been fixed in 2.7.
>
> It's either fixed in 2.7 or it's not. The primary users of this code are
> dirstate and obsmarkers, so it should be pretty easy to test. This changeset has
> a benchmark:
>
> changeset:   25675:5817f71c2336
> user:        Pierre-Yves David <pierre-yves.david at fb.com>
> date:        Wed Nov 26 16:58:31 2014 -0800
> files:       mercurial/obsolete.py
> description:
> obsstore: disable garbage collection during initialization (issue4456)
>
> --
> Mathematics is the supreme nostalgia of our time.
>


More information about the Mercurial-devel mailing list