# HG changeset patch # User Pierre-Yves David # Date 2014-11-27 00:58:31 # Node ID 5817f71c233654fc21754978d9ce0fa8a6f65287 # Parent ee5a4ed4c8b1a1236c75ab699e1e34f86d4fe7c3 obsstore: disable garbage collection during initialization (issue4456) Python garbage collection is triggered by container creation. So code that creates a lot of tuples tends to trigger GC a lot. We disable the gc during obsolescence marker parsing and associated initialization. This provides an interesting speedup (25%). Load marker function on my 58758 markers repo: before: 0.468247 seconds after: 0.344362 seconds The benefit is a bit less visible overall. With python2.6 on my system I see: after: 0.60 before: 0.53 The difference is probably explained by the delaying of a costly GC. (but there is still a win). Marking involved tuples, lists and dicts as ignorable by the garbage collector should give us more benefit. But this is another adventure. Thanks goes to Siddharth Agarwal for the lead. diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -377,6 +377,7 @@ def _fm1encodeonemarker(marker): formats = {_fm0version: (_fm0readmarkers, _fm0encodeonemarker), _fm1version: (_fm1readmarkers, _fm1encodeonemarker)} +@util.nogc def _readmarkers(data): """Read and enumerate markers from raw data""" off = 0 @@ -562,6 +563,7 @@ class obsstore(object): version, markers = _readmarkers(data) return self.add(transaction, markers) + @util.nogc def _load(self, markers): for mark in markers: self._all.append(mark)