-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Use a more lightweight cache for erase_regions
#139240
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @petrochenkov. Use |
Remember that you now have credentials for perf runs, which should be more accurate, and also more representative, with a LTOed/PGOed toolchain. |
@@ -268,6 +268,14 @@ impl<D: Deps> DepGraph<D> { | |||
D::with_deps(TaskDepsRef::Forbid, op) | |||
} | |||
|
|||
/// This checks that no dependencies are registered in `op` if debug assertions are enabled. | |||
pub fn debug_assert_no_deps<OP, R>(op: OP) -> R |
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.
pub fn debug_assert_no_deps<OP, R>(op: OP) -> R | |
pub fn debug_assert_no_deps<R>(op: impl FnOnce() -> R) -> R |
@@ -1376,6 +1376,9 @@ pub struct GlobalCtxt<'tcx> { | |||
/// Common consts, pre-interned for your convenience. | |||
pub consts: CommonConsts<'tcx>, | |||
|
|||
/// A cache for the `erase_regions` function. | |||
pub(in crate::ty) erased_region_cache: ShardedHashMap<Ty<'tcx>, Ty<'tcx>>, |
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.
Could you add comments explaining why 1) the query cache is not used here and 2) a sharded hash map is used instead of a simple one.
} | ||
impl<'tcx> TyCtxt<'tcx> { | ||
/// Erases regions from `ty` to yield a new type. | ||
pub fn erase_regions_ty(self, ty: Ty<'tcx>) -> Ty<'tcx> { |
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.
Could you add a comment telling that this function is expected to be a pure function of its input, and that's why it cannot call any other queries.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Use a more lightweight cache for `erase_regions` This changes `erase_regions` to use a global hashmap instead of a query to cache types with erased lifetimes. `erase_regions_ty` only depends on the input parameter so it doesn't need to be a query. This is a rebase of rust-lang#59505. <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Physical Memory</td><td align="right">Physical Memory</td><td align="right">%</th><td align="right">Committed Memory</td><td align="right">Committed Memory</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.3960s</td><td align="right">1.3883s</td><td align="right"> -0.55%</td><td align="right">147.66 MiB</td><td align="right">147.76 MiB</td><td align="right"> 0.07%</td><td align="right">199.83 MiB</td><td align="right">199.86 MiB</td><td align="right"> 0.01%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2346s</td><td align="right">0.2337s</td><td align="right"> -0.38%</td><td align="right">80.35 MiB</td><td align="right">80.54 MiB</td><td align="right"> 0.24%</td><td align="right">129.99 MiB</td><td align="right">130.12 MiB</td><td align="right"> 0.10%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.7811s</td><td align="right">0.7788s</td><td align="right"> -0.30%</td><td align="right">107.75 MiB</td><td align="right">108.07 MiB</td><td align="right"> 0.29%</td><td align="right">153.67 MiB</td><td align="right">153.99 MiB</td><td align="right"> 0.21%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.2999s</td><td align="right">1.2978s</td><td align="right"> -0.17%</td><td align="right">140.24 MiB</td><td align="right">140.35 MiB</td><td align="right"> 0.08%</td><td align="right">188.59 MiB</td><td align="right">188.58 MiB</td><td align="right"> -0.01%</td></tr><tr><td>Total</td><td align="right">3.7117s</td><td align="right">3.6986s</td><td align="right"> -0.35%</td><td align="right">476.00 MiB</td><td align="right">476.72 MiB</td><td align="right"> 0.15%</td><td align="right">672.08 MiB</td><td align="right">672.55 MiB</td><td align="right"> 0.07%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9965s</td><td align="right"> -0.35%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> 0.17%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> 0.08%</td></tr></table>
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (35d98da): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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 @bors rollup=never 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 (primary -0.7%, secondary -1.4%)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.
CyclesResults (primary -1.8%)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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 776.227s -> 774.214s (-0.26%) |
Not sure if it's worth it, the change is doing something unusual and non-obvious, but the results are mixed. |
Reminder, once the PR becomes ready for a review, use |
This changes
erase_regions
to use a global hashmap instead of a query to cache types with erased lifetimes.erase_regions_ty
only depends on the input parameter so it doesn't need to be a query.This is a rebase of #59505.