Patchwork D9625: rust: document how to enable debug information in optimized builds

login
register
mail settings
Submitter phabricator
Date Dec. 17, 2020, 11:29 a.m.
Message ID <differential-rev-PHID-DREV-k2ifwvi62em4wmax4uhr-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47923/
State Superseded
Headers show

Comments

phabricator - Dec. 17, 2020, 11:29 a.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is particularly useful when profiling.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  .hgignore
  rust/README.rst

CHANGE DETAILS




To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/README.rst b/rust/README.rst
--- a/rust/README.rst
+++ b/rust/README.rst
@@ -40,7 +40,7 @@ 
 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 
+To use features from the Makefile, use the `HG_RUST_FEATURES` environment
 variable: for instance `HG_RUST_FEATURES="some-feature other-feature"`
 
 Profiling
@@ -51,6 +51,14 @@ 
 indicate why the rust code cannot be used (say, using lookarounds in
 hgignore).
 
+Creating a ``.cargo/config`` file with the following content enables
+debug information in optimized builds. This make profiles more informative
+with source file name and line number for Rust stack frames and
+(in some cases) stack frames for Rust functions that have been inlined.
+
+  [profile.release]
+  debug = true
+
 ``py-spy`` (https://github.com/benfred/py-spy) can be used to
 construct a single profile with rust functions and python functions
 (as opposed to ``hg --profile``, which attributes time spent in rust
@@ -58,6 +66,11 @@ 
 as opposed to tools for native code like ``perf``, which attribute
 time to the python interpreter instead of python functions).
 
+Example usage:
+
+  $ make PURE=--rust local # Don't forget to recompile after a code change
+  $ py-spy record --native --output /tmp/profile.svg -- ./hg ...
+
 Developing Rust
 ===============
 
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -64,6 +64,10 @@ 
 # Generated wheels
 wheelhouse/
 
+syntax: rootglob
+# See Profiling in rust/README.rst
+.cargo/config
+
 syntax: regexp
 ^\.pc/
 ^\.(pydev)?project