Skip to content

bazel/coverage: Strip function and branch records from per-test lcov - #5580

Merged
phlax merged 1 commit into
envoyproxy:mainfrom
phlax:coverage-lcov-strip
Nov 9, 2026
Merged

phlax merged 1 commit into
envoyproxy:mainfrom
phlax:coverage-lcov-strip

Conversation

@phlax

@phlax phlax commented Nov 9, 2026

Copy link
Copy Markdown
Member

Bazel runs an lcov merger once per test, in the coverage postprocessing spawn, to produce that test's coverage.dat. In Envoy every one of those files describes the whole instrumented binary: 8.6MB for an integration test, of which 77% is function records (FN/FNDA, 25k mangled names) and 10% branch data (BRDA), repeated for all ~1,600 tests (~14GB per run) and then uploaded, downloaded and parsed again by the combined report, which only validates line coverage.

Add //coverage:lcov_merger, a wrapper for --coverage_output_generator that passes its arguments through to Bazel's merger and then strips the configured record types (by default function and branch records) from the merged report in place. Line records are kept as they are, zero-hit lines included: the baseline report only lists files, so dropping them would hide uncovered lines rather than count them. The combined line coverage is unchanged; the HTML report omits its Functions column when no function records remain.

The rule takes the merger to wrap and the record types to strip, so a consumer that wants function coverage can strip branches alone.

@phlax
phlax requested a balanced review from Copilot November 9, 2026 23:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@phlax
phlax requested a balanced review from Copilot November 9, 2026 23:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@phlax
phlax force-pushed the coverage-lcov-strip branch from 38239f9 to 835e3e0 Compare November 9, 2026 23:12
@phlax
phlax requested a balanced review from Copilot November 9, 2026 23:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@phlax
phlax force-pushed the coverage-lcov-strip branch 2 times, most recently from 11e1a63 to 6509282 Compare November 9, 2026 23:31
Bazel runs an lcov merger once per test, in the coverage postprocessing
spawn, to produce that test's `coverage.dat`. In Envoy every one of
those files describes the whole instrumented binary: 8.6MB for an
integration test, of which 77% is function records (`FN`/`FNDA`, 25k
mangled names) and 10% branch data (`BRDA`), repeated for all ~1,600
tests (~14GB per run) and then uploaded, downloaded and parsed again by
the combined report, which only validates line coverage.

Add `//coverage:lcov_merger`, a wrapper for `--coverage_output_generator`
that passes its arguments through to Bazel's merger and then strips the
configured record types (by default function and branch records) from
the merged report in place. Line records are kept as they are, zero-hit
lines included: the baseline report only lists files, so dropping them
would hide uncovered lines rather than count them. The combined line
coverage is unchanged; the HTML report omits its Functions column when
no function records remain.

The rule takes the merger to wrap and the record types to strip, so a
consumer that wants function coverage can strip branches alone.

Signed-off-by: Ryan Northey <[email protected]>
@phlax
phlax force-pushed the coverage-lcov-strip branch from 6509282 to 4c7594b Compare November 9, 2026 23:46
@phlax
phlax merged commit daddc56 into envoyproxy:main Nov 9, 2026
55 checks passed
phlax added a commit to phlax/toolshed that referenced this pull request Nov 13, 2026
Port `//coverage:lcov_merger` and `//coverage:llvm_support` (the
`llvm-cov` wrapper), with their tests, from `main` at bazel-v0.5.20, so
that WORKSPACE consumers can postprocess coverage inside the test action
as `main` does (envoyproxy#5580, envoyproxy#5582).

With split postprocessing, each test uploads its raw profile for a
separate action to download again. For Envoy that is about 140MB per
integration test and 130GB per full coverage run. Inside the test
action, the wrapper exports line coverage for workspace sources only,
and the merger strips the records the report does not read and removes
the coverage directory's intermediates before the test's outputs are
uploaded.

The files are unchanged from `main`. The report generation that came
with them on `main` (`run`, `coverage_report`, the grcov and lcov merge
repositories) is left out: WORKSPACE consumers have their own.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit that referenced this pull request Nov 13, 2026
…#5588)

Port `//coverage:lcov_merger` and `//coverage:llvm_support` (the
`llvm-cov` wrapper), with their tests, from `main` at bazel-v0.5.20, so
that WORKSPACE consumers can postprocess coverage inside the test action
as `main` does (#5580, #5582).

With split postprocessing, each test uploads its raw profile for a
separate action to download again. For Envoy that is about 140MB per
integration test and 130GB per full coverage run. Inside the test
action, the wrapper exports line coverage for workspace sources only,
and the merger strips the records the report does not read and removes
the coverage directory's intermediates before the test's outputs are
uploaded.

The files are unchanged from `main`. The report generation that came
with them on `main` (`run`, `coverage_report`, the grcov and lcov merge
repositories) is left out: WORKSPACE consumers have their own.

Signed-off-by: Ryan Northey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants