Skip to content

Memoize per-test class analysis in a module-wide cache#11969

Draft
daniel-mohedano wants to merge 1 commit into
masterfrom
daniel.mohedano/line-coverage-memoization-only
Draft

Memoize per-test class analysis in a module-wide cache#11969
daniel-mohedano wants to merge 1 commit into
masterfrom
daniel.mohedano/line-coverage-memoization-only

Conversation

@daniel-mohedano

@daniel-mohedano daniel-mohedano commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Memoizes per-test line-coverage class analysis in a module-wide cache.

When line-level coverage is enabled, JaCoCo's Analyzer re-parses and re-analyzes each covered class's bytecode once per test that covers it, which dominates the report-time cost. This caches the covered lines per (class id, probe set), shared across tests, so a class covered identically by many tests is analyzed only once.

Motivation

Reduce the runtime overhead of line-level per-test code coverage (Test Optimization). Report-time re-analysis was the dominant hotspot; in the test-environment, marginal line-coverage overhead drops meaningfully on suites with headroom (e.g. nebula, spring-boot, okhttp).

The probe recording and instrumentation paths are unchanged, so JaCoCo's aggregate coverage (total %/report uploads, used to back-fill coverage for TIA/ITR-skipped tests) is preserved by its native probe writes.

Additional Notes

Scoped to the report path only: LineCoverageStore.analyzeClass plus two getters on ExecutionDataAdapter. No changes to instrumentation, probe recording, or the coverage API. Coverage stays correct beyond the cache's size guard (the class is simply analyzed each time).

Contributor Checklist

Jira ticket: SDTEST-3847

Jacoco's Analyzer re-parsed each covered class once per test, dominating
line-coverage report cost. Cache the covered lines per (class id, probe set),
shared across tests, so a class covered identically by many tests is analyzed
only once. Recording path is unchanged, so Jacoco's aggregate coverage is
preserved by its native probe writes (no probe-array swap).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@daniel-mohedano daniel-mohedano added type: feature Enhancements and improvements comp: ci visibility Continuous Integration Visibility tag: ai generated Largely based on code generated by an AI or LLM labels Jul 16, 2026
@datadog-official

datadog-official Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 61.95% (+4.74%)

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

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - nebula-release-plugin

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 37.73 37.15 $\color{red}{\blacktriangle}$ +0.58 36.42 $\color{red}{\blacktriangle}$ +1.31 37/120
agentless 37.75 36.42 $\color{red}{\blacktriangle}$ +1.33 36.42 $\color{red}{\blacktriangle}$ +1.33 37/120
agentlessCodeCoverage 43.49 45.38 $\color{green}{\blacktriangledown}$ -1.89 44.48 $\color{green}{\blacktriangledown}$ -0.99 37/120
agentlessLineCoverage 55.25 74.82 $\color{green}{\blacktriangledown}$ -19.57 74.82 $\color{green}{\blacktriangledown}$ -19.57 37/120

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - netflix-zuul

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 89.20 87.80 $\color{red}{\blacktriangle}$ +1.40 87.80 $\color{red}{\blacktriangle}$ +1.40 35/125
agentless 81.62 81.05 $\color{red}{\blacktriangle}$ +0.57 81.05 $\color{red}{\blacktriangle}$ +0.57 35/124
agentlessCodeCoverage 96.02 97.04 $\color{green}{\blacktriangledown}$ -1.02 95.12 $\color{red}{\blacktriangle}$ +0.90 35/122
agentlessLineCoverage 112.21 111.62 $\color{red}{\blacktriangle}$ +0.59 111.62 $\color{red}{\blacktriangle}$ +0.59 34/121

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - reactive-streams-jvm

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 22.20 21.65 $\color{red}{\blacktriangle}$ +0.55 21.65 $\color{red}{\blacktriangle}$ +0.55 39/127
agentless 18.58 18.82 $\color{green}{\blacktriangledown}$ -0.24 18.82 $\color{green}{\blacktriangledown}$ -0.24 38/124
agentlessCodeCoverage 20.54 20.39 $\color{red}{\blacktriangle}$ +0.15 19.99 $\color{red}{\blacktriangle}$ +0.55 37/122
agentlessLineCoverage 26.85 29.82 $\color{green}{\blacktriangledown}$ -2.97 29.82 $\color{green}{\blacktriangledown}$ -2.97 36/121

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - heliboard

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 16.45 9.54 $\color{red}{\blacktriangle}$ +6.91 9.54 $\color{red}{\blacktriangle}$ +6.91 36/47

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@dd-octo-sts

dd-octo-sts Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.98 s 13.91 s [-0.1%; +1.1%] (no difference)
startup:insecure-bank:tracing:Agent 12.95 s 13.02 s [-1.4%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 16.45 s 16.75 s [-6.4%; +2.8%] (no difference)
startup:petclinic:iast:Agent 16.97 s 16.97 s [-0.9%; +0.9%] (no difference)
startup:petclinic:profiling:Agent 16.50 s 16.90 s [-3.6%; -1.1%] (significantly better)
startup:petclinic:sca:Agent 16.99 s 16.87 s [-0.1%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.13 s 16.15 s [-1.1%; +0.8%] (no difference)

Commit: c60b08fa · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - sonar-kotlin

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 6.60 12.87 $\color{green}{\blacktriangledown}$ -6.27 12.87 $\color{green}{\blacktriangledown}$ -6.27 35/118
agentless 7.43 11.88 $\color{green}{\blacktriangledown}$ -4.45 12.12 $\color{green}{\blacktriangledown}$ -4.69 33/115
agentlessCodeCoverage 8.97 14.81 $\color{green}{\blacktriangledown}$ -5.84 15.11 $\color{green}{\blacktriangledown}$ -6.14 33/115
agentlessLineCoverage 12.96 18.82 $\color{green}{\blacktriangledown}$ -5.86 18.82 $\color{green}{\blacktriangledown}$ -5.86 35/118

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - jolokia

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 94.17 93.23 $\color{red}{\blacktriangle}$ +0.94 93.23 $\color{red}{\blacktriangle}$ +0.94 42/131
agentless 90.68 89.58 $\color{red}{\blacktriangle}$ +1.10 89.58 $\color{red}{\blacktriangle}$ +1.10 41/128
agentlessCodeCoverage 99.33 99.00 $\color{red}{\blacktriangle}$ +0.33 99.00 $\color{red}{\blacktriangle}$ +0.33 41/126
agentlessLineCoverage 99.89 99.00 $\color{red}{\blacktriangle}$ +0.89 99.00 $\color{red}{\blacktriangle}$ +0.89 39/124

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - okhttp

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 19.85 19.20 $\color{red}{\blacktriangle}$ +0.65 19.20 $\color{red}{\blacktriangle}$ +0.65 35/126
agentless 19.77 19.20 $\color{red}{\blacktriangle}$ +0.57 19.20 $\color{red}{\blacktriangle}$ +0.57 35/123
agentlessCodeCoverage 22.11 22.54 $\color{green}{\blacktriangledown}$ -0.43 22.09 $\color{red}{\blacktriangle}$ +0.02 34/122
agentlessLineCoverage 39.08 44.48 $\color{green}{\blacktriangledown}$ -5.40 44.48 $\color{green}{\blacktriangledown}$ -5.40 33/128

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - spring_boot

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 16.72 16.04 $\color{red}{\blacktriangle}$ +0.68 16.04 $\color{red}{\blacktriangle}$ +0.68 34/115
agentless 10.25 9.73 $\color{red}{\blacktriangle}$ +0.52 9.73 $\color{red}{\blacktriangle}$ +0.52 34/116
agentlessCodeCoverage 14.27 13.67 $\color{red}{\blacktriangle}$ +0.60 13.40 $\color{red}{\blacktriangle}$ +0.87 35/115
agentlessLineCoverage 22.80 32.95 $\color{green}{\blacktriangledown}$ -10.15 32.95 $\color{green}{\blacktriangledown}$ -10.15 33/114

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - sonar-java

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 41.58 10.97 $\color{red}{\blacktriangle}$ +30.61 13.40 $\color{red}{\blacktriangle}$ +28.18 36/124
agentless 28.19 11.65 $\color{red}{\blacktriangle}$ +16.54 17.03 $\color{red}{\blacktriangle}$ +11.16 36/123
agentlessCodeCoverage 67.60 74.82 $\color{green}{\blacktriangledown}$ -7.22 86.07 $\color{green}{\blacktriangledown}$ -18.47 36/123
agentlessLineCoverage 122.54 125.85 $\color{green}{\blacktriangledown}$ -3.31 136.34 $\color{green}{\blacktriangledown}$ -13.80 35/122

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Test Environment - pass4s

Job Status: 🟢 success

Scenario This PR (%) 7d median Δ 7d 30d median Δ 30d runs (7d/30d)
agent 9.73 9.35 $\color{red}{\blacktriangle}$ +0.38 10.33 $\color{green}{\blacktriangledown}$ -0.60 29/111
agentless 6.02 10.33 $\color{green}{\blacktriangledown}$ -4.31 10.13 $\color{green}{\blacktriangledown}$ -4.11 29/111
agentlessCodeCoverage 16.99 17.03 $\color{green}{\blacktriangledown}$ -0.04 17.38 $\color{green}{\blacktriangledown}$ -0.39 29/110

Baseline: median of @test.tracer_overhead on main (gitlab) over the last 7/30 days, per OSS project & scenario. Δ = this PR − baseline median; red ▲ = more overhead, green ▽ = less overhead than baseline.

@daniel-mohedano

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c60b08fac1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


AnalysisCacheKey(long classId, boolean[] probes) {
this.classId = classId;
this.probes = probes;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid retaining full probe arrays in the cache

When line coverage is enabled for very large/generated classes with many distinct probe patterns, this stores each test's full boolean[] as a module-lifetime cache key, so the factory can retain up to 50,000 arrays that previously died with the test span; an entry-count cap does not bound memory by probe count (for example, 50k unique 10k-probe arrays is hundreds of MB just for keys). Consider snapshotting into a compact representation or using a weighted bound so the cache cannot exhaust the test JVM on large suites.

Useful? React with 👍 / 👎.

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

Labels

comp: ci visibility Continuous Integration Visibility tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant