changeset 42046:4ee906aa7b60

compression: introduce an official `format.revlog-compression` option This option supersedes the `experiment.format.compression` option. The value currently supported are zlib (default) and zstd (if Mercurial was compiled with zstd support). The option gained an explicit reference to `revlog` since this is the target usage here. Different storage methods might require different compression strategies. In our tests, using zstd give a significant CPU usage improvement (both compression and decompressing) while keeping similar repository size. Zstd as other interresting mode (dictionnary, pre-text, etc…) that are probably worth exploring. However, just plain switching from zlib to zstd provide a large benefit.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 27 Mar 2019 18:26:54 +0100
parents d7e751ec679e
children 715d3220ac4f
files mercurial/configitems.py mercurial/help/config.txt mercurial/localrepo.py mercurial/upgrade.py tests/test-repo-compengines.t
diffstat 5 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Tue Apr 02 11:03:46 2019 -0700
+++ b/mercurial/configitems.py	Wed Mar 27 18:26:54 2019 +0100
@@ -553,9 +553,6 @@
 coreconfigitem('experimental', 'extendedheader.similarity',
     default=False,
 )
-coreconfigitem('experimental', 'format.compression',
-    default='zlib',
-)
 coreconfigitem('experimental', 'graphshorten',
     default=False,
 )
@@ -684,6 +681,10 @@
 coreconfigitem('format', 'sparse-revlog',
     default=True,
 )
+coreconfigitem('format', 'revlog-compression',
+    default='zlib',
+    alias=[('experimental', 'format.compression')]
+)
 coreconfigitem('format', 'usefncache',
     default=True,
 )
--- a/mercurial/help/config.txt	Tue Apr 02 11:03:46 2019 -0700
+++ b/mercurial/help/config.txt	Wed Mar 27 18:26:54 2019 +0100
@@ -866,6 +866,13 @@
     Repositories with this on-disk format require Mercurial version 4.7
 
     Enabled by default.
+``revlog-compression``
+    Compression algorithm used by revlog. Supported value are `zlib` and `zstd`.
+    The `zlib` engine is the historical default of Mercurial. `zstd` is a newer
+    format that is usually a net win over `zlib` operating faster at better
+    compression rate. Use `zstd` to reduce CPU usage.
+
+    On some system, Mercurial installation may lack `zstd` supports. Default is `zlib`.
 
 ``graph``
 ---------
--- a/mercurial/localrepo.py	Tue Apr 02 11:03:46 2019 -0700
+++ b/mercurial/localrepo.py	Wed Mar 27 18:26:54 2019 +0100
@@ -2920,10 +2920,10 @@
             if ui.configbool('format', 'dotencode'):
                 requirements.add('dotencode')
 
-    compengine = ui.config('experimental', 'format.compression')
+    compengine = ui.config('format', 'revlog-compression')
     if compengine not in util.compengines:
         raise error.Abort(_('compression engine %s defined by '
-                            'experimental.format.compression not available') %
+                            'format.revlog-compression not available') %
                           compengine,
                           hint=_('run "hg debuginstall" to list available '
                                  'compression engines'))
--- a/mercurial/upgrade.py	Tue Apr 02 11:03:46 2019 -0700
+++ b/mercurial/upgrade.py	Wed Mar 27 18:26:54 2019 +0100
@@ -332,7 +332,7 @@
 
     @classmethod
     def fromconfig(cls, repo):
-        return repo.ui.config('experimental', 'format.compression')
+        return repo.ui.config('format', 'revlog-compression')
 
 @registerformatvariant
 class compressionlevel(formatvariant):
--- a/tests/test-repo-compengines.t	Tue Apr 02 11:03:46 2019 -0700
+++ b/tests/test-repo-compengines.t	Wed Mar 27 18:26:54 2019 +0100
@@ -21,8 +21,8 @@
 
 Unknown compression engine to format.compression aborts
 
-  $ hg --config experimental.format.compression=unknown init unknown
-  abort: compression engine unknown defined by experimental.format.compression not available
+  $ hg --config format.revlog-compression=unknown init unknown
+  abort: compression engine unknown defined by format.revlog-compression not available
   (run "hg debuginstall" to list available compression engines)
   [255]
 
@@ -40,7 +40,7 @@
 
 #if zstd
 
-  $ hg --config experimental.format.compression=zstd init zstd
+  $ hg --config format.revlog-compression=zstd init zstd
   $ cd zstd
   $ cat .hg/requires
   dotencode
@@ -66,7 +66,7 @@
 
   $ cd default
   $ touch bar
-  $ hg --config experimental.format.compression=zstd -q commit -A -m 'add bar with a lot of repeated repeated repeated text'
+  $ hg --config format.revlog-compression=zstd -q commit -A -m 'add bar with a lot of repeated repeated repeated text'
 
   $ cat .hg/requires
   dotencode
@@ -141,13 +141,13 @@
 checking zstd options
 =====================
 
-  $ hg init zstd-level-default --config experimental.format.compression=zstd
-  $ hg init zstd-level-1 --config experimental.format.compression=zstd
+  $ hg init zstd-level-default --config format.revlog-compression=zstd
+  $ hg init zstd-level-1 --config format.revlog-compression=zstd
   $ cat << EOF >> zstd-level-1/.hg/hgrc
   > [storage]
   > revlog.zstd.level=1
   > EOF
-  $ hg init zstd-level-22 --config experimental.format.compression=zstd
+  $ hg init zstd-level-22 --config format.revlog-compression=zstd
   $ cat << EOF >> zstd-level-22/.hg/hgrc
   > [storage]
   > revlog.zstd.level=22
@@ -172,7 +172,7 @@
 
 Test error cases
 
-  $ hg init zstd-level-invalid --config experimental.format.compression=zstd
+  $ hg init zstd-level-invalid --config format.revlog-compression=zstd
   $ cat << EOF >> zstd-level-invalid/.hg/hgrc
   > [storage]
   > revlog.zstd.level=foobar
@@ -182,7 +182,7 @@
   abort: storage.revlog.zstd.level is not a valid integer ('foobar')
   [255]
 
-  $ hg init zstd-level-out-of-range --config experimental.format.compression=zstd
+  $ hg init zstd-level-out-of-range --config format.revlog-compression=zstd
   $ cat << EOF >> zstd-level-out-of-range/.hg/hgrc
   > [storage]
   > revlog.zstd.level=42