Repository navigation
Introduce a Gradle S3 build cache - #12604
Conversation
🟢 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. |
* Configure shared and release S3 build cache namespaces
sarahchen6
left a comment
There was a problem hiding this comment.
LGTM!! Though we should probably update the PR description based on results from the latest changes?
|
@sarahchen6 Yes, I can do that tomorrow when all pipelines have run. I can push an empty commit. |
AlexeyKuznetsov-DD
left a comment
There was a problem hiding this comment.
Can't wait to see it alive!
Left some minor notes.
Just for my understanding: cache expiration was configured in some external admin tool?
Yes |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ded8386885
ℹ️ 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".
There was a problem hiding this comment.
More details
Default release cache namespaces isolate pipelines and separate architectures and operating systems; packaged dependency bytes participate in cache fingerprints. These safeguards were reviewed statically; live S3 operations and tagged-pipeline execution remain unverified.
🤖 Bits Code Review · Commit ded8386
90798b2 to
d15ec3d
Compare
[ci: NON_DEFAULT_JVMS] [ci: ARM64]
Cache hits restore earlier test results and provide no new executions for flaky-test detection. Run selected Test tasks on master every time, while keeping successful results eligible for cache writes and reuse by other branches. Compilation and other build tasks keep normal caching. Preserve the per-project rerun flag and log why task output reuse is disabled.
13a2f36 to
7c16fea
Compare
|
Dooh had to rebase unsigned commits. |
1508ea5
into
master
What Does This Do
Enables S3 build cache for Gradle task outputs in GitLab CI. Eligible jobs can reuse matching outputs, while release pipelines use isolated, pipeline-specific namespaces. Dependency caches, plugin caches and job artifacts remain in GitLab. This should significantly improve Gradle job duration.
This effectively retire the old Gitlab based build cache.
Motivation
The existing pipeline-scoped GitLab cache transfers whole cache archives and limits reuse across pipelines. The S3 build cache lets jobs restore matching Gradle task outputs directly and share them across regular pipelines.
Follow-up
Additional Notes
It's important to understand that not all changes can benefit from the cache. Some changes impacts the whole build e.g. convention plugins, changing something in
internal-api, reformatting code changing line numbers that land in class files, these kind impactful changes makes a different key, and require to be computed the first time they are encountered.More precisely, the cost belongs to the first pipeline requesting each new cache key.
Example in such a PR:
build-logic/which produces new keys. Their PR pipeline needs to execute the affected tasks and stores their outputs.build-logic/continue using the previous entries.You can refer the doc and run book on our build cache.
Note
On
mastertests are still executed without relying on the build cache, the reason is to keep a steady signal for flaky tests.Note
Smoke jobs restore build prerequisites, but their test results have zero reuse across the measured commits because the agent JAR includes the commit SHA.
Caution
If you are working on tasks that need caching ensure you read the gradle guide, in particular on having good inputs (for fingerprinting).
Scope and cache namespaces
This only affects GitLab CI. Dependency/plugin caches and job artifacts remain as big GitLab cache.
v1/<architecture>/<os>/v1/release/<CI_PIPELINE_ID>/<architecture>/<os>/Gradle appends the task cache key. Regular pipelines share entries across branches. Release entries are reused only within the same
CI_PIPELINE_ID; no shared-cache fallback.S3_BUILD_CACHE_PREFIXcan override the full prefix.Results and pipeline timings
The warm run reduced pipeline duration by 31.7% and median job duration by 20.3% across 200 matching cache-enabled Gradle jobs. System-test duration fell from
12m37sto11m27s.Snapshot: 2026-11-06, comparing the November 5 commit
50df1a0547with the November 6 commita19b40f110. Both passed and have identical source trees, using plugin1.9.11and Gradle9.8.2. ARM64 test jobs remained manual in both pipelines.Overall:
All times below are per-job medians. Arrows show the first pipeline followed by the second.
-means test-task restoration is not applicable to that job family.Measurement scope and limits
Cache metrics cover 200 cache-enabled parent-pipeline Gradle jobs in
buildandtests, excluding downstream system tests andvalidate_build: [false]. The analysis covers 402 Gradle job logs, including that uncached validation job in each pipeline. All 200 compared Gradle jobs passed; all 227 executed parent-job names match, with no retries. Median job duration change is calculated from each matched Gradle job's percentage change.Pipeline duration includes non-Gradle jobs, merges job-running intervals, and excludes queues and retries. Job durations include runner overhead. System-test durations include the parent trigger's downstream wait; the separate GitHub
Run system testsworkflow is excluded. Duration calculation. Cache lookup rates use total hits/lookups. Restored/actionable task counts and Gradle durations use the invocation that emitted each S3 summary; unrelated nested-build summaries and follow-up validation commands are excluded. Test-task reuse excludes skipped, no-source and up-to-date tasks;FROM-CACHEcan include local restoration.The master GitLab-cache pipeline
150683126below ran for commit5a9bf74ccd, the master parent merged by50df1a0547. It includes a broader JVM matrix, ARM64 and SSI smoke jobs, so the reported gains compare only the two S3 build cache pipelines. Runner load was not controlled; repeatability needs comparable runs across more commits.Timelines span each group's first start to last finish, including gaps. Parallel rows are not additive; minor jobs are omitted. Time zero is the first parent job, excluding its initial queue. The master reference ends at
48m29sversus GitLab's48m28s; the initial S3 run ends at45m28sversus45m27s, and the warm run at31m09sversus31m03s. Both S3 runs passed without retries.Master GitLab-cache pipeline (2026-11-05)
=> pipeline
150683126gantt title Master GitLab-cache run - pipeline 150683126 dateFormat YYYY-MM-DD HH:mm:ss axisFormat %M:%S tickInterval 5minute todayMarker off section Parent pipeline Build and test compilation : 2000-01-01 00:00:36, 2000-01-01 00:12:11 Instrumentation tests [144] : 2000-01-01 00:07:02, 2000-01-01 00:48:29 Latest-dependency tests [54] : 2000-01-01 00:07:10, 2000-01-01 00:41:07 Smoke tests [144] : 2000-01-01 00:07:16, 2000-01-01 00:41:17 SSI smoke tests [144] : 2000-01-01 00:07:22, 2000-01-01 00:42:18 Other Gradle tests and checks : 2000-01-01 00:00:03, 2000-01-01 00:34:02 Packaging and system-test setup : 2000-01-01 00:06:54, 2000-01-01 00:13:28 Startup benchmarks [2] : 2000-01-01 00:07:48, 2000-01-01 00:21:19 Load and application benchmarks [6] : 2000-01-01 00:07:47, 2000-01-01 00:37:28 Benchmark reporting and configuration validation : 2000-01-01 00:21:24, 2000-01-01 00:41:17 section Downstream pipelines System tests : 2000-01-01 00:13:41, 2000-01-01 00:29:22 Test-matrix generation : 2000-01-01 00:13:44, 2000-01-01 00:15:06 SSI system tests : 2000-01-01 00:15:06, 2000-01-01 00:29:21 section Comparison scale 50-minute boundary :milestone, 2000-01-01 00:50:00, 0sThe last Gradle job,
test_inst: [zulu8, 5/8], ran for40m12sand finished at48m29s. System tests finished at29m22s.Warm S3 build cache pipeline (hot cache, empty commit, best case scanario)
=> pipeline
150859060gantt title Warm S3 build cache run - pipeline 150859060 dateFormat YYYY-MM-DD HH:mm:ss axisFormat %M:%S tickInterval 5minute todayMarker off section Parent pipeline Build and test compilation : 2000-01-01 00:00:00, 2000-01-01 00:06:41 Instrumentation tests [48] : 2000-01-01 00:04:17, 2000-01-01 00:16:38 Latest-dependency tests [30] : 2000-01-01 00:04:37, 2000-01-01 00:18:10 Smoke tests [48] : 2000-01-01 00:06:42, 2000-01-01 00:29:24 Other Gradle tests and checks : 2000-01-01 00:00:01, 2000-01-01 00:19:29 Packaging and system-test setup : 2000-01-01 00:05:16, 2000-01-01 00:11:43 Startup benchmarks [2] : 2000-01-01 00:06:02, 2000-01-01 00:19:59 Benchmark reporting and configuration validation : 2000-01-01 00:20:00, 2000-01-01 00:25:03 Test-result aggregation and pipeline finalization : 2000-01-01 00:29:25, 2000-01-01 00:31:09 section Downstream pipelines System tests : 2000-01-01 00:11:44, 2000-01-01 00:23:11 Test-matrix generation : 2000-01-01 00:11:45, 2000-01-01 00:13:17 SSI system tests : 2000-01-01 00:13:18, 2000-01-01 00:23:11 section Comparison scale 50-minute boundary :milestone, 2000-01-01 00:50:00, 0sThe last Gradle job,
test_smoke: [17, 8/8], ran for22m38sand finished at29m24s. System tests finished at23m11s.Smoke tests were the last test group in the warm run, finishing at
29m24s. Instrumentation and latest-dependency tests finished at16m38sand18m10s; system tests finished at23m11s, with benchmark reporting and configuration validation at25m03s. Further instrumentation reductions save runner time.Smoke tests cannot benefit from the Gradle S3 Build Cache ; in hot cache situation, smoke tests or child pipelines – like system tests – will determine the pipeline end.
Remaining cache misses
The warm run had 3,692 misses across 127,093 lookups (2.9%) and 3,803 writes (18.1% of the initial 21,048). Writes count operations, not unique cache keys.
Spotless: 1,157 writes. Muzzle's eight shards: 1,647 writes, including 283 in
muzzle: [4/8]. Other jobs: 999 writes. Spotless and Muzzle account for 73.7% of writes. Both initial and warm jobs passed. Per-task key/input hashes were not retained, so remaining miss causes need targeted comparison.Follow-up: analyze why they miss, by comparing keys with
--info -Dorg.gradle.caching.debug=true, including dependencies, formatter state, toolchains, and path/ref-dependent inputs. Identical source trees can have different inputs. Cache-miss diagnostics.Remaining tasks
Correctness checks before rollout
Verify cache invalidation for dd-trace-java specifics: changes to source files, dependencies, test options, JDK or builder tags, architecture, environment, native tools, services and nested builds. Disable caching when an input cannot be declared. Integration-test caching.
dd-trace-java.muzzlereports additional JVM data in test task inputs #12631dd-trace-java.test-jvm-constraintsreports additional JVM data in test task inputs #12630dd-trace-java.test-jvm-constraintsreport architecture in test task inputs #12635Ensure build and test jobs resolve the same locked dependencies. The S3 build cache does not refresh dependencies, and
--refresh-dependenciesdoes not update locks. Dependency caching, dependency locking.CI builder image, should they be accounted, in particular if JVM are fingerprinted in testJvm and muzzle ?
In test-containers track the actual version or hash of
icr.io/appcafe/websphere-traditional:latest, or runwebsphere-jmxtests uncached after a fresh pull.alwaysPull()does not run when Gradle restores test results. Image pull policy.Compare with
--no-build-cache --rerun-tasks; check artifacts, test results and executed-test counts.TestAgent needed fingerprinting as well
Now
validate_buildis a matrix job with and without build cache, both are useful to control correctness.Allow tweaking behavior on demand.
Do we need to check cached outputs for secrets?
Other tasks
SKIP_BUILD_CACHEas CI option via commit message #13220Test JVM
Container images
Tests having a moving version tag are a problem as they are not accounted in task's fingerprints. The following is a proposed solution to account for them.
Proposed build-logic DSL:
dependencies { testContainerImage(image("cassandra:4", "test.cassandra.image")) }The factory method
imagedeclares the reference and explicit system-property name;testContainerImageassociates it with the consuming test suite. The plugin would:TESTCONTAINERS_HUB_IMAGE_NAME_PREFIXand JDBC's SQL Server mapping.test.cassandra.imageto the fullregistry/repository@sha256:...reference on the consuming test tasks.Tests then use
System.getProperty("test.cassandra.image"), retaining any Testcontainers compatibility mapping. Both property name and value are Gradle task inputs. A changed digest changes the key. Resolution indoFirstwould be too late.This syntax can be supplied through DependencyHandler extensions; the plugin must provide the DSL and OCI resolver. No native Gradle OCI resolution is implied.
Moving test references found: WebSphere
latest, Google Cloud CLIemulators, Cassandra3/4, MySQL8.0, PostgreSQL16-alpine, implicit SQL Serverlatest, Oracle23.5-slim-faststart, and Testcontainers' Alpine3.17helper. Apply digest tracking to release tags too: they can be republished. Resolve the effective CI mirror, whose contents can differ from upstream.CI builders
Builder
ci-*tags can move. Track the actual builder digest as an input to affected cacheable Gradle tasks, and retain architecture separation.Test counts
The initial and warm aggregates match for all 172 counted jobs: 400,054 reported tests each. These include restored results by the build cache.
Muzzle
The planner discovers dependency versions; the plugin registers per-version checks with stable names derived from pass/fail, dependency coordinates and the optional directive name. Discovery and planning are not cached by the S3 build cache. Artifact downloads use Gradle's separate dependency cache.
Each
MuzzleTaskis already cacheable. Reuse depends on its implementation, directive and instrumentation/tooling/dependency classpaths; a stable task name alone does not guarantee a hit. Each planned check has two build-cache outcomes:reports/<task>.txtand skip the compatibility assertion.A warm run can therefore mix restored and executed checks: the planner is free to select versions whose results have not been cached. Random version sampling can change that selection between runs.
muzzle-endis not cacheable; it regenerates reports from both restored and newly produced result files.Latest dependencies and scheduled locks
The scheduled lock refresh does not change test dependency selection in this PR. It runs in
buildandvalidate_build, not inbuild_testsor test jobs, and the rewritten locks are not shared.buildalso uses-PskipTests, so it produces no cached test results against those refreshed locks.Before and after the migration, test jobs resolve dependencies using their checked-in locks. The S3 build cache changes output reuse: matching results from earlier test jobs can now be restored across pipelines. Outputs built with refreshed dependencies are reusable only when the consuming task's fingerprints match. No lock-refresh or lock-handoff change is needed for this migration.
Remaining input checks
Standard sources, classpaths and test options are tracked. Check full JDK/native-tool versions, relevant environment variables, service state and dependencies resolved inside nested builds. Paths and moving labels do not identify their contents. The S3 build cache adds no inputs automatically.
Compare representative results with
--no-build-cache --rerun-tasks. For untrackable external state, disable caching and up-to-date reuse on affected tasks. Keep release isolation and independentvalidate_buildchecks.Identified bug post activation of the S3 build cache
Nightly cache warming
The
POPULATE_CACHEpopulates dependency/plugin caches. Which is still useful, during build or tests. Moreover, running this nightly helps keeping the Gradle S3 Build Cache in a steady state.Success measures and remaining work
Primary metrics: median/tail job duration, pipeline critical path, S3 build cache lookup hit rate and Gradle
FROM-CACHE, split by job family and architecture. Also track writes/misses, transfer time/bytes, cache errors and actual test executions. The plugin's cumulative cache-time estimate is not pipeline wall time.