rust-lang / rust-lang/rust

Significant application performance degradation when making a module public

Open
#128,730 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-codegen C-bug E-needs-mcve I-slow T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I've encountered an unexpected and significant performance degradation in my application when changing a module's visibility from private to public. This behavior seems counterintuitive and potentially indicates a compiler optimization issue or an unexpected interaction between module visibility and performance.

my code:

mod black:

source: https://github.com/hayden4r4/blackscholes-rust/blob/master/src/lets_be_rational/mod.rs#L8
benches: https://github.com/hayden4r4/blackscholes-rust/blob/master/benches/black.rs

Current behavior

When the black module is made public, the overall application performance degrades by approximately 50%.

Expected

Changing a module's visibility should not have a significant impact on the application's overall performance. We would expect minimal to no performance change when modifying module visibility.

Environment

Rust version: 1.80.0 (051478957 2024-07-21)
Cargo version: 1.80.0 (376290515 2024-07-16)
os: macos m1 max

Anyone may know where is the bug/problem/challange?

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 src/lets_be_rational/mod.rs at the cited module declaration and the benches/black.rs benchmark. Run the benchmark with the module private and public on the stated Rust and macOS environment, then inspect compiler output or profiling data to isolate the cause. Done means identifying whether this is a compiler optimization issue and documenting a reproducible result or fix direction.

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.