-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Reduce integer Display
implementation size
#133247
Reduce integer Display
implementation size
#133247
Conversation
Thanks! r=me with squash. |
75f1ff7
to
a991f25
Compare
@bors r=workingjubilee |
…lay-impl, r=workingjubilee Reduce integer `Display` implementation size I was thinking about rust-lang#128204 and how we could reduce the size of the code and just realized that we didn't need the `_fmt` method to be implemented on signed integers, which in turns allow to simplify greatly the macro call. r? `@workingjubilee`
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#131736 (Emscripten: link with -sWASM_BIGINT) - rust-lang#132207 (Store resolution for self and crate root module segments) - rust-lang#133153 (Add visits to nodes that already have flat_maps in ast::MutVisitor) - rust-lang#133218 (Implement `~const` item bounds in RPIT) - rust-lang#133228 (Rewrite `show_md_content_with_pager`) - rust-lang#133247 (Reduce integer `Display` implementation size) r? `@ghost` `@rustbot` modify labels: rollup
@bors r- |
81d470f
to
ab38c6d
Compare
@bors r=workingjubilee |
…lay-impl, r=workingjubilee Reduce integer `Display` implementation size I was thinking about rust-lang#128204 and how we could reduce the size of the code and just realized that we didn't need the `_fmt` method to be implemented on signed integers, which in turns allow to simplify greatly the macro call. r? `@workingjubilee`
? PR CI doesn't run library tests...? |
@bors r- |
#[cfg(feature = "optimize_for_size")] | ||
fn $gen_name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
// 2^128 is about 3*10^38, so 39 gives an extra byte of space | ||
let mut buf = [MaybeUninit::<u8>::uninit(); 39]; | ||
const SIZE: usize = $u::MAX.ilog(10) as usize + 1; | ||
let mut buf = [MaybeUninit::<u8>::uninit(); SIZE]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? What is the effect of this change on binary size? Or is $u
always the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On smaller targets, the maximum size might be of u32
and not u64
so since we're there... But on the binary size, there should be no difference for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, hopefully so.
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#131505 (use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on Darwin) - rust-lang#131859 (Update TRPL to add new Chapter 17: Async and Await) - rust-lang#132090 (Stop being so bail-y in candidate assembly) - rust-lang#132597 (btree: don't leak value if destructor of key panics) - rust-lang#132911 (Pretty print async fn sugar in opaques and trait bounds) - rust-lang#133159 (Don't allow `-Zunstable-options` to take a value ) - rust-lang#133247 (Reduce integer `Display` implementation size) - rust-lang#133286 (Re-delay a resolve `bug` related to `Self`-ctor in patterns) Failed merges: - rust-lang#133215 (Fix missing submodule in `./x vendor`) r? `@ghost` `@rustbot` modify labels: rollup
…lay-impl, r=workingjubilee Reduce integer `Display` implementation size I was thinking about rust-lang#128204 and how we could reduce the size of the code and just realized that we didn't need the `_fmt` method to be implemented on signed integers, which in turns allow to simplify greatly the macro call. r? ``@workingjubilee``
…lay-impl, r=workingjubilee Reduce integer `Display` implementation size I was thinking about rust-lang#128204 and how we could reduce the size of the code and just realized that we didn't need the `_fmt` method to be implemented on signed integers, which in turns allow to simplify greatly the macro call. r? `@workingjubilee`
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#127483 (Allow disabling ASan instrumentation for globals) - rust-lang#131505 (use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on Darwin) - rust-lang#132949 (Add specific diagnostic for using macro_rules macro as attribute/derive) - rust-lang#133247 (Reduce integer `Display` implementation size) - rust-lang#133286 (Re-delay a resolve `bug` related to `Self`-ctor in patterns) - rust-lang#133332 (Mark `<[T; N]>::as_mut_slice` with the `const` specifier.) - rust-lang#133366 (Remove unnecessary bool from `ExpectedFound::new`) Failed merges: - rust-lang#131859 (Update TRPL to add new Chapter 17: Async and Await) r? `@ghost` `@rustbot` modify labels: rollup
Failed in rollup on Unfortunately PR CI doesn't seem to run library tests Log failure example
|
@bors rollup=iffy |
I have no clue what's going on in this case... On 64 linux bits, I don't get this failure and I also don't understand how this failure can happen... |
library/core/src/fmt/num.rs
Outdated
} | ||
#[cfg(feature = "optimize_for_size")] | ||
{ | ||
return $gen_name((!self.unsigned_abs().$conv_fn()), *self >= 0, f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I think the !
shouldn't be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops.
30c7df6
to
0d4b52f
Compare
@GuillaumeGomez the trick about that CI job is here... locally I don't think one would ever write this, so yeah... rust/src/ci/docker/scripts/x86_64-gnu-llvm.sh Lines 37 to 39 in 6e1c115
It's not that std tests don't run in PR CI (they do), however here you have code guarded by rust/src/ci/docker/scripts/x86_64-gnu-llvm.sh Lines 21 to 22 in 6e1c115
|
Actually this PR intentionally tries to adjust code size, so |
The problem was indeed because I never tested with the |
Forgot to re-r+ it... @bors r=workingjubilee |
☀️ Test successful - checks-actions |
Finished benchmarking commit (7db7489): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary 0.1%)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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary -0.0%, secondary -0.1%)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.
Bootstrap: 797.447s -> 796.592s (-0.11%) |
I was thinking about #128204 and how we could reduce the size of the code and just realized that we didn't need the
_fmt
method to be implemented on signed integers, which in turns allow to simplify greatly the macro call.r? @workingjubilee