##// END OF EJS Templates
nodemap: display percentage of unused in `hg debugnodemap`...
marmoute -
r45125:99ea74cb default
parent child Browse files
Show More
@@ -2146,6 +2146,8 b' def debugnodemap(ui, repo, **opts):'
2146 ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
2146 ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
2147 ui.write((b"data-length: %d\n") % docket.data_length)
2147 ui.write((b"data-length: %d\n") % docket.data_length)
2148 ui.write((b"data-unused: %d\n") % docket.data_unused)
2148 ui.write((b"data-unused: %d\n") % docket.data_unused)
2149 unused_perc = docket.data_unused * 100.0 / docket.data_length
2150 ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
2149
2151
2150
2152
2151 @command(
2153 @command(
@@ -102,6 +102,9 b' class _NoTransaction(object):'
102 def add(self, *args, **kwargs):
102 def add(self, *args, **kwargs):
103 pass
103 pass
104
104
105 def addabort(self, *args, **kwargs):
106 pass
107
105
108
106 def update_persistent_nodemap(revlog):
109 def update_persistent_nodemap(revlog):
107 """update the persistent nodemap right now
110 """update the persistent nodemap right now
@@ -171,7 +174,17 b' def _persist_nodemap(tr, revlog, pending'
171 data = persistent_data(revlog.index)
174 data = persistent_data(revlog.index)
172 # EXP-TODO: if this is a cache, this should use a cache vfs, not a
175 # EXP-TODO: if this is a cache, this should use a cache vfs, not a
173 # store vfs
176 # store vfs
174 tr.add(datafile, 0)
177
178 tryunlink = revlog.opener.tryunlink
179
180 def abortck(tr):
181 tryunlink(datafile)
182
183 callback_id = b"delete-%s" % datafile
184
185 # some flavor of the transaction abort does not cleanup new file, it
186 # simply empty them.
187 tr.addabort(callback_id, abortck)
175 with revlog.opener(datafile, b'w+') as fd:
188 with revlog.opener(datafile, b'w+') as fd:
176 fd.write(data)
189 fd.write(data)
177 if feed_data:
190 if feed_data:
@@ -198,9 +211,6 b' def _persist_nodemap(tr, revlog, pending'
198 if feed_data:
211 if feed_data:
199 revlog.index.update_nodemap_data(target_docket, new_data)
212 revlog.index.update_nodemap_data(target_docket, new_data)
200
213
201 # EXP-TODO: if the transaction abort, we should remove the new data and
202 # reinstall the old one.
203
204 # search for old index file in all cases, some older process might have
214 # search for old index file in all cases, some older process might have
205 # left one behind.
215 # left one behind.
206 olds = _other_rawdata_filepath(revlog, target_docket)
216 olds = _other_rawdata_filepath(revlog, target_docket)
@@ -17,6 +17,7 b' Test the persistent on-disk nodemap'
17 tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
17 tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
18 data-length: 122880
18 data-length: 122880
19 data-unused: 0
19 data-unused: 0
20 data-unused: 0.000%
20 $ f --size .hg/store/00changelog.n
21 $ f --size .hg/store/00changelog.n
21 .hg/store/00changelog.n: size=70
22 .hg/store/00changelog.n: size=70
22
23
@@ -99,6 +100,7 b' add a new commit'
99 tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
100 tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
100 data-length: 122880
101 data-length: 122880
101 data-unused: 0
102 data-unused: 0
103 data-unused: 0.000%
102 #else
104 #else
103 $ hg debugnodemap --metadata
105 $ hg debugnodemap --metadata
104 uid: ???????????????? (glob)
106 uid: ???????????????? (glob)
@@ -106,6 +108,7 b' add a new commit'
106 tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
108 tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
107 data-length: 123072
109 data-length: 123072
108 data-unused: 192
110 data-unused: 192
111 data-unused: 0.156%
109 #endif
112 #endif
110
113
111 $ f --size .hg/store/00changelog.n
114 $ f --size .hg/store/00changelog.n
@@ -154,6 +157,7 b' Test code path without mmap'
154 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
157 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
155 data-length: 123328
158 data-length: 123328
156 data-unused: 384
159 data-unused: 384
160 data-unused: 0.311%
157 $ f --sha256 .hg/store/00changelog-*.nd --size
161 $ f --sha256 .hg/store/00changelog-*.nd --size
158 .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
162 .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
159 #endif
163 #endif
@@ -164,6 +168,7 b' Test code path without mmap'
164 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
168 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
165 data-length: 123328
169 data-length: 123328
166 data-unused: 384
170 data-unused: 384
171 data-unused: 0.311%
167 $ f --sha256 .hg/store/00changelog-*.nd --size
172 $ f --sha256 .hg/store/00changelog-*.nd --size
168 .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
173 .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
169 #endif
174 #endif
@@ -174,6 +179,7 b' Test code path without mmap'
174 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
179 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
175 data-length: 122944
180 data-length: 122944
176 data-unused: 0
181 data-unused: 0
182 data-unused: 0.000%
177 $ f --sha256 .hg/store/00changelog-*.nd --size
183 $ f --sha256 .hg/store/00changelog-*.nd --size
178 .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
184 .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
179 #endif
185 #endif
@@ -190,6 +196,7 b' Test force warming the cache'
190 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
196 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
191 data-length: 122944
197 data-length: 122944
192 data-unused: 0
198 data-unused: 0
199 data-unused: 0.000%
193 #else
200 #else
194 $ hg debugnodemap --metadata
201 $ hg debugnodemap --metadata
195 uid: ???????????????? (glob)
202 uid: ???????????????? (glob)
@@ -197,6 +204,7 b' Test force warming the cache'
197 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
204 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
198 data-length: 122944
205 data-length: 122944
199 data-unused: 0
206 data-unused: 0
207 data-unused: 0.000%
200 #endif
208 #endif
201
209
202 Check out of sync nodemap
210 Check out of sync nodemap
@@ -230,6 +238,9 b' If the nodemap is lagging behind, it can'
230 data-unused: 256 (pure !)
238 data-unused: 256 (pure !)
231 data-unused: 256 (rust !)
239 data-unused: 256 (rust !)
232 data-unused: 0 (no-rust no-pure !)
240 data-unused: 0 (no-rust no-pure !)
241 data-unused: 0.208% (pure !)
242 data-unused: 0.208% (rust !)
243 data-unused: 0.000% (no-rust no-pure !)
233 $ cp -f ../tmp-copies/* .hg/store/
244 $ cp -f ../tmp-copies/* .hg/store/
234 $ hg debugnodemap --metadata
245 $ hg debugnodemap --metadata
235 uid: ???????????????? (glob)
246 uid: ???????????????? (glob)
@@ -237,6 +248,7 b' If the nodemap is lagging behind, it can'
237 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
248 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
238 data-length: 122944
249 data-length: 122944
239 data-unused: 0
250 data-unused: 0
251 data-unused: 0.000%
240 $ hg log -r "$NODE" -T '{rev}\n'
252 $ hg log -r "$NODE" -T '{rev}\n'
241 5003
253 5003
242
254
@@ -271,6 +283,9 b' the nodemap should detect the changelog '
271 data-unused: 448 (pure !)
283 data-unused: 448 (pure !)
272 data-unused: 123904 (rust !)
284 data-unused: 123904 (rust !)
273 data-unused: 0 (no-pure no-rust !)
285 data-unused: 0 (no-pure no-rust !)
286 data-unused: 50.273% (rust !)
287 data-unused: 0.363% (pure !)
288 data-unused: 0.000% (no-pure no-rust !)
274
289
275 $ cp -f ../tmp-copies/* .hg/store/
290 $ cp -f ../tmp-copies/* .hg/store/
276 $ hg debugnodemap --metadata
291 $ hg debugnodemap --metadata
@@ -279,6 +294,7 b' the nodemap should detect the changelog '
279 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
294 tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
280 data-length: 122944
295 data-length: 122944
281 data-unused: 0
296 data-unused: 0
297 data-unused: 0.000%
282 $ hg log -r "$OTHERNODE" -T '{rev}\n'
298 $ hg log -r "$OTHERNODE" -T '{rev}\n'
283 5002
299 5002
284
300
@@ -296,6 +312,7 b' An up to date nodemap should be availabl'
296 tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
312 tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
297 data-length: 123008
313 data-length: 123008
298 data-unused: 0
314 data-unused: 0
315 data-unused: 0.000%
299 $ echo babar2 > babar
316 $ echo babar2 > babar
300 $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
317 $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
301 uid: ???????????????? (glob)
318 uid: ???????????????? (glob)
@@ -307,6 +324,9 b' An up to date nodemap should be availabl'
307 data-unused: 192 (pure !)
324 data-unused: 192 (pure !)
308 data-unused: 192 (rust !)
325 data-unused: 192 (rust !)
309 data-unused: 0 (no-pure no-rust !)
326 data-unused: 0 (no-pure no-rust !)
327 data-unused: 0.156% (pure !)
328 data-unused: 0.156% (rust !)
329 data-unused: 0.000% (no-pure no-rust !)
310 $ hg debugnodemap --metadata
330 $ hg debugnodemap --metadata
311 uid: ???????????????? (glob)
331 uid: ???????????????? (glob)
312 tip-rev: 5004
332 tip-rev: 5004
@@ -317,6 +337,9 b' An up to date nodemap should be availabl'
317 data-unused: 192 (pure !)
337 data-unused: 192 (pure !)
318 data-unused: 192 (rust !)
338 data-unused: 192 (rust !)
319 data-unused: 0 (no-pure no-rust !)
339 data-unused: 0 (no-pure no-rust !)
340 data-unused: 0.156% (pure !)
341 data-unused: 0.156% (rust !)
342 data-unused: 0.000% (no-pure no-rust !)
320
343
321 Another process does not see the pending nodemap content during run.
344 Another process does not see the pending nodemap content during run.
322
345
@@ -340,6 +363,9 b' Another process does not see the pending'
340 data-unused: 192 (pure !)
363 data-unused: 192 (pure !)
341 data-unused: 192 (rust !)
364 data-unused: 192 (rust !)
342 data-unused: 0 (no-pure no-rust !)
365 data-unused: 0 (no-pure no-rust !)
366 data-unused: 0.156% (pure !)
367 data-unused: 0.156% (rust !)
368 data-unused: 0.000% (no-pure no-rust !)
343 $ hg debugnodemap --metadata
369 $ hg debugnodemap --metadata
344 uid: ???????????????? (glob)
370 uid: ???????????????? (glob)
345 tip-rev: 5005
371 tip-rev: 5005
@@ -350,6 +376,9 b' Another process does not see the pending'
350 data-unused: 448 (pure !)
376 data-unused: 448 (pure !)
351 data-unused: 448 (rust !)
377 data-unused: 448 (rust !)
352 data-unused: 0 (no-pure no-rust !)
378 data-unused: 0 (no-pure no-rust !)
379 data-unused: 0.363% (pure !)
380 data-unused: 0.363% (rust !)
381 data-unused: 0.000% (no-pure no-rust !)
353
382
354 $ cat output.txt
383 $ cat output.txt
355
384
@@ -369,8 +398,15 b' Check that a failing transaction will pr'
369 uid: ???????????????? (glob)
398 uid: ???????????????? (glob)
370 tip-rev: 5005
399 tip-rev: 5005
371 tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
400 tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
372 data-length: 123584
401 data-length: 123584 (pure !)
373 data-unused: 448
402 data-length: 123584 (rust !)
403 data-length: 123136 (no-pure no-rust !)
404 data-unused: 448 (pure !)
405 data-unused: 448 (rust !)
406 data-unused: 0 (no-pure no-rust !)
407 data-unused: 0.363% (pure !)
408 data-unused: 0.363% (rust !)
409 data-unused: 0.000% (no-pure no-rust !)
374 $ f --size --sha256 .hg/store/00changelog-*.nd
410 $ f --size --sha256 .hg/store/00changelog-*.nd
375 .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
411 .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
376 .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
412 .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
General Comments 0
You need to be logged in to leave comments. Login now