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

Compile backtrace-related deps with opt-level=s #122462

Closed
wants to merge 1 commit into from

Conversation

erikdesjardins
Copy link
Contributor

Locally, this shrinks a stripped helloworld by 8k (~2%), which isn't huge but it's something.

I also tried opt-level=z but it produces the same result. opt-level=s is preferrable in that case since it inhibits fewer optimizations.

@rustbot
Copy link
Collaborator

rustbot commented Mar 13, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Mar 13, 2024
@erikdesjardins
Copy link
Contributor Author

After this, the largest functions in helloworld-tiny are

┌─────────────────────────────────────────────────────────────────────────────────────────────────┬────────────┐
│ Symbol                                                                                          │       Size │
├─────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ std::sys_common::backtrace::_print_fmt::{{closure}}                                             │  15.88 KiB │
│ std::backtrace_rs::symbolize::gimli::Context::new                                               │  14.28 KiB │
│ addr2line::ResUnit<R>::find_function_or_location::{{closure}}                                   │   9.41 KiB │
│ addr2line::Lines::parse                                                                         │   7.78 KiB │
│ miniz_oxide::inflate::core::decompress                                                          │   6.81 KiB │
│ std::backtrace_rs::symbolize::gimli::libs_dl_iterate_phdr::callback                             │   4.86 KiB │
│ gimli::read::unit::parse_attribute                                                              │   4.12 KiB │
│ miniz_oxide::inflate::core::REVERSED_BITS_LOOKUP                                                │      4 KiB │
│ main                                                                                            │   3.42 KiB │
│ addr2line::function::Function<R>::parse_children                                                │   3.27 KiB │
│ std::backtrace_rs::symbolize::SymbolName::new                                                   │   3.24 KiB │
│ gimli::read::line::DebugLine<R>::program                                                        │   3.23 KiB │
│ core::slice::sort::recurse                                                                      │   3.19 KiB │
│ <&T as core::fmt::Display>::fmt                                                                 │   3.16 KiB │
│ alloc::raw_vec::RawVec<T,A>::reserve_for_push                                                   │   2.81 KiB │
│ gimli::read::abbrev::AbbreviationsCache::get                                                    │   2.30 KiB │
│ gimli::read::line::parse_attribute                                                              │   2.27 KiB │
│ gimli::read::dwarf::Unit<R>::new                                                                │   2.27 KiB │
│ <&str as core::str::pattern::Pattern>::is_contained_in                                          │   2.11 KiB │
│ std::backtrace_rs::symbolize::gimli::elf::<impl std::backtrace_rs::symbolize::gimli::Mapping>::new_debug
                                                                                                  │   1.94 KiB │
│ rustc_demangle::v0::Printer::print_const                                                        │   1.89 KiB │
│ std::backtrace_rs::print::BacktraceFrameFmt::print_raw_with_column                              │   1.75 KiB │
...

Cargo.toml Outdated Show resolved Hide resolved
@Kobzol
Copy link
Contributor

Kobzol commented Mar 14, 2024

@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 Mar 14, 2024
@bors
Copy link
Contributor

bors commented Mar 14, 2024

⌛ Trying commit 03e7e9e with merge 2105cee...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2024
Compile backtrace-related deps with `opt-level=s`

Locally, this shrinks a stripped helloworld by 8k (~2%), which isn't huge but it's something.

I also tried `opt-level=z` but it produces the same result. `opt-level=s` is preferrable in that case since it inhibits fewer optimizations.
@bors
Copy link
Contributor

bors commented Mar 14, 2024

☀️ Try build successful - checks-actions
Build commit: 2105cee (2105ceeb0f23267f160392bd0e43b1c647590aac)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2105cee): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [0.2%, 1.9%] 7
Regressions ❌
(secondary)
1.0% [0.2%, 3.7%] 29
Improvements ✅
(primary)
-1.4% [-4.2%, -0.2%] 20
Improvements ✅
(secondary)
-1.2% [-3.6%, -0.6%] 10
All ❌✅ (primary) -0.7% [-4.2%, 1.9%] 27

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)
2.7% [1.4%, 4.0%] 2
Regressions ❌
(secondary)
2.6% [1.9%, 4.5%] 7
Improvements ✅
(primary)
-7.4% [-14.2%, -1.8%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.5% [-14.2%, 4.0%] 7

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)
2.1% [2.0%, 2.1%] 2
Regressions ❌
(secondary)
2.1% [1.8%, 3.1%] 7
Improvements ✅
(primary)
-3.0% [-6.1%, -1.0%] 10
Improvements ✅
(secondary)
-2.2% [-3.2%, -1.1%] 2
All ❌✅ (primary) -2.2% [-6.1%, 2.1%] 12

Binary size

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.2% [0.0%, 0.5%] 10
Regressions ❌
(secondary)
0.6% [0.6%, 0.6%] 3
Improvements ✅
(primary)
-1.7% [-9.6%, -0.0%] 63
Improvements ✅
(secondary)
-1.9% [-3.7%, -0.1%] 80
All ❌✅ (primary) -1.4% [-9.6%, 0.5%] 73

Bootstrap: 670.21s -> 668.391s (-0.27%)
Artifact size: 310.75 MiB -> 310.70 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 14, 2024
@erikdesjardins
Copy link
Contributor Author

Didn't expect the perf regressions to be so large, will investigate.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 14, 2024
@erikdesjardins
Copy link
Contributor Author

erikdesjardins commented Mar 14, 2024

Perf regressions for helloworld (./target/release/collector profile_local cachegrind +6f3eb1ce3d50246b2cbc5de3107c0f34889f5cc6 --rustc2 +2105ceeb0f23267f160392bd0e43b1c647590aac --include helloworld --profiles Opt --scenarios IncrUnchanged) seem to be mostly in the dynamic linker which is odd, since we don't dynamically link these backtrace crates. So I'm not sure why this would make the compiler itself slower to dynamically link.

--------------------------------------------------------------------------------
-- Function:file summary
--------------------------------------------------------------------------------
  Ir_____  function:file

> 458,404  _dl_lookup_symbol_x:
  411,604    ./elf/../sysdeps/generic/dl-new-hash.h
   46,800    ./elf/./elf/dl-lookup.c

> 203,746  <rustc_middle::ty::Ty as rustc_serialize::serialize::Decodable<rustc_metadata::rmeta::decoder::DecodeContext>>::decode:???

> 136,876  do_lookup_x:
  132,196    ./elf/./elf/dl-lookup.c
    2,600    ./elf/../sysdeps/generic/ldsodefs.h
    2,080    ./elf/../sysdeps/generic/dl-protected.h

> 103,302  _dl_addr:./elf/./elf/dl-addr.c

>  83,216  <rustc_middle::ty::context::CtxtInterners>::intern_ty:???

>  56,186  _dl_relocate_object:
   24,976    ./elf/./elf/dl-reloc.c
   15,630    ./elf/../sysdeps/x86_64/dl-machine.h
   14,011    ./elf/./elf/do-rel.h
    1,569    ./elf/../sysdeps/generic/ldsodefs.h

...

Locally, this shrinks a stripped helloworld by 8k (~2%),
which isn't huge but it's something.

I also tried `opt-level=z` but it produces the same result.
`opt-level=s` is preferrable in that case since it inhibits fewer
optimizations.
@bors
Copy link
Contributor

bors commented Apr 8, 2024

☔ The latest upstream changes (presumably #123608) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC Dylan-DPC added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 1, 2024
@Mark-Simulacrum
Copy link
Member

I think we are dynamically linking these crates? rustc uses a shared library for std today.

In any case I think this likely can't proceed given the regressions so I'm going to go ahead and close (but feel free to reopen if you want to invest in alternative designs etc).

@erikdesjardins erikdesjardins deleted the forsize branch May 6, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants