Comments
Patch
@@ -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
@@ -442,7 +442,6 @@
def _readmarkerversion(data):
return _unpack('>B', data[0:1])[0]
-@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]
-@util.nogc
def _addsuccessors(successors, markers):
for mark in markers:
successors.setdefault(mark[0], set()).add(mark)
-@util.nogc
def _addprecursors(precursors, markers):
for mark in markers:
for suc in mark[1]:
precursors.setdefault(suc, set()).add(mark)
-@util.nogc
def _addchildren(children, markers):
for mark in markers:
parents = mark[5]
@@ -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