rust/README.rst
changeset 46140 ec14c37958ec
parent 45614 7bd13bf99d1c
child 48296 4ee6b8b40787
equal deleted inserted replaced
46139:3ca5ca380a34 46140:ec14c37958ec
    38 ================
    38 ================
    39 
    39 
    40 You might want to check the `features` section in ``hg-cpython/Cargo.toml``.
    40 You might want to check the `features` section in ``hg-cpython/Cargo.toml``.
    41 It may contain features that might be interesting to try out.
    41 It may contain features that might be interesting to try out.
    42 
    42 
    43 To use features from the Makefile, use the `HG_RUST_FEATURES` environment 
    43 To use features from the Makefile, use the `HG_RUST_FEATURES` environment
    44 variable: for instance `HG_RUST_FEATURES="some-feature other-feature"`
    44 variable: for instance `HG_RUST_FEATURES="some-feature other-feature"`
    45 
    45 
    46 Profiling
    46 Profiling
    47 =========
    47 =========
    48 
    48 
    49 Setting the environment variable ``RUST_LOG=trace`` will make hg print
    49 Setting the environment variable ``RUST_LOG=trace`` will make hg print
    50 a few high level rust-related performance numbers. It can also
    50 a few high level rust-related performance numbers. It can also
    51 indicate why the rust code cannot be used (say, using lookarounds in
    51 indicate why the rust code cannot be used (say, using lookarounds in
    52 hgignore).
    52 hgignore).
    53 
    53 
       
    54 Creating a ``.cargo/config`` file with the following content enables
       
    55 debug information in optimized builds. This make profiles more informative
       
    56 with source file name and line number for Rust stack frames and
       
    57 (in some cases) stack frames for Rust functions that have been inlined.
       
    58 
       
    59   [profile.release]
       
    60   debug = true
       
    61 
    54 ``py-spy`` (https://github.com/benfred/py-spy) can be used to
    62 ``py-spy`` (https://github.com/benfred/py-spy) can be used to
    55 construct a single profile with rust functions and python functions
    63 construct a single profile with rust functions and python functions
    56 (as opposed to ``hg --profile``, which attributes time spent in rust
    64 (as opposed to ``hg --profile``, which attributes time spent in rust
    57 to some unlucky python code running shortly after the rust code, and
    65 to some unlucky python code running shortly after the rust code, and
    58 as opposed to tools for native code like ``perf``, which attribute
    66 as opposed to tools for native code like ``perf``, which attribute
    59 time to the python interpreter instead of python functions).
    67 time to the python interpreter instead of python functions).
       
    68 
       
    69 Example usage:
       
    70 
       
    71   $ make PURE=--rust local # Don't forget to recompile after a code change
       
    72   $ py-spy record --native --output /tmp/profile.svg -- ./hg ...
    60 
    73 
    61 Developing Rust
    74 Developing Rust
    62 ===============
    75 ===============
    63 
    76 
    64 The current version of Rust in use is ``1.41.1``, because it's what Debian
    77 The current version of Rust in use is ``1.41.1``, because it's what Debian