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

The libcore.rlib size more than doubled since 1.47 #80245

Closed
tmiasko opened this issue Dec 20, 2020 · 7 comments
Closed

The libcore.rlib size more than doubled since 1.47 #80245

tmiasko opened this issue Dec 20, 2020 · 7 comments
Labels
A-simd Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. I-heavy Issue: Problems and improvements with respect to binary size of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@tmiasko
Copy link
Contributor

tmiasko commented Dec 20, 2020

The libcore.rlib size for x86_64-unknown-linux-gnu target:

Toolchain MB
nightly 76
nightly* 20
beta 48
1.48 47
1.47 36
1.46 29
1.45 29
1.44 28
1.43 27
1.42 27
1.41 27
1.40 28
1.39 26
1.38 26
1.37 27
1.36 27
1.35 27
1.34 27
1.33 26
1.32 26
1.31 26
nightly* = libcore without stdarch

diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 5b19bf6b80f..cc4344a30aa 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -284,7 +284,6 @@
 // `core_arch` depends on libcore, but the contents of this module are
 // set up in such a way that directly pulling it here works such that the
 // crate uses the this crate as its libcore.
-#[path = "../../stdarch/crates/core_arch/src/mod.rs"]
 #[allow(
     missing_docs,
     missing_debug_implementations,
@@ -297,7 +296,93 @@
 // merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
 #[allow(clashing_extern_declarations)]
 #[unstable(feature = "stdsimd", issue = "48556")]
-mod core_arch;
+mod core_arch {
+    pub mod arch {
+        #[stable(feature = "a", since = "1.0.0")]
+        pub mod x86 {
+            #[allow(non_camel_case_types)]
+            #[stable(feature = "a", since = "1.0.0")]
+            #[derive(Copy, Clone)]
+            pub struct __m128i;
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_pause() {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_set1_epi8(_: i8) -> __m128i {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_or_si128(_: __m128i, _: __m128i) -> __m128i {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_movemask_epi8(_: __m128i) -> i32 {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_load_si128(_: *const __m128i) -> __m128i {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_loadu_si128(_: *const __m128i) -> __m128i {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_store_si128(_: *mut __m128i, _: __m128i) {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_cmpeq_epi8(_: __m128i, _: __m128i) -> __m128i {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_cmpgt_epi8(_: __m128i, _: __m128i) -> __m128i {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _mm_setzero_si128() -> __m128i {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub fn has_cpuid() -> bool {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub struct CpuidResult {
+                /// EAX register.
+                #[stable(feature = "simd_x86", since = "1.27.0")]
+                pub eax: u32,
+                /// EBX register.
+                #[stable(feature = "simd_x86", since = "1.27.0")]
+                pub ebx: u32,
+                /// ECX register.
+                #[stable(feature = "simd_x86", since = "1.27.0")]
+                pub ecx: u32,
+                /// EDX register.
+                #[stable(feature = "simd_x86", since = "1.27.0")]
+                pub edx: u32,
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn __cpuid(_: u32) -> CpuidResult {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn __cpuid_count(_: u32, _: u32) -> CpuidResult {
+                todo!();
+            }
+            #[stable(feature = "a", since = "1.0.0")]
+            pub unsafe fn _xgetbv(_: u32) -> u64 {
+                todo!();
+            }
+        }
+        #[stable(feature = "a", since = "1.0.0")]
+        pub mod x86_64 {
+            #[stable(feature = "a", since = "1.0.0")]
+            pub use super::x86::*;
+        }
+    }
+}
 
 #[stable(feature = "simd_arch", since = "1.27.0")]
 pub use core_arch::arch;

@tmiasko tmiasko added the C-bug Category: This is a bug. label Dec 20, 2020
@camelid camelid added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 20, 2020
@camelid
Copy link
Member

camelid commented Dec 20, 2020

Not sure if this is a compiler-caused thing or not, so added both T-compiler and T-libs.

@camelid camelid added the I-heavy Issue: Problems and improvements with respect to binary size of generated code. label Dec 20, 2020
@camelid
Copy link
Member

camelid commented Dec 20, 2020

Maybe a lot of monomorphization happening?

@camelid
Copy link
Member

camelid commented Dec 20, 2020

Do we know how much of it is metadata, how much is MIR, how much is LLVM IR, and how much is object code? (Actually I'm not sure what things there are in an rlib – there don't seem to be docs on this.)

@jyn514
Copy link
Member

jyn514 commented Dec 20, 2020

I expect this has the same cause as the 40% compile time regression, which is the new avx512 intrinsics. https://hackmd.io/bm8_ygc8SFi64MWKZowhWw?both#Regressions

@camelid
Copy link
Member

camelid commented Dec 20, 2020

@jyn514 Is that #79938? I didn't see anything in the HackMD directly about AVX512.

@tmiasko
Copy link
Contributor Author

tmiasko commented Dec 20, 2020

Nightly -Zmeta-stats for core crate (items MIR accounts for 45.3 MB out of 72 MB):

with MIR without items MIR
dep bytes 0 0
lib feature bytes 10107 10107
lang item bytes 357 357
diagnostic item bytes 359 359
native bytes 0 0
source_map bytes 220553 220553
impl bytes 47150 47150
exp. symbols bytes 3636 3636
def-path table bytes 1193251 1193251
proc-macro-data-bytes 0 0
item bytes 60279879 19469482
table bytes 4545064 4545064
hygiene bytes 5775148 1274523
zero bytes 18454275 8444074
total bytes 72079395 26767993

@camelid camelid added the A-simd Area: SIMD (Single Instruction Multiple Data) label Dec 21, 2020
@tmiasko
Copy link
Contributor Author

tmiasko commented Jan 7, 2021

Closing in favour of rust-lang/stdarch#248.

@tmiasko tmiasko closed this as completed Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-simd Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. I-heavy Issue: Problems and improvements with respect to binary size of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants