-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
instance_def_size_estimate is not that good at estimating #69382
Comments
the estimates here is also part of what I talked about in #64913 (comment) |
and when building with optimization (-O) even more functions have an estimated size of 0. tried to compile librustc_macros with -O and more then 71% of the functions hade 0 as estimated size so almost only the name of the function that affects what CGUs that gets merged. |
There is definitely room for improvement here. The size-estimate is just a rough heuristic to get rid of the worst kinds of LLVM work mis-schedulings. I think if we had something that predicated the number of LLVM instructions, that would probably be a big improvement. But first I would try to come up with proper requirements. What are the properties we need from a heuristic like this? It's probably more "compile-time impact" than "size" what we are interested in. And how does this interact with LLVM inlining, MIR inlining, etc. |
Triage: The instance estimates are still based on a total number of statements (a drop shim often consist entirely of drop terminators and receive estimate of zero). |
For example, drop glue generated for struct below, doesn't have any statements, only terminators. Previously it received an estimate of 0, the new estimate is 13 (6+5 drop terminators, +1 resume, +1 return). struct S { a: String, b: String, c: String, d: String, e: String, f: String, } Originally reported in rust-lang#69382 (comment)
…ebank Include terminators in instance size estimate For example, drop glue generated for struct below, doesn't have any statements, only terminators. Previously it received an estimate of 0, the new estimate is 13 (6+5 drop terminators, +1 resume, +1 return). ```rust struct S { a: String, b: String, c: String, d: String, e: String, f: String, } ``` Originally reported in rust-lang#69382 (comment)
Include terminators in instance size estimate For example, drop glue generated for struct below, doesn't have any statements, only terminators. Previously it received an estimate of 0, the new estimate is 13 (6+5 drop terminators, +1 resume, +1 return). ```rust struct S { a: String, b: String, c: String, d: String, e: String, f: String, } ``` Originally reported in rust-lang#69382 (comment)
when trying to see what the problem was with #66617
I noticed that the llvm-ir did not match the estimate e.g. core::ptr::drop_in_place
actual number of llvm-ir lines 17170 and the estimated size 24 so 715x larger then estimated.
this results in that when the CGUs shall be merged the CGU that contains these functions is merged multipel times and result in one CGU that is mush larger then the other and due to this the compile time is longer then needed.
have seen that especially core::ptr::drop_in_place have many x to smal estimates in real crates also.
I used a debug build of rustc to be able to trace and used the example from #66617
RUSTC_LOG=rustc_mir::monomorphize::partitioning=debug rustc +stage2 --emit=llvm-ir -Cno-prepopulate-passes main.rs
to get llvm-ir and see the estimates.I expected the estimate to be nere the actual number of llvm-ir lines for the functions.
one strange thing is that there is a lot of estimates that is 0 and that is not that common to have so feels like faults.
also some estimates is larger then the lines of llvm-ir e.g.
actual: 5370 Estimated: 9129 diff: -3759 alloc::alloc::box_free
the rustc version is built from 03d2f5c
Some more not that good estimates
@rustbot modify labels to +I-compiletime
cc @michaelwoerister
The text was updated successfully, but these errors were encountered: