[PATCH 2 of 6] util: drop the py26 garbage collector disabling hack
Matt Harbison
mharbison72 at gmail.com
Fri Jun 16 23:05:35 EDT 2017
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1497655633 14400
# Fri Jun 16 19:27:13 2017 -0400
# Node ID 1452c47128a707b930bb4cd3cea9e356ea40db39
# Parent 067742482ebea687d10f87d4139193961e293aa9
util: drop the py26 garbage collector disabling hack
This was doing nothing on 2.7+.
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -460,20 +460,7 @@
# on write.
self._map = parsers.dict_new_presized(len(st) / 71)
- # 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. parse_dirstate creates a tuple
- # for each file in the dirstate. The C version then immediately marks
- # them as not to be tracked by the collector. However, this has no
- # effect on when GCs are triggered, only on what objects the GC looks
- # into. This means that O(number of files) GCs are unavoidable.
- # Depending on when in the process's lifetime the dirstate is parsed,
- # this can get very expensive. As a workaround, disable GC while
- # parsing the dirstate.
- #
- # (we cannot decorate the function directly since it is in a C module)
- parse_dirstate = util.nogc(parsers.parse_dirstate)
- p = parse_dirstate(self._map, self._copymap, st)
+ p = parsers.parse_dirstate(self._map, self._copymap, st)
if not self._dirtypl:
self._pl = p
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -442,7 +442,6 @@
def _readmarkerversion(data):
return _unpack('>B', data[0:1])[0]
- at util.nogc
def _readmarkers(data):
"""Read and enumerate markers from raw data"""
diskversion = _readmarkerversion(data)
@@ -506,18 +505,15 @@
"""The flags field of the marker"""
return self._data[2]
- at util.nogc
def _addsuccessors(successors, markers):
for mark in markers:
successors.setdefault(mark[0], set()).add(mark)
- at util.nogc
def _addprecursors(precursors, markers):
for mark in markers:
for suc in mark[1]:
precursors.setdefault(suc, set()).add(mark)
- at util.nogc
def _addchildren(children, markers):
for mark in markers:
parents = mark[5]
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -903,30 +903,6 @@
def never(fn):
return False
-def nogc(func):
- """disable garbage collector
-
- 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.
- """
- if sys.version_info >= (2, 7):
- return func
- def wrapper(*args, **kwargs):
- gcenabled = gc.isenabled()
- gc.disable()
- try:
- return func(*args, **kwargs)
- finally:
- if gcenabled:
- gc.enable()
- return wrapper
-
def pathto(root, n1, n2):
'''return the relative path from one place to another.
root should use os.sep to separate directories
More information about the Mercurial-devel
mailing list