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: Replace boolean options with a CoverageLevel enum #124507

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

Zalathar
Copy link
Contributor

After #123409, and some discussion at #79649 (comment) and #124120, it became clear to me that we should have a unified concept of “coverage level”, instead of having several separate boolean flags that aren't actually independent.

This PR therefore introduces a CoverageLevel enum, to replace the existing boolean flags for branch and mcdc.

The no-branch value (for -Zcoverage-options) has been renamed to block, instructing the compiler to only instrument for block coverage, with no branch coverage or MD/DC instrumentation.

@rustbot label +A-code-coverage
cc @ZhuUx @Lambdaris @RenjiSann

@rustbot
Copy link
Collaborator

rustbot commented Apr 29, 2024

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) labels Apr 29, 2024
@ZhuUx
Copy link
Contributor

ZhuUx commented Apr 29, 2024

It's nice to make this more cleaner. How about renaming the argument to --coverage-level as this comment suggests? Though there is not clear use case at the moment, we can set --coverage-options aside temporarily.

@Zalathar
Copy link
Contributor Author

For now, I would prefer to stick with coverage-options.

I don't think having separate flags for “level” and ”options” is useful at the moment, and keeping everything under “options” reduces back-and-forth churn.

In other words, I think we should keep all of these settings under coverage-option, until we have more experience that tells us whether having a separate flag would be useful.

Comment on lines 947 to 954
for option in v.split(',') {
match option {
"no-branch" => {
slot.branch = false;
slot.mcdc = false;
}
"branch" => slot.branch = true,
"mcdc" => {
slot.branch = true;
slot.mcdc = true;
}
"block" => slot.level = CoverageLevel::Block,
"branch" => slot.level = CoverageLevel::Branch,
"mcdc" => slot.level = CoverageLevel::Mcdc,
_ => return false,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we keep the for loop for future changes ? Otherwise, I think we should get rid of it, as it wouldn't make sense to give -Z coverage-options=mcdc,block to the compiler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should keep the loop.

It's true that there are no other independent options at the moment, but I don't think there's much benefit in removing it now just to have to add it back later when adding another option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Some examples of possible future options: #124144 (comment), #120013, and perhaps an option to not expand/emit zero-width spans.)

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 29, 2024

📌 Commit f926337 has been approved by compiler-errors

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 Apr 29, 2024
@bors
Copy link
Contributor

bors commented Apr 30, 2024

⌛ Testing commit f926337 with merge f9dca46...

@bors
Copy link
Contributor

bors commented Apr 30, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing f9dca46 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 30, 2024
@bors bors merged commit f9dca46 into rust-lang:master Apr 30, 2024
11 checks passed
@rustbot rustbot added this to the 1.80.0 milestone Apr 30, 2024
@Zalathar Zalathar deleted the coverage-level branch April 30, 2024 05:01
@bors bors mentioned this pull request Apr 30, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f9dca46): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

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

Cycles

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)
1.4% [0.7%, 2.2%] 2
Regressions ❌
(secondary)
2.7% [2.0%, 4.7%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.4% [0.7%, 2.2%] 2

Binary size

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

Bootstrap: 674.628s -> 673.064s (-0.23%)
Artifact size: 315.93 MiB -> 315.92 MiB (-0.00%)

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.

7 participants