rust-nodemap: automatically use the rust index for persistent nodemap
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 18 Feb 2020 15:19:11 +0100
changeset 44513 e7fff9c3cdac
parent 44512 febe88a6f7f7
child 44514 15a033cabc19
rust-nodemap: automatically use the rust index for persistent nodemap The persistent nodemap requires the rust index to be used to provides any gains. So we automatically enable it for revlog using the persistent nodemap. We keep it off for other revset because now that the rust revlog fully initialise the nodemap using it everywhere introduce a fairly significant regression (eg: hg diff moving from 0.8s to 2.3s on mozilla-try) Differential Revision: https://phab.mercurial-scm.org/D8164
mercurial/revlog.py
tests/test-persistent-nodemap.t
--- a/mercurial/revlog.py	Tue Feb 18 18:32:55 2020 +0100
+++ b/mercurial/revlog.py	Tue Feb 18 15:19:11 2020 +0100
@@ -618,12 +618,19 @@
             and NodemapRevlogIO is not None
         )
 
+        use_rust_index = False
+        if rustrevlog is not None:
+            if self.nodemap_file is not None:
+                use_rust_index = True
+            else:
+                use_rust_index = self.opener.options.get(b'rust.index')
+
         self._io = revlogio()
         if self.version == REVLOGV0:
             self._io = revlogoldio()
         elif devel_nodemap:
             self._io = NodemapRevlogIO()
-        elif rustrevlog is not None and self.opener.options.get(b'rust.index'):
+        elif use_rust_index:
             self._io = rustrevlogio()
         try:
             d = self._io.parseindex(indexdata, self._inline)
--- a/tests/test-persistent-nodemap.t	Tue Feb 18 18:32:55 2020 +0100
+++ b/tests/test-persistent-nodemap.t	Tue Feb 18 15:19:11 2020 +0100
@@ -2,7 +2,6 @@
 Test the persistent on-disk nodemap
 ===================================
 
-
   $ hg init test-repo
   $ cd test-repo
   $ cat << EOF >> .hg/hgrc
@@ -26,6 +25,35 @@
   $ hg log -r "$ANYNODE" --template '{rev}\n'
   5000
 
+
+#if rust
+
+  $ f --sha256 .hg/store/00changelog-*.nd
+  .hg/store/00changelog-????????????????.nd: sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6 (glob)
+  $ hg debugnodemap --dump-new | f --sha256 --size
+  size=122880, sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6
+  $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size
+  size=122880, sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6
+  0000: 00 00 00 76 00 00 01 65 00 00 00 95 00 00 01 34 |...v...e.......4|
+  0010: 00 00 00 19 00 00 01 69 00 00 00 ab 00 00 00 4b |.......i.......K|
+  0020: 00 00 00 07 00 00 01 4c 00 00 00 f8 00 00 00 8f |.......L........|
+  0030: 00 00 00 c0 00 00 00 a7 00 00 00 89 00 00 01 46 |...............F|
+  0040: 00 00 00 92 00 00 01 bc 00 00 00 71 00 00 00 ac |...........q....|
+  0050: 00 00 00 af 00 00 00 b4 00 00 00 34 00 00 01 ca |...........4....|
+  0060: 00 00 00 23 00 00 01 45 00 00 00 2d 00 00 00 b2 |...#...E...-....|
+  0070: 00 00 00 56 00 00 01 0f 00 00 00 4e 00 00 02 4c |...V.......N...L|
+  0080: 00 00 00 e7 00 00 00 cd 00 00 01 5b 00 00 00 78 |...........[...x|
+  0090: 00 00 00 e3 00 00 01 8e 00 00 00 4f 00 00 00 b1 |...........O....|
+  00a0: 00 00 00 30 00 00 00 11 00 00 00 25 00 00 00 d2 |...0.......%....|
+  00b0: 00 00 00 ec 00 00 00 69 00 00 01 2b 00 00 01 2e |.......i...+....|
+  00c0: 00 00 00 aa 00 00 00 15 00 00 00 3a 00 00 01 4e |...........:...N|
+  00d0: 00 00 00 4d 00 00 00 9d 00 00 00 8e 00 00 00 a4 |...M............|
+  00e0: 00 00 00 c3 00 00 00 eb 00 00 00 29 00 00 00 ad |...........)....|
+  00f0: 00 00 01 3a 00 00 01 32 00 00 00 04 00 00 00 53 |...:...2.......S|
+
+
+#else
+
   $ f --sha256 .hg/store/00changelog-*.nd
   .hg/store/00changelog-????????????????.nd: sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 (glob)
   $ hg debugnodemap --dump-new | f --sha256 --size
@@ -48,6 +76,9 @@
   00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
   00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
   00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
+
+#endif
+
   $ hg debugnodemap --check
   revision in index:   5001
   revision in nodemap: 5001
@@ -60,19 +91,20 @@
   $ hg add foo
   $ hg ci -m 'foo'
 
-#if pure
+#if no-pure no-rust
+  $ hg debugnodemap --metadata
+  uid: ???????????????? (glob)
+  tip-rev: 5001
+  data-length: 122880
+  data-unused: 0
+#else
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5001
   data-length: 123072
   data-unused: 192
-#else
-  $ hg debugnodemap --metadata
-  uid: ???????????????? (glob)
-  tip-rev: 5001
-  data-length: 122880
-  data-unused: 0
 #endif
+
   $ f --size .hg/store/00changelog.n
   .hg/store/00changelog.n: size=42
 
@@ -81,11 +113,16 @@
 #if pure
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123072, sha256=136472751566c8198ff09e306a7d2f9bd18bd32298d614752b73da4d6df23340 (glob)
+#endif
 
-#else
+#if rust
+  $ f --sha256 .hg/store/00changelog-*.nd --size
+  .hg/store/00changelog-????????????????.nd: size=123072, sha256=ccc8a43310ace13812fcc648683e259346754ef934c12dd238cf9b7fadfe9a4b (glob)
+#endif
+
+#if no-pure no-rust
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=122880, sha256=bfafebd751c4f6d116a76a37a1dee2a251747affe7efbcc4f4842ccc746d4db9 (glob)
-
 #endif
 
   $ hg debugnodemap --check
@@ -115,8 +152,17 @@
   data-unused: 384
   $ f --sha256 .hg/store/00changelog-*.nd --size
   .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob)
-
-#else
+#endif
+#if rust
+  $ hg debugnodemap --metadata
+  uid: ???????????????? (glob)
+  tip-rev: 5002
+  data-length: 123328
+  data-unused: 384
+  $ f --sha256 .hg/store/00changelog-*.nd --size
+  .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob)
+#endif
+#if no-pure no-rust
   $ hg debugnodemap --metadata
   uid: ???????????????? (glob)
   tip-rev: 5002