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

Readd track_caller to Result::from_residual #91752

Merged
merged 2 commits into from
Dec 15, 2021

Conversation

yaahc
Copy link
Member

@yaahc yaahc commented Dec 10, 2021

This is a followup on #87401 in and an attempt to move the issue towards resolution.

As part of the overhaul of the Try trait we removed the ability for errors to grab location information during propagation via ? with the builtin std::result::Result. The previously linked issue has a fair bit of discussion into the reasons for and against the usage of #[track_caller] on the FromResidual impl on Result that I will do my best to summarize.


For

Against


Personally, I want to quantify the performance / bloat impact of re-adding this attribute, and fully evaluate the pros and cons before deciding if I need to switch eyre to have a custom Result type, which would also mean I need try_trait_v2 to be stabilized, cc @scottmcm. If the performance impact is minor enough in the general case I think I would prefer that the default Result type has the ability to track location information for consistency with panic error reporting, and leave it to applications that need particularly high performance to handle the micro optimizations of introducing their own efficient custom Result type or matching manually.

Alternatively, I wonder if the performance penalty on code that doesn't use the location information on FromResidual could be mitigated via new optimizations.

@yaahc yaahc added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Dec 10, 2021
@rust-highfive
Copy link
Collaborator

r? @m-ou-se

(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 Dec 10, 2021
@cuviper
Copy link
Member

cuviper commented Dec 10, 2021

Alternatively, I wonder if the performance penalty on code that doesn't use the location information on FromResidual could be mitigated via new optimizations.

If the calls are inlined, it's likely that the unused location information will already be optimized away.

@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 Dec 10, 2021
@bors
Copy link
Contributor

bors commented Dec 10, 2021

⌛ Trying commit 44756d8 with merge 8c48303ad50f06e7dd1cc5ba110053ede6d55199...

@rust-log-analyzer

This comment has been minimized.

@cuviper
Copy link
Member

cuviper commented Dec 10, 2021

Looks like it might need some UI output review / blessing.

@scottmcm
Copy link
Member

My big question here is whether it'd result in a de-facto stability guarantee, despite there not de-jure being one per #88302 (comment).

For example, without this we could merge the "re-yeet" MIR blocks from multiple ?s, but if they need to preserve all the line numbers that becomes very different.

@yaahc
Copy link
Member Author

yaahc commented Dec 10, 2021

My big question here is whether it'd result in a de-facto stability guarantee, despite there not de-jure being one per #88302 (comment).

For example, without this we could merge the "re-yeet" MIR blocks from multiple ?s, but if they need to preserve all the line numbers that becomes very different.

No matter what I think we've already made the explicit decision that we do not consider #[track_caller] location data to be part of our stable API, so if some future consideration comes along that pushes us in the other direction we can always revert this change.

@bors
Copy link
Contributor

bors commented Dec 10, 2021

☀️ Try build successful - checks-actions
Build commit: 8c48303ad50f06e7dd1cc5ba110053ede6d55199 (8c48303ad50f06e7dd1cc5ba110053ede6d55199)

@rust-timer
Copy link
Collaborator

Queued 8c48303ad50f06e7dd1cc5ba110053ede6d55199 with parent 0b42dea, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8c48303ad50f06e7dd1cc5ba110053ede6d55199): comparison url.

Summary: This change led to moderate relevant regressions 😿 in compiler performance.

  • Moderate regression in instruction counts (up to 1.4% on incr-unchanged builds of wg-grammar)

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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 10, 2021
@m-ou-se
Copy link
Member

m-ou-se commented Dec 12, 2021

r? @cuviper

@rust-highfive rust-highfive assigned cuviper and unassigned m-ou-se Dec 12, 2021
@cuviper
Copy link
Member

cuviper commented Dec 14, 2021

The only negative perf results are in incremental builds, and even those are not too bad. I think it's acceptable.

@bors r+

@bors
Copy link
Contributor

bors commented Dec 14, 2021

📌 Commit 94307e2 has been approved by cuviper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 14, 2021
@bors
Copy link
Contributor

bors commented Dec 15, 2021

⌛ Testing commit 94307e2 with merge df89fd2...

@bors
Copy link
Contributor

bors commented Dec 15, 2021

☀️ Test successful - checks-actions
Approved by: cuviper
Pushing df89fd2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 15, 2021
@bors bors merged commit df89fd2 into rust-lang:master Dec 15, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 15, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (df89fd2): comparison url.

Summary: This benchmark run did not return any relevant changes.

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

@rustbot label: -perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants