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

coverage: Don't bother renumbering expressions on the Rust side #114399

Merged
merged 3 commits into from Sep 21, 2023

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Aug 3, 2023

The LLVM API that we use to encode coverage mappings already has its own code for removing unused coverage expressions and renumbering the rest.

This lets us get rid of our own complex renumbering code, making it easier to change our coverage code in other ways.


Now that we have tests for coverage mappings (#114843), I've been able to verify that this PR doesn't make the coverage mappings worse, thanks to an explicit simplification step.

@rustbot
Copy link
Collaborator

rustbot commented Aug 3, 2023

r? @jackh726

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 3, 2023
@Zalathar
Copy link
Contributor Author

Zalathar commented Aug 3, 2023

@rustbot label +A-code-coverage

@rustbot rustbot added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Aug 3, 2023
@Zalathar Zalathar force-pushed the no-renumber branch 2 times, most recently from 71d2089 to f7f8123 Compare August 3, 2023 06:51
@Zalathar

This comment was marked as outdated.

@Zalathar Zalathar force-pushed the no-renumber branch 5 times, most recently from b26bbf3 to 24ad7c5 Compare August 13, 2023 23:48
@jackh726
Copy link
Member

@Zalathar I'll wait to review this for a bit. Let me know if the other PR takes more time than you want, or you'd rather I just review this.

@Zalathar
Copy link
Contributor Author

@jackh726 Yeah, currently the other change is proceeding well, so I think it makes sense to wait on reviewing this one. I'll speak up when that changes.

@Zalathar
Copy link
Contributor Author

@rustbot author

@rustbot rustbot 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 Aug 14, 2023
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 20, 2023
@rustbot
Copy link
Collaborator

rustbot commented Aug 20, 2023

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@Zalathar
Copy link
Contributor Author

I've rebased this to sit on top of a copy of #114843, which adds the new tests that demonstrate how this affects coverage maps. Once that gets merged and I rebase this onto the new master, the patches with 🍒 should all disappear.

Using those tests, I've found that there are changes to the maps, but they can be eliminated by adding an explicit simplify-expressions step during coverage codegen that replicates the simplifications performed in-passing by the renumbering code. (In fact, it does a slightly better job in some cases.)

@Zalathar Zalathar force-pushed the no-renumber branch 12 times, most recently from 6c86faf to 72721d2 Compare September 19, 2023 04:05
@Zalathar Zalathar force-pushed the no-renumber branch 2 times, most recently from 2c6a213 to 4a8f6cf Compare September 21, 2023 01:02
After coverage instrumentation and MIR transformations, we can sometimes end up
with coverage expressions that always have a value of zero. Any expression
operand that refers to an always-zero expression can be replaced with a literal
`Operand::Zero`, making the emitted coverage mapping data smaller and simpler.

This simplification step is mostly redundant with the simplifications performed
inline in `expressions_with_regions`, except that it does a slightly more
thorough job in some cases (because it checks for always-zero expressions
*after* other simplifications).

However, adding this simplification step will then let us greatly simplify that
code, without affecting the quality of the emitted coverage maps.
The LLVM API that we use to encode coverage mappings already has its own code
for removing unused coverage expressions and renumbering the rest.

This lets us get rid of our own complex renumbering code, making it easier to
change our coverage code in other ways.
Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice comments, made the review relatively easy.

@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 21, 2023

📌 Commit 041a232 has been approved by jackh726

It is now in the queue for this repository.

@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 Sep 21, 2023
@bors
Copy link
Contributor

bors commented Sep 21, 2023

⌛ Testing commit 041a232 with merge 24b45c3...

@bors
Copy link
Contributor

bors commented Sep 21, 2023

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing 24b45c3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 21, 2023
@bors bors merged commit 24b45c3 into rust-lang:master Sep 21, 2023
12 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 21, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (24b45c3): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.5% [-2.0%, -1.0%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.5% [-2.0%, -1.0%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 630.615s -> 633.468s (0.45%)
Artifact size: 317.63 MiB -> 317.47 MiB (-0.05%)

@Zalathar Zalathar deleted the no-renumber branch September 22, 2023 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) 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-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.

None yet

6 participants