Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline size estimates #113684

Merged
merged 4 commits into from
Jul 15, 2023
Merged

Conversation

nnethercote
Copy link
Contributor

Makes things nicer and a tiny bit faster.

r? @wesleywiser

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 14, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jul 14, 2023

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 14, 2023
@bors
Copy link
Contributor

bors commented Jul 14, 2023

⌛ Trying commit adcfd93f0aa9b387f91a10e9dc49c5dc189572a0 with merge eb0596b60545ce2c3ac92dd2aafb5713910aeca4...

@bors
Copy link
Contributor

bors commented Jul 14, 2023

☀️ Try build successful - checks-actions
Build commit: eb0596b60545ce2c3ac92dd2aafb5713910aeca4 (eb0596b60545ce2c3ac92dd2aafb5713910aeca4)

@rust-timer

This comment has been minimized.

@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 14, 2023

⌛ Trying commit f2d28cc15b1a20c5a5b93031eb5d3cf110c61497 with merge a861e61c1dc3fcf632860ee8946626d8945d9bd9...

@bors
Copy link
Contributor

bors commented Jul 14, 2023

☀️ Try build successful - checks-actions
Build commit: a861e61c1dc3fcf632860ee8946626d8945d9bd9 (a861e61c1dc3fcf632860ee8946626d8945d9bd9)

compiler/rustc_middle/src/mir/mono.rs Outdated Show resolved Hide resolved
Comment on lines +63 to +64
// "Normal" functions size estimate: the number of
// statements, plus one for the terminator.
Copy link
Member

@wesleywiser wesleywiser Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, seeing this code again reminded me of something that occurred to me while reading your recent blog post: should we have different size estimates for codegen with and without optimizations enabled?

I could believe this current estimate is relatively accurate for debug builds but many optimization passes in LLVM are non-linear with regards to the number of basic blocks. Perhaps it makes sense to use different estimation strategies when we are optimizing code and not optimizing code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried a variety of alternative estimation functions. #113047 and #113649 are two that I filed PRs for, and I've tried a bunch more locally. I can't say that I ever really saw meaningful differences between release and debug builds. Cleverer estimation functions have gotten me exactly zero wins at the moment, so I'm inclined to not spend more effort there :)

It replaces `(Linkage, Visibility)`, making the code nicer. Plus the
next commit will add another field.
This means we call `MonoItem::size_estimate` (which involves a query)
less often: just once per mono item, and then once more per inline item
placement. After that we can reuse the stored value as necessary. This
means `CodegenUnit::compute_size_estimate` is cheaper.
They're quite rare, and ignoring them simplifies things quite a bit, and
further reduces the number of calls to `MonoItem::size_estimate` to the
number of placed items (one per root item, and one or more per reachable
inlined item).
It doesn't seem worthwhile now that `MonoItem::size_estimate` is called
much less often.
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 14, 2023

⌛ Trying commit f4c4602 with merge bef6ff6...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (eb0596b60545ce2c3ac92dd2aafb5713910aeca4): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.3% [1.3%, 1.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 657.803s -> 657.535s (-0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 14, 2023
@nnethercote
Copy link
Contributor Author

@bors r=wesleywiser

@bors
Copy link
Contributor

bors commented Jul 15, 2023

📌 Commit f4c4602 has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2023
@bors
Copy link
Contributor

bors commented Jul 15, 2023

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing bef6ff6 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 15, 2023
@bors bors merged commit bef6ff6 into rust-lang:master Jul 15, 2023
11 checks passed
@rustbot rustbot added this to the 1.73.0 milestone Jul 15, 2023
@nnethercote nnethercote deleted the streamline-size-estimates branch July 15, 2023 01:48
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bef6ff6): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.8% [-6.1%, -1.8%] 3
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 657.64s -> 657.713s (0.01%)

@the8472
Copy link
Member

the8472 commented Jul 15, 2023

There has been a bors issue that lead to the merge commit of this PR getting purged from master.
You'll have to make a new PR to reapply it.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2023
…s-2, r=wesleywiser

Streamline size estimates (take 2)

This was merged in rust-lang#113684 but then [something happened](rust-lang#113684 (comment)):

> There has been a bors issue that lead to the merge commit of this PR getting purged from master.
> You'll have to make a new PR to reapply it.

So this is exactly the same changes.

`@bors` r=wesleywiser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants