comparison mercurial/pure/parsers.py @ 44333:50ad851efd9b

nodemap: introduce append-only incremental update of the persistent data Rewriting the full nodemap for each transaction has a cost we would like to avoid. We introduce a new way to write persistent nodemap data by adding new information at the end for file. Any new and updated block as added at the end of the file. The last block is the new root node. With this method, some of the block already on disk get "dereferenced" and become dead data. In later changesets, We'll start tracking the amount of dead data to eventually re-generate a full nodemap. Differential Revision: https://phab.mercurial-scm.org/D7886
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 15 Jan 2020 15:49:54 +0100
parents 671f9479af0e
children e41a164db7a9
comparison
equal deleted inserted replaced
44323:76a96e3a2bbb 44333:50ad851efd9b
154 154
155 The nodemap should be valid for the full set of revisions in the 155 The nodemap should be valid for the full set of revisions in the
156 index.""" 156 index."""
157 return nodemaputil.persistent_data(self) 157 return nodemaputil.persistent_data(self)
158 158
159 def nodemap_data_incremental(self):
160 """Return bytes containing a incremental update to persistent nodemap
161
162 This containst the data for an append-only update of the data provided
163 in the last call to `update_nodemap_data`.
164 """
165 if self._nm_root is None:
166 return None
167 data = nodemaputil.update_persistent_data(
168 self, self._nm_root, self._nm_max_idx, self._nm_rev
169 )
170 self._nm_root = self._nm_max_idx = self._nm_rev = None
171 return data
172
159 def update_nodemap_data(self, nm_data): 173 def update_nodemap_data(self, nm_data):
160 """provide full blokc of persisted binary data for a nodemap 174 """provide full blokc of persisted binary data for a nodemap
161 175
162 The data are expected to come from disk. See `nodemap_data_all` for a 176 The data are expected to come from disk. See `nodemap_data_all` for a
163 produceur of such data.""" 177 produceur of such data."""
164 if nm_data is not None: 178 if nm_data is not None:
165 nodemaputil.parse_data(nm_data) 179 self._nm_root, self._nm_max_idx = nodemaputil.parse_data(nm_data)
180 if self._nm_root:
181 self._nm_rev = len(self) - 1
182 else:
183 self._nm_root = self._nm_max_idx = self._nm_rev = None
166 184
167 185
168 class InlinedIndexObject(BaseIndexObject): 186 class InlinedIndexObject(BaseIndexObject):
169 def __init__(self, data, inline=0): 187 def __init__(self, data, inline=0):
170 self._data = data 188 self._data = data