Skip to content

perf(internal/civisibility): cache impacted-test decisions#4701

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
feat/civisibility-impacted-tests-cache
Apr 28, 2026
Merged

perf(internal/civisibility): cache impacted-test decisions#4701
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
feat/civisibility-impacted-tests-cache

Conversation

@tonyredondo

Copy link
Copy Markdown
Member

What does this PR do?

Optimizes CI Visibility impacted-test analysis by caching IsImpacted decisions per analyzer and replacing per-call temporary test bitmap allocation with a direct bitmap range intersection check.

The implementation preserves existing behavior:

  • suffix-based modified-file matching
  • first matching modified file wins
  • missing line information marks matching files as impacted
  • existing debug log fragments are still emitted, including on cache hits
  • analyzer state is safe for concurrent IsImpacted calls

It also adds benchmarks for repeated cached calls, cold distinct ranges, misses, missing-line-info decisions, and the direct bitmap range check.

Motivation

Profiling after the previous CI Visibility optimizations showed IsImpacted still doing repeated work on retries/subtests. The previous flow rebuilt a temporary bitmap for each test range and scanned modified files on every call. This change keeps the same decisions while avoiding that repeated allocation and memoizing repeated source range lookups.

Latest local benchmark sample:

BenchmarkIsImpactedRepeatedSameRange-12          36.02 ns/op    0 B/op    0 allocs/op
BenchmarkIsImpactedRepeatedDistinctRanges-12     41.69 ns/op    0 B/op    0 allocs/op
BenchmarkIsImpactedColdDistinctRanges-12        533.9 ns/op   173 B/op    3 allocs/op
BenchmarkIsImpactedRepeatedMiss-12               27.41 ns/op    0 B/op    0 allocs/op
BenchmarkIsImpactedNoLineInfo-12                 35.36 ns/op    0 B/op    0 allocs/op
BenchmarkBitmapIntersectsLineRange-12            2.953 ns/op    0 B/op    0 allocs/op

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Local verification:

git diff --check
go test ./internal/civisibility/utils/impactedtests -count=1
go test -race ./internal/civisibility/utils/impactedtests -count=1
go test ./internal/civisibility/utils/... -count=1
go test ./internal/civisibility/integrations/... -count=1
go test ./internal/civisibility/utils/impactedtests -bench='BenchmarkIsImpacted|BenchmarkBitmapIntersects' -benchmem -run '^$'

Notes:

  • System tests are not added because this is an internal performance refactor with no agent protocol or user-facing behavior change.
  • make lint, make test, make generate, and make fix-modules were not run directly; the narrower local commands above were run against the affected CI Visibility packages, and no generated files or module files changed.

@tonyredondo
tonyredondo requested a review from a team as a code owner April 28, 2026 11:50
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 28, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 92.78%
Overall Coverage: 61.30% (+4.07%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1d14ff4 | Docs | Datadog PR Page | Give us feedback!

@pr-commenter

pr-commenter Bot commented Apr 28, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-04-28 12:29:33

Comparing candidate commit 1d14ff4 in PR branch feat/civisibility-impacted-tests-cache with baseline commit 1f7ab1c in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 153 metrics, 8 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.10%. Comparing base (1f7ab1c) to head (1d14ff4).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...civisibility/utils/impactedtests/impacted_tests.go 93.33% 5 Missing and 2 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...civisibility/utils/impactedtests/impacted_tests.go 84.65% <93.33%> (ø)

... and 449 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants