D8192: nodemap: display percentage of unused in `hg debugnodemap`

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

D8192: nodemap: display percentage of unused in `hg debugnodemap`

valentin.gatienbaron (Valentin Gatien-Baron)
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is useful to assess the density of the cache.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8192

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -17,6 +17,7 @@
   tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=70
 
@@ -99,6 +100,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -106,6 +108,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 123072
   data-unused: 192
+  data-unused: 0.156%
 #endif
 
   $ f --size .hg/store/00changelog.n
@@ -154,6 +157,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
 #endif
@@ -164,6 +168,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
 #endif
@@ -174,6 +179,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
 #endif
@@ -190,6 +196,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -197,6 +204,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #endif
 
 Check out of sync nodemap
@@ -230,6 +238,9 @@
   data-unused: 256 (pure !)
   data-unused: 256 (rust !)
   data-unused: 0 (no-rust no-pure !)
+  data-unused: 0.208% (pure !)
+  data-unused: 0.208% (rust !)
+  data-unused: 0.000% (no-rust no-pure !)
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -237,6 +248,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$NODE" -T '{rev}\n'
   5003
 
@@ -271,6 +283,9 @@
   data-unused: 448 (pure !)
   data-unused: 123904 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 50.273% (rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
@@ -279,6 +294,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$OTHERNODE" -T '{rev}\n'
   5002
 
@@ -296,6 +312,7 @@
   tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
   data-length: 123008
   data-unused: 0
+  data-unused: 0.000%
   $ echo babar2 > babar
   $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
   uid: ???????????????? (glob)
@@ -307,6 +324,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5004
@@ -317,6 +337,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
 Another process does not see the pending nodemap content during run.
 
@@ -340,6 +363,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5005
@@ -350,6 +376,9 @@
   data-unused: 448 (pure !)
   data-unused: 448 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cat output.txt
 
@@ -369,8 +398,15 @@
   uid: ???????????????? (glob)
   tip-rev: 5005
   tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
-  data-length: 123584
-  data-unused: 448
+  data-length: 123584 (pure !)
+  data-length: 123584 (rust !)
+  data-length: 123136 (no-pure no-rust !)
+  data-unused: 448 (pure !)
+  data-unused: 448 (rust !)
+  data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ f --size --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -102,6 +102,9 @@
     def add(self, *args, **kwargs):
         pass
 
+    def addabort(self, *args, **kwargs):
+        pass
+
 
 def update_persistent_nodemap(revlog):
     """update the persistent nodemap right now
@@ -171,7 +174,17 @@
             data = persistent_data(revlog.index)
         # EXP-TODO: if this is a cache, this should use a cache vfs, not a
         # store vfs
-        tr.add(datafile, 0)
+
+        tryunlink = revlog.opener.tryunlink
+
+        def abortck(tr):
+            tryunlink(datafile)
+
+        callback_id = b"delete-%s" % datafile
+
+        # some flavor of the transaction abort does not cleanup new file, it
+        # simply empty them.
+        tr.addabort(callback_id, abortck)
         with revlog.opener(datafile, b'w+') as fd:
             fd.write(data)
             if feed_data:
@@ -198,9 +211,6 @@
     if feed_data:
         revlog.index.update_nodemap_data(target_docket, new_data)
 
-    # EXP-TODO: if the transaction abort, we should remove the new data and
-    # reinstall the old one.
-
     # search for old index file in all cases, some older process might have
     # left one behind.
     olds = _other_rawdata_filepath(revlog, target_docket)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2144,6 +2144,8 @@
             ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
             ui.write((b"data-length: %d\n") % docket.data_length)
             ui.write((b"data-unused: %d\n") % docket.data_unused)
+            unused_perc = docket.data_unused * 100.0 / docket.data_length
+            ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
 
 
 @command(



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8192: nodemap: display percentage of unused in `hg debugnodemap`

valentin.gatienbaron (Valentin Gatien-Baron)
marmoute added a comment.
marmoute updated this revision to Diff 20438.


  simple rebase

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8192?vs=20395&id=20438

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8192/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8192

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -17,6 +17,7 @@
   tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=70
 
@@ -99,6 +100,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -106,6 +108,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 123072
   data-unused: 192
+  data-unused: 0.156%
 #endif
 
   $ f --size .hg/store/00changelog.n
@@ -154,6 +157,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
 #endif
@@ -164,6 +168,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
 #endif
@@ -174,6 +179,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
 #endif
@@ -190,6 +196,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -197,6 +204,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #endif
 
 Check out of sync nodemap
@@ -230,6 +238,9 @@
   data-unused: 256 (pure !)
   data-unused: 256 (rust !)
   data-unused: 0 (no-rust no-pure !)
+  data-unused: 0.208% (pure !)
+  data-unused: 0.208% (rust !)
+  data-unused: 0.000% (no-rust no-pure !)
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -237,6 +248,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$NODE" -T '{rev}\n'
   5003
 
@@ -271,6 +283,9 @@
   data-unused: 448 (pure !)
   data-unused: 123904 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 50.273% (rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
@@ -279,6 +294,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$OTHERNODE" -T '{rev}\n'
   5002
 
@@ -296,6 +312,7 @@
   tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
   data-length: 123008
   data-unused: 0
+  data-unused: 0.000%
   $ echo babar2 > babar
   $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
   uid: ???????????????? (glob)
@@ -307,6 +324,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5004
@@ -317,6 +337,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
 Another process does not see the pending nodemap content during run.
 
@@ -340,6 +363,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5005
@@ -350,6 +376,9 @@
   data-unused: 448 (pure !)
   data-unused: 448 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cat output.txt
 
@@ -369,8 +398,15 @@
   uid: ???????????????? (glob)
   tip-rev: 5005
   tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
-  data-length: 123584
-  data-unused: 448
+  data-length: 123584 (pure !)
+  data-length: 123584 (rust !)
+  data-length: 123136 (no-pure no-rust !)
+  data-unused: 448 (pure !)
+  data-unused: 448 (rust !)
+  data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ f --size --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -102,6 +102,9 @@
     def add(self, *args, **kwargs):
         pass
 
+    def addabort(self, *args, **kwargs):
+        pass
+
 
 def update_persistent_nodemap(revlog):
     """update the persistent nodemap right now
@@ -171,7 +174,17 @@
             data = persistent_data(revlog.index)
         # EXP-TODO: if this is a cache, this should use a cache vfs, not a
         # store vfs
-        tr.add(datafile, 0)
+
+        tryunlink = revlog.opener.tryunlink
+
+        def abortck(tr):
+            tryunlink(datafile)
+
+        callback_id = b"delete-%s" % datafile
+
+        # some flavor of the transaction abort does not cleanup new file, it
+        # simply empty them.
+        tr.addabort(callback_id, abortck)
         with revlog.opener(datafile, b'w+') as fd:
             fd.write(data)
             if feed_data:
@@ -198,9 +211,6 @@
     if feed_data:
         revlog.index.update_nodemap_data(target_docket, new_data)
 
-    # EXP-TODO: if the transaction abort, we should remove the new data and
-    # reinstall the old one.
-
     # search for old index file in all cases, some older process might have
     # left one behind.
     olds = _other_rawdata_filepath(revlog, target_docket)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2123,6 +2123,8 @@
             ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
             ui.write((b"data-length: %d\n") % docket.data_length)
             ui.write((b"data-unused: %d\n") % docket.data_unused)
+            unused_perc = docket.data_unused * 100.0 / docket.data_length
+            ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
 
 
 @command(



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8192: nodemap: display percentage of unused in `hg debugnodemap`

valentin.gatienbaron (Valentin Gatien-Baron)
In reply to this post by valentin.gatienbaron (Valentin Gatien-Baron)
marmoute added a comment.
marmoute updated this revision to Diff 20584.


  eventless rebase past D8255 <https://phab.mercurial-scm.org/D8255>

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8192?vs=20438&id=20584

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8192/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8192

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -17,6 +17,7 @@
   tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=70
 
@@ -99,6 +100,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -106,6 +108,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 123072
   data-unused: 192
+  data-unused: 0.156%
 #endif
 
   $ f --size .hg/store/00changelog.n
@@ -154,6 +157,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
 #endif
@@ -164,6 +168,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
 #endif
@@ -174,6 +179,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
 #endif
@@ -190,6 +196,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -197,6 +204,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #endif
 
 Check out of sync nodemap
@@ -230,6 +238,9 @@
   data-unused: 256 (pure !)
   data-unused: 256 (rust !)
   data-unused: 0 (no-rust no-pure !)
+  data-unused: 0.208% (pure !)
+  data-unused: 0.208% (rust !)
+  data-unused: 0.000% (no-rust no-pure !)
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -237,6 +248,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$NODE" -T '{rev}\n'
   5003
 
@@ -271,6 +283,9 @@
   data-unused: 448 (pure !)
   data-unused: 123904 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 50.273% (rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
@@ -279,6 +294,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$OTHERNODE" -T '{rev}\n'
   5002
 
@@ -296,6 +312,7 @@
   tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
   data-length: 123008
   data-unused: 0
+  data-unused: 0.000%
   $ echo babar2 > babar
   $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
   uid: ???????????????? (glob)
@@ -307,6 +324,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5004
@@ -317,6 +337,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
 Another process does not see the pending nodemap content during run.
 
@@ -340,6 +363,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5005
@@ -350,6 +376,9 @@
   data-unused: 448 (pure !)
   data-unused: 448 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cat output.txt
 
@@ -369,8 +398,15 @@
   uid: ???????????????? (glob)
   tip-rev: 5005
   tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
-  data-length: 123584
-  data-unused: 448
+  data-length: 123584 (pure !)
+  data-length: 123584 (rust !)
+  data-length: 123136 (no-pure no-rust !)
+  data-unused: 448 (pure !)
+  data-unused: 448 (rust !)
+  data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ f --size --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -102,6 +102,9 @@
     def add(self, *args, **kwargs):
         pass
 
+    def addabort(self, *args, **kwargs):
+        pass
+
 
 def update_persistent_nodemap(revlog):
     """update the persistent nodemap right now
@@ -171,7 +174,17 @@
             data = persistent_data(revlog.index)
         # EXP-TODO: if this is a cache, this should use a cache vfs, not a
         # store vfs
-        tr.add(datafile, 0)
+
+        tryunlink = revlog.opener.tryunlink
+
+        def abortck(tr):
+            tryunlink(datafile)
+
+        callback_id = b"delete-%s" % datafile
+
+        # some flavor of the transaction abort does not cleanup new file, it
+        # simply empty them.
+        tr.addabort(callback_id, abortck)
         with revlog.opener(datafile, b'w+') as fd:
             fd.write(data)
             if feed_data:
@@ -198,9 +211,6 @@
     if feed_data:
         revlog.index.update_nodemap_data(target_docket, new_data)
 
-    # EXP-TODO: if the transaction abort, we should remove the new data and
-    # reinstall the old one.
-
     # search for old index file in all cases, some older process might have
     # left one behind.
     olds = _other_rawdata_filepath(revlog, target_docket)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2125,6 +2125,8 @@
             ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
             ui.write((b"data-length: %d\n") % docket.data_length)
             ui.write((b"data-unused: %d\n") % docket.data_unused)
+            unused_perc = docket.data_unused * 100.0 / docket.data_length
+            ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
 
 
 @command(



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8192: nodemap: display percentage of unused in `hg debugnodemap`

valentin.gatienbaron (Valentin Gatien-Baron)
In reply to this post by valentin.gatienbaron (Valentin Gatien-Baron)
marmoute added a comment.
marmoute updated this revision to Diff 20687.


  rebase above latest default up to landed-D8182

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8192?vs=20584&id=20687

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8192/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8192

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -17,6 +17,7 @@
   tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=70
 
@@ -99,6 +100,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -106,6 +108,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 123072
   data-unused: 192
+  data-unused: 0.156%
 #endif
 
   $ f --size .hg/store/00changelog.n
@@ -154,6 +157,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
 #endif
@@ -164,6 +168,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
 #endif
@@ -174,6 +179,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
 #endif
@@ -190,6 +196,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -197,6 +204,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #endif
 
 Check out of sync nodemap
@@ -230,6 +238,9 @@
   data-unused: 256 (pure !)
   data-unused: 256 (rust !)
   data-unused: 0 (no-rust no-pure !)
+  data-unused: 0.208% (pure !)
+  data-unused: 0.208% (rust !)
+  data-unused: 0.000% (no-rust no-pure !)
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -237,6 +248,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$NODE" -T '{rev}\n'
   5003
 
@@ -271,6 +283,9 @@
   data-unused: 448 (pure !)
   data-unused: 123904 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 50.273% (rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
@@ -279,6 +294,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$OTHERNODE" -T '{rev}\n'
   5002
 
@@ -296,6 +312,7 @@
   tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
   data-length: 123008
   data-unused: 0
+  data-unused: 0.000%
   $ echo babar2 > babar
   $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
   uid: ???????????????? (glob)
@@ -307,6 +324,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5004
@@ -317,6 +337,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
 Another process does not see the pending nodemap content during run.
 
@@ -340,6 +363,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5005
@@ -350,6 +376,9 @@
   data-unused: 448 (pure !)
   data-unused: 448 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cat output.txt
 
@@ -369,8 +398,15 @@
   uid: ???????????????? (glob)
   tip-rev: 5005
   tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
-  data-length: 123584
-  data-unused: 448
+  data-length: 123584 (pure !)
+  data-length: 123584 (rust !)
+  data-length: 123136 (no-pure no-rust !)
+  data-unused: 448 (pure !)
+  data-unused: 448 (rust !)
+  data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ f --size --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -102,6 +102,9 @@
     def add(self, *args, **kwargs):
         pass
 
+    def addabort(self, *args, **kwargs):
+        pass
+
 
 def update_persistent_nodemap(revlog):
     """update the persistent nodemap right now
@@ -171,7 +174,17 @@
             data = persistent_data(revlog.index)
         # EXP-TODO: if this is a cache, this should use a cache vfs, not a
         # store vfs
-        tr.add(datafile, 0)
+
+        tryunlink = revlog.opener.tryunlink
+
+        def abortck(tr):
+            tryunlink(datafile)
+
+        callback_id = b"delete-%s" % datafile
+
+        # some flavor of the transaction abort does not cleanup new file, it
+        # simply empty them.
+        tr.addabort(callback_id, abortck)
         with revlog.opener(datafile, b'w+') as fd:
             fd.write(data)
             if feed_data:
@@ -198,9 +211,6 @@
     if feed_data:
         revlog.index.update_nodemap_data(target_docket, new_data)
 
-    # EXP-TODO: if the transaction abort, we should remove the new data and
-    # reinstall the old one.
-
     # search for old index file in all cases, some older process might have
     # left one behind.
     olds = _other_rawdata_filepath(revlog, target_docket)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2139,6 +2139,8 @@
             ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
             ui.write((b"data-length: %d\n") % docket.data_length)
             ui.write((b"data-unused: %d\n") % docket.data_unused)
+            unused_perc = docket.data_unused * 100.0 / docket.data_length
+            ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
 
 
 @command(



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8192: nodemap: display percentage of unused in `hg debugnodemap`

valentin.gatienbaron (Valentin Gatien-Baron)
In reply to this post by valentin.gatienbaron (Valentin Gatien-Baron)
marmoute updated this revision to Diff 20743.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8192?vs=20687&id=20743

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8192/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8192

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -17,6 +17,7 @@
   tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=70
 
@@ -99,6 +100,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -106,6 +108,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 123072
   data-unused: 192
+  data-unused: 0.156%
 #endif
 
   $ f --size .hg/store/00changelog.n
@@ -154,6 +157,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
 #endif
@@ -164,6 +168,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
 #endif
@@ -174,6 +179,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
 #endif
@@ -190,6 +196,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -197,6 +204,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #endif
 
 Check out of sync nodemap
@@ -230,6 +238,9 @@
   data-unused: 256 (pure !)
   data-unused: 256 (rust !)
   data-unused: 0 (no-rust no-pure !)
+  data-unused: 0.208% (pure !)
+  data-unused: 0.208% (rust !)
+  data-unused: 0.000% (no-rust no-pure !)
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -237,6 +248,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$NODE" -T '{rev}\n'
   5003
 
@@ -271,6 +283,9 @@
   data-unused: 448 (pure !)
   data-unused: 123904 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 50.273% (rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
@@ -279,6 +294,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$OTHERNODE" -T '{rev}\n'
   5002
 
@@ -296,6 +312,7 @@
   tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
   data-length: 123008
   data-unused: 0
+  data-unused: 0.000%
   $ echo babar2 > babar
   $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
   uid: ???????????????? (glob)
@@ -307,6 +324,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5004
@@ -317,6 +337,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
 Another process does not see the pending nodemap content during run.
 
@@ -340,6 +363,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5005
@@ -350,6 +376,9 @@
   data-unused: 448 (pure !)
   data-unused: 448 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cat output.txt
 
@@ -369,8 +398,15 @@
   uid: ???????????????? (glob)
   tip-rev: 5005
   tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
-  data-length: 123584
-  data-unused: 448
+  data-length: 123584 (pure !)
+  data-length: 123584 (rust !)
+  data-length: 123136 (no-pure no-rust !)
+  data-unused: 448 (pure !)
+  data-unused: 448 (rust !)
+  data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ f --size --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -102,6 +102,9 @@
     def add(self, *args, **kwargs):
         pass
 
+    def addabort(self, *args, **kwargs):
+        pass
+
 
 def update_persistent_nodemap(revlog):
     """update the persistent nodemap right now
@@ -171,7 +174,17 @@
             data = persistent_data(revlog.index)
         # EXP-TODO: if this is a cache, this should use a cache vfs, not a
         # store vfs
-        tr.add(datafile, 0)
+
+        tryunlink = revlog.opener.tryunlink
+
+        def abortck(tr):
+            tryunlink(datafile)
+
+        callback_id = b"delete-%s" % datafile
+
+        # some flavor of the transaction abort does not cleanup new file, it
+        # simply empty them.
+        tr.addabort(callback_id, abortck)
         with revlog.opener(datafile, b'w+') as fd:
             fd.write(data)
             if feed_data:
@@ -198,9 +211,6 @@
     if feed_data:
         revlog.index.update_nodemap_data(target_docket, new_data)
 
-    # EXP-TODO: if the transaction abort, we should remove the new data and
-    # reinstall the old one.
-
     # search for old index file in all cases, some older process might have
     # left one behind.
     olds = _other_rawdata_filepath(revlog, target_docket)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2146,6 +2146,8 @@
             ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
             ui.write((b"data-length: %d\n") % docket.data_length)
             ui.write((b"data-unused: %d\n") % docket.data_unused)
+            unused_perc = docket.data_unused * 100.0 / docket.data_length
+            ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
 
 
 @command(



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8192: nodemap: display percentage of unused in `hg debugnodemap`

valentin.gatienbaron (Valentin Gatien-Baron)
In reply to this post by valentin.gatienbaron (Valentin Gatien-Baron)
Closed by commit rHG99ea74cbed74: nodemap: display percentage of unused in `hg debugnodemap` (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8192?vs=20743&id=20934

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8192/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8192

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -17,6 +17,7 @@
   tip-node: 06ddac466af534d365326c13c3879f97caca3cb1
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=70
 
@@ -99,6 +100,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 122880
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -106,6 +108,7 @@
   tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49
   data-length: 123072
   data-unused: 192
+  data-unused: 0.156%
 #endif
 
   $ f --size .hg/store/00changelog.n
@@ -154,6 +157,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
 #endif
@@ -164,6 +168,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 123328
   data-unused: 384
+  data-unused: 0.311%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
 #endif
@@ -174,6 +179,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob)
 #endif
@@ -190,6 +196,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -197,6 +204,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
 #endif
 
 Check out of sync nodemap
@@ -230,6 +238,9 @@
   data-unused: 256 (pure !)
   data-unused: 256 (rust !)
   data-unused: 0 (no-rust no-pure !)
+  data-unused: 0.208% (pure !)
+  data-unused: 0.208% (rust !)
+  data-unused: 0.000% (no-rust no-pure !)
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
@@ -237,6 +248,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$NODE" -T '{rev}\n'
   5003
 
@@ -271,6 +283,9 @@
   data-unused: 448 (pure !)
   data-unused: 123904 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 50.273% (rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cp -f ../tmp-copies/* .hg/store/
   $ hg debugnodemap --metadata
@@ -279,6 +294,7 @@
   tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e
   data-length: 122944
   data-unused: 0
+  data-unused: 0.000%
   $ hg log -r "$OTHERNODE" -T '{rev}\n'
   5002
 
@@ -296,6 +312,7 @@
   tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf
   data-length: 123008
   data-unused: 0
+  data-unused: 0.000%
   $ echo babar2 > babar
   $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata"
   uid: ???????????????? (glob)
@@ -307,6 +324,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5004
@@ -317,6 +337,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
 Another process does not see the pending nodemap content during run.
 
@@ -340,6 +363,9 @@
   data-unused: 192 (pure !)
   data-unused: 192 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.156% (pure !)
+  data-unused: 0.156% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5005
@@ -350,6 +376,9 @@
   data-unused: 448 (pure !)
   data-unused: 448 (rust !)
   data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
 
   $ cat output.txt
 
@@ -369,8 +398,15 @@
   uid: ???????????????? (glob)
   tip-rev: 5005
   tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db
-  data-length: 123584
-  data-unused: 448
+  data-length: 123584 (pure !)
+  data-length: 123584 (rust !)
+  data-length: 123136 (no-pure no-rust !)
+  data-unused: 448 (pure !)
+  data-unused: 448 (rust !)
+  data-unused: 0 (no-pure no-rust !)
+  data-unused: 0.363% (pure !)
+  data-unused: 0.363% (rust !)
+  data-unused: 0.000% (no-pure no-rust !)
   $ f --size --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -102,6 +102,9 @@
     def add(self, *args, **kwargs):
         pass
 
+    def addabort(self, *args, **kwargs):
+        pass
+
 
 def update_persistent_nodemap(revlog):
     """update the persistent nodemap right now
@@ -171,7 +174,17 @@
             data = persistent_data(revlog.index)
         # EXP-TODO: if this is a cache, this should use a cache vfs, not a
         # store vfs
-        tr.add(datafile, 0)
+
+        tryunlink = revlog.opener.tryunlink
+
+        def abortck(tr):
+            tryunlink(datafile)
+
+        callback_id = b"delete-%s" % datafile
+
+        # some flavor of the transaction abort does not cleanup new file, it
+        # simply empty them.
+        tr.addabort(callback_id, abortck)
         with revlog.opener(datafile, b'w+') as fd:
             fd.write(data)
             if feed_data:
@@ -198,9 +211,6 @@
     if feed_data:
         revlog.index.update_nodemap_data(target_docket, new_data)
 
-    # EXP-TODO: if the transaction abort, we should remove the new data and
-    # reinstall the old one.
-
     # search for old index file in all cases, some older process might have
     # left one behind.
     olds = _other_rawdata_filepath(revlog, target_docket)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2146,6 +2146,8 @@
             ui.write((b"tip-node: %s\n") % hex(docket.tip_node))
             ui.write((b"data-length: %d\n") % docket.data_length)
             ui.write((b"data-unused: %d\n") % docket.data_unused)
+            unused_perc = docket.data_unused * 100.0 / docket.data_length
+            ui.write((b"data-unused: %2.3f%%\n") % unused_perc)
 
 
 @command(



To: marmoute, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel