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

no more transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>> #94841

Closed
wants to merge 2 commits into from

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Mar 11, 2022

cc #94799 (comment)
reverts the first commit of #93505.

let's see what's the perf and max-rss effect of this change.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 11, 2022
@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 11, 2022
@lcnr lcnr changed the title no more transmute<List<Ty<'tcx>>, List<GenericArg<'tcx>>> no more transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>> Mar 11, 2022
@lcnr
Copy link
Contributor Author

lcnr commented Mar 11, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 11, 2022
@bors
Copy link
Contributor

bors commented Mar 11, 2022

⌛ Trying commit 0ed0fce with merge 4b4ec5434ef1443b760a9a294271b40d3f67560b...

@bors
Copy link
Contributor

bors commented Mar 11, 2022

☀️ Try build successful - checks-actions
Build commit: 4b4ec5434ef1443b760a9a294271b40d3f67560b (4b4ec5434ef1443b760a9a294271b40d3f67560b)

@rust-timer
Copy link
Collaborator

Queued 4b4ec5434ef1443b760a9a294271b40d3f67560b with parent f58d51b, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4b4ec5434ef1443b760a9a294271b40d3f67560b): comparison url.

Summary: This benchmark run did not return any relevant results. 36 results were found to be statistically significant but too small to be relevant.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking 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 led to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 11, 2022
@jackh726
Copy link
Member

It is a very small regression, but I think it's worth it for the reduced complexity.

@lcnr
Copy link
Contributor Author

lcnr commented Mar 14, 2022

i don't necessarily think so 🤔 I want to keep using List<Ty<'tcx>> for tuples and we already have a small negative perf impact from that and I don't want to make that one bigger.

Going to keep looking for the actual cause of that regression for now and then figure out where to go from there

@davidtwco
Copy link
Member

i don't necessarily think so 🤔 I want to keep using List<Ty<'tcx>> for tuples and we already have a small negative perf impact from that and I don't want to make that one bigger.

Going to keep looking for the actual cause of that regression for now and then figure out where to go from there

It doesn't sound like you're intending to land this, so I'll mark it as S-waiting-on-author and you can comment again if this should be reviewed so it can land.

@davidtwco davidtwco added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 18, 2022
@lcnr lcnr closed this May 9, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 19, 2023
…errors

Don't transmute `&List<GenericArg>` <-> `&List<Ty>`

In rust-lang#93505 we allowed safely transmuting between `&List<GenericArg<'_>>` and `&List<Ty<'_>>`. This was possible because `GenericArg` is a tagged pointer and the tag for types is `0b00`, such that a `GenericArg` with a type inside has the same layout as `Ty`.

While this was meant as an optimization, it doesn't look like it was actually any perf or max-rss win (see rust-lang#94799 (comment), rust-lang#94841, rust-lang#110496 (comment)).

Additionally the way it was done is quite fragile — `unsafe` code was not properly documented or contained in a module, types were not marked as `repr(C)` (making the transmutes possibly unsound). All of this makes the code maintenance harder and blocks other possible optimizations (as an example I've found out about these `transmutes` when my change caused them to sigsegv compiler).

Thus, I think we can safely (pun intended) remove those transmutes, making maintenance easier, optimizations possible, code less cursed, etc.

r? `@compiler-errors`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Apr 23, 2023
Don't transmute `&List<GenericArg>` <-> `&List<Ty>`

In #93505 we allowed safely transmuting between `&List<GenericArg<'_>>` and `&List<Ty<'_>>`. This was possible because `GenericArg` is a tagged pointer and the tag for types is `0b00`, such that a `GenericArg` with a type inside has the same layout as `Ty`.

While this was meant as an optimization, it doesn't look like it was actually any perf or max-rss win (see rust-lang/rust#94799 (comment), rust-lang/rust#94841, rust-lang/rust#110496 (comment)).

Additionally the way it was done is quite fragile — `unsafe` code was not properly documented or contained in a module, types were not marked as `repr(C)` (making the transmutes possibly unsound). All of this makes the code maintenance harder and blocks other possible optimizations (as an example I've found out about these `transmutes` when my change caused them to sigsegv compiler).

Thus, I think we can safely (pun intended) remove those transmutes, making maintenance easier, optimizations possible, code less cursed, etc.

r? `@compiler-errors`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants