Conversation
Merging this PR will not alter performance
Performance Changes
Tip Curious why this is faster? Use the CodSpeed MCP and ask your agent. Comparing |
|
Noting: the reason I'm currently gating this behind a label is because it makes tests in CI more than twice as slow. |
f310af7 to
226b0e5
Compare
| [build] | ||
| rustflags = ["-C", "instrument-coverage"] | ||
| target-dir = "target/coverage" |
There was a problem hiding this comment.
There was a problem hiding this comment.
Enabling instrumentation? Yeah, it's significant, which is why it gets its own target here.
|
|
||
| # Decisions | ||
| [[ ! $has_skip_label && ($any_code_changed || $on_main_branch) ]] && test_code=1 | ||
| [[ $on_main_branch || $has_coverage_label ]] && collect_coverage=1 |
There was a problem hiding this comment.
Why do we only collect coverage on pull requests with a label?
There was a problem hiding this comment.
Mostly because it's slow -- instrumentation makes our test runs roughly 50% slower, sadly.
| use uv_dev::{COVERAGE_RUSTC_WRAPPER_ENV, coverage_rustc_wrapper, run}; | ||
| use uv_static::EnvVars; | ||
|
|
||
| fn main() -> ExitCode { |
There was a problem hiding this comment.
Noting: it feels like a pretty bad hack to reuse uv-dev as a rustc wrapper, but this needs to live somewhere. Maybe I can abstract it as uv-dev rustc ... or similar.
This adds a new `cargo dev coverage` subcommand, which invokes nextest under our new coverage pesudo-profile. This profile in turn enables `-C instrument-coverage`. `cargo dev coverage` also takes care of merging raw profiling samples into profdata and LCOV reports for us, which our new `coverage-html-report.py` script can turn into a readable (but very large) HTML report. The basic flow for this is: ``` $ # any nextest flags will work $ cargo dev coverage ... ``` That will output something like: ``` Merged profile: .../astral-sh/uv/target/coverage/profdata/b46cc0f3-7cd0-4309-9df2-10ab653e6dd8.profdata LCOV profile: .../astral-sh/uv/target/coverage/lcov/b46cc0f3-7cd0-4309-9df2-10ab653e6dd8.lcov Generate an HTML report with: uv run --script scripts/coverage-html-report.py b46cc0f3-7cd0-4309-9df2-10ab653e6dd8 ``` And then you can run: ``` uv run --script scripts/coverage-html-report.py b46cc0f3-7cd0-4309-9df2-10ab653e6dd8 ``` (or add `--open` to auto-open in the browser). Under the hood, this only uses existing dependencies plus Rust's own LLVM toolchain, plus coverage.py for the HTML report generation. Signed-off-by: William Woodruff <william@yossarian.net> MVP coverage workflow Signed-off-by: William Woodruff <william@yossarian.net> MVP coverage workflow, take 2 Signed-off-by: William Woodruff <william@yossarian.net> Use a pool of 16 raw profiles for pooling Signed-off-by: William Woodruff <william@yossarian.net> Avoid some Windows UNC pain Signed-off-by: William Woodruff <william@yossarian.net> Fix rustflags for coverage on Windows Signed-off-by: William Woodruff <william@yossarian.net> Remove coverage ID chum Signed-off-by: William Woodruff <william@yossarian.net> Avoid Windows nonsense Signed-off-by: William Woodruff <william@yossarian.net> Add coverage guide to CONTRIBUTING Signed-off-by: William Woodruff <william@yossarian.net> Be less strict about the ID Signed-off-by: William Woodruff <william@yossarian.net> Prettier Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>

Summary
This adds a new
cargo dev coveragesubcommand, which invokes nextest under our new coverage pesudo-profile. This profile in turn enables-C instrument-coverage.cargo dev coveragealso takes care of merging raw profiling samples into profdata and LCOV reports for us, which our newcoverage-html-report.pyscript can turn into a readable (but very large) HTML report.The basic flow for this is:
That will output something like:
And then you can run:
(or add
--opento auto-open in the browser).Under the hood, this only uses existing dependencies plus Rust's own LLVM toolchain, plus coverage.py for the HTML report generation.
TODOs:
CONTRIBUTING.mdTest Plan
Internal only.