changeset 51682:c10fa6388dbf

revlog: use an explicit config option to enable mmap usage for index We replace the `experimental.mmapindexthreshold` with two options: The `storage.revlog.mmap.index` is a boolean option to enable or disable the feature. The `storage.revlog.mmap.index:size-threshold` is a bytes option that control when we will be using mmap instead of plain reading.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 08 Jul 2024 17:02:27 +0200
parents 522b4d729e89
children 5f37c36f36b9
files mercurial/configitems.toml mercurial/helptext/config.txt mercurial/localrepo.py tests/test-revlog-mmapindex.t
diffstat 4 files changed, 32 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.toml	Thu Apr 11 00:02:07 2024 +0200
+++ b/mercurial/configitems.toml	Mon Jul 08 17:02:27 2024 +0200
@@ -987,10 +987,6 @@
 
 [[items]]
 section = "experimental"
-name = "mmapindexthreshold"
-
-[[items]]
-section = "experimental"
 name = "narrow"
 default = false
 
@@ -2167,6 +2163,16 @@
 
 [[items]]
 section = "storage"
+name = "revlog.mmap.index"
+default = false
+
+[[items]]
+section = "storage"
+name = "revlog.mmap.index:size-threshold"
+default = "1 MB"
+
+[[items]]
+section = "storage"
 name = "revlog.optimize-delta-parent-choice"
 default = true
 alias = [["format", "aggressivemergedeltas"]]
--- a/mercurial/helptext/config.txt	Thu Apr 11 00:02:07 2024 +0200
+++ b/mercurial/helptext/config.txt	Mon Jul 08 17:02:27 2024 +0200
@@ -2344,6 +2344,17 @@
         you do, consider talking with the mercurial developer community about your
         repositories.
 
+``revlog.mmap.index``
+    Whether to use the Operating System "memory mapping" feature (when
+    possible) to access the revlog index. This improves performance
+    and reduces memory pressure.
+
+.. container:: verbose
+
+    ``revlog.mmap.index:size-threshold``
+
+        The size of index above which to use the "memory mapping" feature.
+
 ``revlog.optimize-delta-parent-choice``
     When storing a merge revision, both parents will be equally considered as
     a possible delta base. This results in better delta selection and improved
--- a/mercurial/localrepo.py	Thu Apr 11 00:02:07 2024 +0200
+++ b/mercurial/localrepo.py	Mon Jul 08 17:02:27 2024 +0200
@@ -1123,9 +1123,11 @@
     if 0 <= chainspan:
         delta_config.max_deltachain_span = chainspan
 
-    mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
-    if mmapindexthreshold is not None:
-        data_config.mmap_index_threshold = mmapindexthreshold
+    if ui.configbool(b'storage', b'revlog.mmap.index'):
+        data_config.mmap_index_threshold = ui.configbytes(
+            b'storage',
+            b'revlog.mmap.index:size-threshold',
+        )
 
     withsparseread = ui.configbool(b'experimental', b'sparse-read')
     srdensitythres = float(
--- a/tests/test-revlog-mmapindex.t	Thu Apr 11 00:02:07 2024 +0200
+++ b/tests/test-revlog-mmapindex.t	Mon Jul 08 17:02:27 2024 +0200
@@ -36,7 +36,9 @@
   > EOF
 
 mmap index which is now more than 4k long
-  $ hg log -l 5 -T '{rev}\n' --config experimental.mmapindexthreshold=4k
+  $ hg log -l 5 -T '{rev}\n' \
+  >     --config storage.revlog.mmap.index=yes \
+  >     --config storage.revlog.mmap.index:size-threshold=4k
   mmapping $TESTTMP/a/.hg/store/00changelog.i (no-pure !)
   mmapping $TESTTMP/a/.hg/store/00changelog-????????.nd (glob) (rust !)
   100
@@ -46,7 +48,9 @@
   96
 
 do not mmap index which is still less than 32k
-  $ hg log -l 5 -T '{rev}\n' --config experimental.mmapindexthreshold=32k
+  $ hg log -l 5 -T '{rev}\n' \
+  >     --config storage.revlog.mmap.index=yes \
+  >     --config storage.revlog.mmap.index:size-threshold=32k
   mmapping $TESTTMP/a/.hg/store/00changelog-????????.nd (glob) (rust !)
   100
   99