Mercurial > hg
changeset 34934:6e66033f91cc stable
dirstate: avoid reading the map when possible (issue5713) (issue5717)
Before the recent refactor, we would not load the entire map until it was
accessed. As part of the refactor, that got lost and even just trying to load
the dirstate parents would load the whole map. This caused a perf regression
(issue5713) and a regression with static http serving (issue5717).
Making it lazy loaded again fixes both.
Differential Revision: https://phab.mercurial-scm.org/D1253
author | Durham Goode <durham@fb.com> |
---|---|
date | Thu, 26 Oct 2017 16:15:36 -0700 |
parents | 0217f75b6e59 |
children | ffeea2406276 |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 14 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Thu Oct 26 16:15:31 2017 -0700 +++ b/mercurial/dirstate.py Thu Oct 26 16:15:36 2017 -0700 @@ -129,7 +129,7 @@ def _map(self): '''Return the dirstate contents as a map from filename to (state, mode, size, time).''' - self._read() + self._map = dirstatemap(self._ui, self._opener, self._root) return self._map @property @@ -353,10 +353,6 @@ f.discard() raise - def _read(self): - self._map = dirstatemap(self._ui, self._opener, self._root) - self._map.read() - def invalidate(self): '''Causes the next access to reread the dirstate. @@ -1201,14 +1197,24 @@ self._root = root self._filename = 'dirstate' - self._map = {} - self.copymap = {} self._parents = None self._dirtyparents = False # for consistent view between _pl() and _read() invocations self._pendingmode = None + @propertycache + def _map(self): + self._map = {} + self.read() + return self._map + + @propertycache + def copymap(self): + self.copymap = {} + self._map + return self.copymap + def clear(self): self._map = {} self.copymap = {} @@ -1388,7 +1394,7 @@ @propertycache def identity(self): - self.read() + self._map return self.identity @propertycache