Mercurial > public > mercurial-scm > hg
comparison mercurial/branchmap.py @ 24159:5b4ed033390b stable 3.3.1
revisionbranchcache: fall back to slow path if starting readonly (issue4531)
Transitioning to Mercurial versions with revision branch cache could be slow as
long as all operations were readonly (revset queries) and the cache would be
populated but not written back.
Instead, fall back to using the consistently slow path when readonly and the
cache doesn't exist yet. That avoids the overhead of populating the cache
without writing it back.
If not readonly, it will still populate all missing entries initially. That
avoids repeated writing of the cache file with small updates, and it also makes
sure a fully populated cache available for the readonly operations.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 06 Feb 2015 02:52:10 +0100 |
parents | 7cc77030c557 |
children | bb11081562d7 |
comparison
equal
deleted
inserted
replaced
24158:d414c28db84d | 24159:5b4ed033390b |
---|---|
328 branch and the last bit indicate that it is a branch close commit. | 328 branch and the last bit indicate that it is a branch close commit. |
329 The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i | 329 The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i |
330 and will grow with it but be 1/8th of its size. | 330 and will grow with it but be 1/8th of its size. |
331 """ | 331 """ |
332 | 332 |
333 def __init__(self, repo): | 333 def __init__(self, repo, readonly=True): |
334 assert repo.filtername is None | 334 assert repo.filtername is None |
335 self._names = [] # branch names in local encoding with static index | 335 self._names = [] # branch names in local encoding with static index |
336 self._rbcrevs = array('c') # structs of type _rbcrecfmt | 336 self._rbcrevs = array('c') # structs of type _rbcrecfmt |
337 self._rbcsnameslen = 0 | 337 self._rbcsnameslen = 0 |
338 try: | 338 try: |
340 self._rbcsnameslen = len(bndata) # for verification before writing | 340 self._rbcsnameslen = len(bndata) # for verification before writing |
341 self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')] | 341 self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')] |
342 except (IOError, OSError), inst: | 342 except (IOError, OSError), inst: |
343 repo.ui.debug("couldn't read revision branch cache names: %s\n" % | 343 repo.ui.debug("couldn't read revision branch cache names: %s\n" % |
344 inst) | 344 inst) |
345 if readonly: | |
346 # don't try to use cache - fall back to the slow path | |
347 self.branchinfo = self._branchinfo | |
348 | |
345 if self._names: | 349 if self._names: |
346 try: | 350 try: |
347 data = repo.vfs.read(_rbcrevs) | 351 data = repo.vfs.read(_rbcrevs) |
348 self._rbcrevs.fromstring(data) | 352 self._rbcrevs.fromstring(data) |
349 except (IOError, OSError), inst: | 353 except (IOError, OSError), inst: |