rust-lang / rust-lang/rust

Worse perf with NonZero

Open
#142,914 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-optimization S-needs-info T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

In https://github.com/rust-lang/literal-escaper/pull/15 I introduced NonZero into literal-escaper, but noticed perf regressions (on ARM).

On compiler explorer I noticed x86_64 asm differences that seem to indicate there may be a difference in inlining behavior: asm being generated without code differences in the surrounding code (does that not mean it is dead?). These can indeed be removed by uncommenting the commented #[inline] directives (top left pane). On arm, the changes are similar but more extensive and I can't tell whether extra function code is called or not.

Sprinkling the right #[inline] directives does remove the perf regressions on ARM. I haven't been able to do perf measurements on x86_64 yet.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with rust-lang/literal-escaper PR #15 and compare the compiler-explorer assembly in the linked x86_64 example, including the commented #[inline] directives. Investigate the corresponding ARM output and verify whether the generated extra function code is called or dead. Done means identifying the cause of the regression and confirming the effect with performance measurements on ARM and, if possible, x86_64.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.