rust: introduce `dirstate-tree` cargo feature
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 30 Sep 2020 18:10:53 +0200
changeset 45609 e604a3c03ab9
parent 45608 423f17f94f35
child 45610 496537c9c1b4
rust: introduce `dirstate-tree` cargo feature This feature gates (at compile-time) the use of the newly-added dirstate tree. The motivation for this is that the dirstate tree is currently *very* slow; replacing the current hashmap-based dirstate is not a viable solution in terms of performance... and why would you be using the Rust implementation if not for performance? The feature will also help reviewers better understand the differences that will slowly appear as the dirstate tree gets better. Differential Revision: https://phab.mercurial-scm.org/D9132
Makefile
contrib/heptapod-ci.yml
rust/README.rst
rust/hg-core/Cargo.toml
rust/hg-core/src/dirstate.rs
rust/hg-cpython/Cargo.toml
--- a/Makefile	Wed Sep 30 18:23:43 2020 +0200
+++ b/Makefile	Wed Sep 30 18:10:53 2020 +0200
@@ -133,7 +133,7 @@
 rust-tests:
 	cd $(HGROOT)/rust/hg-cpython \
 		&& $(CARGO) test --quiet --all \
-			--no-default-features --features "$(py_feature)"
+			--no-default-features --features "$(py_feature) $(HG_RUST_FEATURES)"
 
 check-code:
 	hg manifest | xargs python contrib/check-code.py
--- a/contrib/heptapod-ci.yml	Wed Sep 30 18:23:43 2020 +0200
+++ b/contrib/heptapod-ci.yml	Wed Sep 30 18:10:53 2020 +0200
@@ -41,6 +41,12 @@
     variables:
         PYTHON: python3
 
+rust-cargo-test-py3-dirstate-tree:
+    <<: *rust_cargo_test
+    variables:
+        PYTHON: python3
+        HG_RUST_FEATURES: dirstate-tree
+
 test-py2:
     <<: *runtests
     variables:
@@ -82,6 +88,15 @@
         PYTHON: python3
         TEST_HGMODULEPOLICY: "rust+c"
 
+test-py3-rust-dirstate-tree:
+    <<: *runtests
+    variables:
+        HGWITHRUSTEXT: cpython
+        RUNTEST_ARGS: "--rust --blacklist /tmp/check-tests.txt"
+        PYTHON: python3
+        TEST_HGMODULEPOLICY: "rust+c"
+        HG_RUST_FEATURES: "dirstate-tree"
+
 test-py2-chg:
     <<: *runtests
     variables:
--- a/rust/README.rst	Wed Sep 30 18:23:43 2020 +0200
+++ b/rust/README.rst	Wed Sep 30 18:10:53 2020 +0200
@@ -34,6 +34,15 @@
 One day we may use this environment variable to switch to new experimental
 binding crates like a hypothetical ``HGWITHRUSTEXT=hpy``.
 
+Special features
+================
+
+You might want to check the `features` section in ``hg-cpython/Cargo.toml``.
+It may contain features that might be interesting to try out.
+
+To use features from the Makefile, use the `HG_RUST_FEATURES` environment 
+variable: for instance `HG_RUST_FEATURES="some-feature other-feature"`
+
 Profiling
 =========
 
--- a/rust/hg-core/Cargo.toml	Wed Sep 30 18:23:43 2020 +0200
+++ b/rust/hg-core/Cargo.toml	Wed Sep 30 18:10:53 2020 +0200
@@ -40,3 +40,9 @@
 clap = "*"
 pretty_assertions = "0.6.1"
 tempfile = "3.1.0"
+
+[features]
+# Use a (still unoptimized) tree for the dirstate instead of the current flat
+# dirstate. This is not yet recommended for performance reasons. A future
+# version might make it the default, or make it a runtime option.
+dirstate-tree = []
--- a/rust/hg-core/src/dirstate.rs	Wed Sep 30 18:23:43 2020 +0200
+++ b/rust/hg-core/src/dirstate.rs	Wed Sep 30 18:10:53 2020 +0200
@@ -11,6 +11,7 @@
 
 pub mod dirs_multiset;
 pub mod dirstate_map;
+#[cfg(feature = "dirstate-tree")]
 pub mod dirstate_tree;
 pub mod parsers;
 pub mod status;
--- a/rust/hg-cpython/Cargo.toml	Wed Sep 30 18:23:43 2020 +0200
+++ b/rust/hg-cpython/Cargo.toml	Wed Sep 30 18:10:53 2020 +0200
@@ -10,6 +10,7 @@
 
 [features]
 default = ["python27"]
+dirstate-tree = ["hg-core/dirstate-tree"]
 
 # Features to build an extension module:
 python27 = ["cpython/python27-sys", "cpython/extension-module-2-7"]