Memoize per-test class analysis in a module-wide cache#11969
Memoize per-test class analysis in a module-wide cache#11969daniel-mohedano wants to merge 1 commit into
Conversation
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>
|
🎯 Code Coverage (details) 🔗 Commit SHA: c60b08f | Docs | Datadog PR Page | Give us feedback! |
Test Environment - nebula-release-pluginJob Status: 🟢 success
Baseline: median of |
Test Environment - netflix-zuulJob Status: 🟢 success
Baseline: median of |
Test Environment - reactive-streams-jvmJob Status: 🟢 success
Baseline: median of |
Test Environment - heliboardJob Status: 🟢 success
Baseline: median of |
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Test Environment - sonar-kotlinJob Status: 🟢 success
Baseline: median of |
Test Environment - jolokiaJob Status: 🟢 success
Baseline: median of |
Test Environment - okhttpJob Status: 🟢 success
Baseline: median of |
Test Environment - spring_bootJob Status: 🟢 success
Baseline: median of |
Test Environment - sonar-javaJob Status: 🟢 success
Baseline: median of |
Test Environment - pass4sJob Status: 🟢 success
Baseline: median of |
|
@codex review |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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 👍 / 👎.
What Does This Do
Memoizes per-test line-coverage class analysis in a module-wide cache.
When line-level coverage is enabled, JaCoCo's
Analyzerre-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.analyzeClassplus two getters onExecutionDataAdapter. 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
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: SDTEST-3847