Show More
@@ -9,7 +9,7 b' import errno' | |||||
9 | from node import nullid |
|
9 | from node import nullid | |
10 | from i18n import _ |
|
10 | from i18n import _ | |
11 | import scmutil, util, ignore, osutil, parsers, encoding |
|
11 | import scmutil, util, ignore, osutil, parsers, encoding | |
12 | import os, stat, errno |
|
12 | import os, stat, errno, gc | |
13 |
|
13 | |||
14 | propertycache = util.propertycache |
|
14 | propertycache = util.propertycache | |
15 | filecache = scmutil.filecache |
|
15 | filecache = scmutil.filecache | |
@@ -285,7 +285,23 b' class dirstate(object):' | |||||
285 | if not st: |
|
285 | if not st: | |
286 | return |
|
286 | return | |
287 |
|
287 | |||
288 | p = parsers.parse_dirstate(self._map, self._copymap, st) |
|
288 | # Python's garbage collector triggers a GC each time a certain number | |
|
289 | # of container objects (the number being defined by | |||
|
290 | # gc.get_threshold()) are allocated. parse_dirstate creates a tuple | |||
|
291 | # for each file in the dirstate. The C version then immediately marks | |||
|
292 | # them as not to be tracked by the collector. However, this has no | |||
|
293 | # effect on when GCs are triggered, only on what objects the GC looks | |||
|
294 | # into. This means that O(number of files) GCs are unavoidable. | |||
|
295 | # Depending on when in the process's lifetime the dirstate is parsed, | |||
|
296 | # this can get very expensive. As a workaround, disable GC while | |||
|
297 | # parsing the dirstate. | |||
|
298 | gcenabled = gc.isenabled() | |||
|
299 | gc.disable() | |||
|
300 | try: | |||
|
301 | p = parsers.parse_dirstate(self._map, self._copymap, st) | |||
|
302 | finally: | |||
|
303 | if gcenabled: | |||
|
304 | gc.enable() | |||
289 | if not self._dirtypl: |
|
305 | if not self._dirtypl: | |
290 | self._pl = p |
|
306 | self._pl = p | |
291 |
|
307 |
General Comments 0
You need to be logged in to leave comments.
Login now