-
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
ParamEnv::def_id
is expensive
#74865
Comments
We could probably remove it. Have to think a bit about it. It shouldn't eventually be needed for chalk, but it permits us to have a crutch for now, since chalk constructs its parameter environments differently (and hence the |
I think this is that relevant discussion. We didn't really go into it, since I think it was somewhat unrelated. Unfortunately, I haven't looked into alternatives here and don't even really know much about the implementation history for this, since this particular bit of code comes from the original integration. I imagine we could either try to "elaborate" the environment when we actually create a As a side note, looking through uses of Somewhat related, but I think some of the cases where a |
@jackh726 I think it's the case that chalk's parameter environments just have strictly more things in them, is that right? But are all of those predicates things we can represent (and faithfully interconvert) with rustc's |
Yes
No, we need a |
Yeah, I see. So we could extend the set of rustc predicates and then we could just have larger parameter environments when using chalk? |
Yes, that could work. |
Is there a clear path forward for this? I'm happy to help but I know nothing about Chalk... |
@nnethercote yes So, the first thing to do would be to add a Then, you would essentially have to add those predicates here. From there, you should be able to remove the environment elaboration in Let me know if that makes sense! I'll be around on Zulip if you have questions or need to discuss. |
@rustbot claim |
…, r=nikomatsakis Removing the `def_id` field from hot `ParamEnv` to make it smaller This PR addresses rust-lang#74865.
@nnethercote or @jonas-schievink could this be closed? |
Fixing the performance regression of rust-lang#76244 Issue rust-lang#74865 suggested that removing the `def_id` field from `ParamEnv` would improve performance. PR rust-lang#76244 implemented this change. Generally, [results](https://perf.rust-lang.org/compare.html?start=80fc9b0ecb29050d45b17c64af004200afd3cfc2&end=5ef250dd2ad618ee339f165e9b711a1b4746887d) were as expected: an instruction count decrease of about a percent. The instruction count for the unicode crates increased by about 3%, which `@nnethercote` speculated to be caused by a quirk of inlining or codegen. As the results were generally positive, and for chalk integration, this was also a step in the right direction, the PR was r+'d regardless. However, [wall-time performance results](https://perf.rust-lang.org/compare.html?start=a055c5a1bd95e029e9b31891db63b6dc8258b472&end=7402a394471a6738a40fea7d4f1891666e5a80c5&stat=task-clock) show a much larger performance degradation: 25%, as [mentioned](rust-lang#76244 (comment)) by `@Mark-Simulacrum.` This PR, for now, reverts rust-lang#76244 and attempts to find out, which change caused the regression.
ParamEnv::def_id
is only used for Chalk, which currently isn't on by default. I tried removing that field, which (among other things) reduces the size of the hotPredicateObligation
type from 40 bytes to 32 bytes. Here are some local perf results onFull
builds.(The
unicode_normalization
regression is weird, because this change results in the code clearly doing less work overall. Maybe it's a quirk of inlining or codegen, the kind of thing that may well disappear in the face of other minor changes.)Is this field really needed?
cc @rust-lang/wg-compiler-performance
The text was updated successfully, but these errors were encountered: