[PATCH] nogc: do disable gc for CPython
Jun Wu
quark at fb.com
Tue May 23 20:20:00 UTC 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1495570793 25200
# Tue May 23 13:19:53 2017 -0700
# Node ID 66dc3a3b4631507fed3ea7fd2fa3e3356ea820fe
# Parent 34e9b8b94f66db7ebe366f67cea7b64bd0ec6968
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 66dc3a3b4631
nogc: do disable gc for CPython
279cd8 makes util.nogc a no-op for Python >= 2.7. That's actually hurting
performance. For example, _fm1readmarkers takes 70ms with gc disabled, 190ms
with gc enabled.
This patch makes util.nogc effective for CPython and only a no-op for PyPy.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -910,9 +910,5 @@ def nogc(func):
into. As a workaround, disable GC while building complex (huge)
containers.
-
- This garbage collector issue have been fixed in 2.7.
"""
- if sys.version_info >= (2, 7):
- return func
def wrapper(*args, **kwargs):
gcenabled = gc.isenabled()
@@ -925,4 +921,9 @@ def nogc(func):
return wrapper
+if pyplatform.python_implementation() != 'CPython':
+ # PyPy becomes slower with gc disabled
+ def nogc(func):
+ return func
+
def pathto(root, n1, n2):
'''return the relative path from one place to another.
More information about the Mercurial-devel
mailing list