comparison mercurial/localrepo.py @ 44104:85c4cd73996b

localrepo: also fastpath access to working copy parents when possible If the filter level guarantee that the working copy parents will be visible, we allow fast path access to them. With this change multiple commands can now run without triggering filtering. After using the quick access mechanism introduced, the whole series results in pretty good performance gain: ``` All benchmarks: before after ratio [8e095512] [36b2f659] - 711?0.8ms 60.7?0.2ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 712?0.8ms 61.6?0.2ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 690?1ms 93.5?0.3ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 688?1ms 93.8?0.3ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 714?1ms 60.7?0.8ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 713?1ms 60.9?0.3ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 689?1ms 93.7?0.2ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 687?2ms 92.8?0.2ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 799?2ms 98.1?0.6ms 0.12 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 800?0.8ms 100.0?0.4ms 0.12 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 711?0.9ms 111?0.2ms 0.16 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 711?1ms 112?0.3ms 0.16 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 760?1ms 59.8?0.1ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 763?2ms 62.2?0.3ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 689?1ms 93.1?0.3ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 688?1ms 94.3?0.3ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 763?1ms 60.1?0.2ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 763?1ms 62.1?0.4ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 689?0.8ms 93.2?0.2ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 687?0.9ms 94.1?0.3ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] ``` Differential Revision: https://phab.mercurial-scm.org/D7492
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 17 Nov 2019 14:39:28 +0100
parents 2122ffa903ea
children d86dede17392
comparison
equal deleted inserted replaced
44103:2077ffede71f 44104:85c4cd73996b
1515 1515
1516 def setnarrowpats(self, newincludes, newexcludes): 1516 def setnarrowpats(self, newincludes, newexcludes):
1517 narrowspec.save(self, newincludes, newexcludes) 1517 narrowspec.save(self, newincludes, newexcludes)
1518 self.invalidate(clearfilecache=True) 1518 self.invalidate(clearfilecache=True)
1519 1519
1520 @util.propertycache 1520 @unfilteredpropertycache
1521 def _quick_access_changeid(self): 1521 def _quick_access_changeid_null(self):
1522 """an helper dictionnary for __getitem__ calls
1523
1524 This contains a list of symbol we can recognise right away without
1525 further processing.
1526 """
1527 return { 1522 return {
1528 b'null': (nullrev, nullid), 1523 b'null': (nullrev, nullid),
1529 nullrev: (nullrev, nullid), 1524 nullrev: (nullrev, nullid),
1530 nullid: (nullrev, nullid), 1525 nullid: (nullrev, nullid),
1531 } 1526 }
1527
1528 @unfilteredpropertycache
1529 def _quick_access_changeid_wc(self):
1530 # also fast path access to the working copy parents
1531 # however, only do it for filter that ensure wc is visible.
1532 quick = {}
1533 cl = self.unfiltered().changelog
1534 for node in self.dirstate.parents():
1535 if node == nullid:
1536 continue
1537 rev = cl.index.get_rev(node)
1538 if rev is None:
1539 # unknown working copy parent case:
1540 #
1541 # skip the fast path and let higher code deal with it
1542 continue
1543 pair = (rev, node)
1544 quick[rev] = pair
1545 quick[node] = pair
1546 return quick
1547
1548 @unfilteredmethod
1549 def _quick_access_changeid_invalidate(self):
1550 if '_quick_access_changeid_wc' in vars(self):
1551 del self.__dict__['_quick_access_changeid_wc']
1552
1553 @property
1554 def _quick_access_changeid(self):
1555 """an helper dictionnary for __getitem__ calls
1556
1557 This contains a list of symbol we can recognise right away without
1558 further processing.
1559 """
1560 mapping = self._quick_access_changeid_null
1561 if self.filtername in repoview.filter_has_wc:
1562 mapping = mapping.copy()
1563 mapping.update(self._quick_access_changeid_wc)
1564 return mapping
1532 1565
1533 def __getitem__(self, changeid): 1566 def __getitem__(self, changeid):
1534 # dealing with special cases 1567 # dealing with special cases
1535 if changeid is None: 1568 if changeid is None:
1536 return context.workingctx(self) 1569 return context.workingctx(self)
1885 def wjoin(self, f, *insidef): 1918 def wjoin(self, f, *insidef):
1886 return self.vfs.reljoin(self.root, f, *insidef) 1919 return self.vfs.reljoin(self.root, f, *insidef)
1887 1920
1888 def setparents(self, p1, p2=nullid): 1921 def setparents(self, p1, p2=nullid):
1889 self[None].setparents(p1, p2) 1922 self[None].setparents(p1, p2)
1923 self._quick_access_changeid_invalidate()
1890 1924
1891 def filectx(self, path, changeid=None, fileid=None, changectx=None): 1925 def filectx(self, path, changeid=None, fileid=None, changectx=None):
1892 """changeid must be a changeset revision, if specified. 1926 """changeid must be a changeset revision, if specified.
1893 fileid can be a file revision or node.""" 1927 fileid can be a file revision or node."""
1894 return context.filectx( 1928 return context.filectx(
2482 self._sparsesignaturecache.clear() 2516 self._sparsesignaturecache.clear()
2483 2517
2484 def invalidatevolatilesets(self): 2518 def invalidatevolatilesets(self):
2485 self.filteredrevcache.clear() 2519 self.filteredrevcache.clear()
2486 obsolete.clearobscaches(self) 2520 obsolete.clearobscaches(self)
2521 self._quick_access_changeid_invalidate()
2487 2522
2488 def invalidatedirstate(self): 2523 def invalidatedirstate(self):
2489 '''Invalidates the dirstate, causing the next call to dirstate 2524 '''Invalidates the dirstate, causing the next call to dirstate
2490 to check if it was modified since the last time it was read, 2525 to check if it was modified since the last time it was read,
2491 rereading it if it has. 2526 rereading it if it has.