obscache: directly allocate zeroed bytearray
This is much faster that incrementally appending to it. On mozilla central
without obsolescence markers this move full cache building from 0.3s to nothing
visible.
--- a/hgext3rd/evolve/obscache.py Fri Jun 09 01:26:29 2017 +0100
+++ b/hgext3rd/evolve/obscache.py Fri Jun 09 01:39:42 2017 +0100
@@ -417,16 +417,18 @@
For now we stick to the simpler approach of paying the
performance cost on new changesets.
"""
- node = repo.changelog.node
- succs = repo.obsstore.successors
- for r in revs:
- if node(r) in succs:
- val = 1
- else:
- val = 0
- self._data.append(val)
- cl = repo.changelog
- assert len(self._data) == len(cl), (len(self._data), len(cl))
+ new_entries = bytearray(len(revs))
+ if not self._data:
+ self._setdata(new_entries)
+ else:
+ self._data.extend(new_entries)
+ data = self._data
+ if repo.obsstore:
+ node = repo.changelog.node
+ succs = repo.obsstore.successors
+ for r in revs:
+ if node(r) in succs:
+ data[r] = 1
def _updatemarkers(self, repo, obsmarkers):
"""update the cache with new markers"""