Repository navigation
Avoid instantiating FnSig when not necessary - #165863
nnethercote wants to merge 1 commit into
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Avoid instantiating `FnSig` when not necessary
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (15c8031): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.4%, secondary 1.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.0%, secondary -11.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 482.212s -> 481.954s (-0.05%) |
This comment has been minimized.
This comment has been minimized.
In various places we call `fn_sig`, which is expensive because it instantiates the signature, but then only look at the ABI or the safety, which don't require the instantiation. This commit introduces `fn_sig_abi` and `fn_sig_safety` which are alternatives that skip instantiation. In `check_instance_abi` the commit also changes `instance.ty(...)` to `tcx.type_of(...)` to avoid a second unnecessary instantiation path.
4d5b1d2 to
9c20e78
Compare
|
LLM disclosure: this PR involve LLM analysis of profiles. I wrote the code and text myself. |
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| match *autoderef.final_ty().kind() { | ||
| ty::FnDef(def_id, _) => { | ||
| let abi = self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi(); | ||
| // njn: move double skip_binder removal to precursor commit |
There was a problem hiding this comment.
reminder
| && let fn_sig @ ty::FnSig { | ||
| .. | ||
| } = fn_ty.fn_sig(tcx).skip_binder() | ||
| // njn: move this cleanup to a separate commit |
There was a problem hiding this comment.
reminder
In various places we call
fn_sig, which is expensive because it instantiates the signature, but then only look at the ABI or the safety, which don't require the instantiation. This commit introducesfn_sig_abiandfn_sig_safetywhich are alternatives that skip instantiation.In
check_instance_abithe commit also changesinstance.ty(...)totcx.type_of(...)to avoid a second unnecessary instantiation path.r? @bjorn3