Skip to content

[MINOR][VL] Cache Maven distribution in x86 CI - #13662

Closed
felipepessoto wants to merge 2 commits into
apache:mainfrom
felipepessoto:felipepessoto-maven-distribution-cache
Closed

felipepessoto wants to merge 2 commits into
apache:mainfrom
felipepessoto:felipepessoto-maven-distribution-cache

Conversation

@felipepessoto

@felipepessoto felipepessoto commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Cache build/.mvn in the 21 Maven-using jobs defined directly in velox_backend_x86.yml, reducing repeated downloads and exposure to Maven Central HTTP 429s.

A reusable action reads maven.version from pom.xml without invoking Maven and keys the cache by version, OS, and architecture. Cache misses use the unchanged wrapper. No dependency caching (~/.m2), download-retry changes, or Docker image changes. Includes documentation.

How was this patch tested?

Offline CentOS 8/Ubuntu 24.04 bootstrap/restore checks and x86 actionlint passed for the unchanged cache implementation. The standalone Python tests and their format-check wiring have been removed. Workflow YAML, license-header, and whitespace checks pass.

Real CI: fast-build, Spark 4.2 build, and Ubuntu TPC jobs passed on 27e48f54c (run 44182492158). Fast-build saved the cache; Spark 4.2 restored it and reused Maven without downloading again. Relevant log excerpts, preserved inline (UTC):

2026-11-17T22:01:00.2675138Z Cache saved with key: maven-distribution-v1-3.9.16-Linux-X64
2026-11-17T22:05:24.5239332Z Cache restored from key: maven-distribution-v1-3.9.16-Linux-X64
2026-11-17T22:05:24.6072232Z Using downloaded Maven: /__w/gluten/gluten/build/.mvn/apache-maven-3.9.16/bin/mvn (version 3.9.16)

This confirms cache behavior, not full CI completion. The original CentOS 8/Spark 3.5/Java 8 case was still queued when the evidence was captured.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: GitHub Copilot 1.0.106-8.unstable.r43566476370.g869eef3 (GPT-6.1 Sol, gpt-6.1-sol)

@github-actions github-actions Bot added CORE works for Gluten Core INFRA DOCS labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@felipepessoto
felipepessoto marked this pull request as ready for review November 17, 2026 22:58
Copilot AI balanced review requested due to automatic review settings November 17, 2026 22:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the Maven distribution caching change.

No open issues 🎉

What changed in this PR

This PR caches the Maven distribution across 21 Maven-using jobs defined directly in the Velox x86 workflow, reducing repeated downloads and exposure to Maven Central rate limits.

Changes:

  • Adds a reusable action that reads the pinned Maven version without invoking Maven and caches build/.mvn by version, runner OS, and architecture.
  • Restores the cache after checkout while preserving wrapper behavior on cache misses; dependency caches and Docker images remain unchanged.
  • Adds regression tests, runs them in the format workflow, and documents the cache’s scope.
File Description
gluten-ut/​src-ci/​test/​python/​test_maven_distribution_cache.py Tests version extraction, cache keys, and placement before Maven builds.
docs/​backends/​velox/​developers/​velox-backend-CI.md Documents cache behavior, coverage, and exclusions.
.github/​workflows/​velox_backend_x86.yml Adds the cache action to 21 directly defined Maven-using jobs.
.github/​workflows/​code_format.yml Runs regression tests and expands relevant path triggers.
.github/​actions/​cache-maven/​action.yml Defines version extraction and Maven distribution caching.

Review effort: Balanced

@felipepessoto

Copy link
Copy Markdown
Contributor Author

@LuciferYang, @yaooqinn could you review #13662? CI is green. This caches the Maven distribution for Velox x86 CI to reduce repeated downloads and HTTP 429s. Real cache save/restore evidence is included, and build/mvn is unchanged.

@zhouyuan, #13662 uses actions/cache for the Maven distribution only (~8.9 MiB), not Maven dependencies. Save/restore is already verified in CI.

Switching to Apache Stash would follow #12820 and avoid consuming the shared Actions cache quota. The downside is additional container tooling (python3, gh, jq), executable-permission handling, and coordinating parallel saves. Keeping actions/cache is simpler, and the storage footprint is much smaller than Delta’s multi-GB caches.

Would you prefer Stash here too, or is actions/cache acceptable for this small distribution cache?

- name: Cache Maven distribution
uses: actions/cache@v4
with:
path: build/.mvn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The 429s this targets come from one URL: build/mvn line 69 downloads Maven from a hardcoded repo1.maven.org URL. The root pom.xml already resolves dependencies from the GCS mirror first (#11545), and Spark's build/mvn downloads the distribution from that mirror, falling back to archive.apache.org. The mirror has 3.9.16.

Switching that URL, with a fallback for versions the mirror hasn't synced, is a one-file change. It takes repo1 out of every path: the 29 jobs in other workflows that call build/mvn without this cache (two of them run inside x86, via iceberg-spark-ut), a new branch's first run, and local builds. This PR covers one workflow with 21 copied steps and a test to keep them in sync.

Could you link a job that failed with a 429? I'd rather change the download source first, here or in a separate PR, and then see whether the cache is still worth carrying.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @LuciferYang, agreed, fixing the download source first makes sense. The failure was in [this CentOS 8/Spark 3.5/Java 8 job](https://github.com/felipepessoto/gluten/actions/runs/44166328281/job/134336305147). Copying the relevant output here so it doesn’t depend on log retention:

curl: (22) The requested URL returned error: 429
ERROR: Failed to download Maven from https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.tar.gz

I’ve opened #13669 to use Apache’s CDN with archive fallback and SHA-512 verification. Would you prefer the GCS mirror as the primary source there?

The motivation for this cache was reliability, reducing repeated downloads and exposure to 429s, not faster CI. Your cold-cache point is valid: it doesn’t protect every bootstrap, whereas changing the source covers cold runs, other workflows, and local builds.

I’ll hold this cache PR while we validate the source change, then reassess whether caching adds enough benefit. If we keep it, I’ll address the cold-start coverage and test regex.

fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Cache Maven distribution
uses: actions/cache@v4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

actions/cache saves only in its post step, after the job succeeds. A fork run restores only from its own branch or the fork's main, and no push or scheduled run covers main. So a branch's first run gets its cache from whichever early container job succeeds first, normally build-fast-build-test. A PR that touches only a shim for Spark 3.4 through 4.1 or only tools/gluten-it has no such job, so its Maven jobs start together when build-native-lib-centos-8 finishes, and nearly all download Maven as they do today.

If build/mvn moves off repo1 (see my other comment), these misses only cost a mirror download. Otherwise, a container job after detect-changes that checks out, runs this action, then build/mvn --version would seed the cache. A host job won't work: actions/cache hashes the compression method into the cache version, and the ubuntu-24.04 host has zstd, while the container jobs in run 44182492158 used gzip.

builds = [
index
for index, step in enumerate(steps)
if re.search(r"\$MVN_CMD\b|\bbuild/mvn\s", step.get("run", ""))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The job detection here matches $MVN_CMD and build/mvn followed by whitespace, but not ${MVN_CMD}, ${{ env.MVN_CMD }}, or a quoted "$GITHUB_WORKSPACE/build/mvn". A Maven step written one of those ways isn't detected, so its job passes without the cache step. Nothing in the file uses those forms today.

r"\$\{?MVN_CMD\b|env\.MVN_CMD\b|\bbuild/mvn[\s\"']" covers them and still classifies every current job the same way. Plain \bbuild/mvn\b is too loose: it matches the build/mvn) in the detect-changes path regexes.

Copilot AI balanced review requested due to automatic review settings November 19, 2026 23:27
@github-actions github-actions Bot removed the CORE works for Gluten Core label Nov 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review identifies no active issues with the Maven distribution caching change.

No open issues 🎉

Review effort: Balanced

felipepessoto and others added 2 commits November 20, 2026 12:57
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the standalone cache test suite and its format-check step and path triggers. Leave the cache action and Velox job integration unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@felipepessoto
felipepessoto force-pushed the felipepessoto-maven-distribution-cache branch from ce2696e to 4ac6a11 Compare November 20, 2026 20:58
Copilot AI balanced review requested due to automatic review settings November 20, 2026 20:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the Maven distribution caching changes.

No open issues 🎉

Review effort: Balanced

@philo-he

Copy link
Copy Markdown
Member

Thanks for the PR. I'm not sure I have the full context.

Isn't Maven already installed in the Gluten Docker images that most of our CI jobs use? If not, could we add it to those images?

I'm also curious how other projects like Spark avoid downloading Maven from the official sites in every CI job. Is there a best practice we could follow?

@felipepessoto

Copy link
Copy Markdown
Contributor Author

Thanks for the PR. I'm not sure I have the full context.

Isn't Maven already installed in the Gluten Docker images that most of our CI jobs use? If not, could we add it to those images?

I'm also curious how other projects like Spark avoid downloading Maven from the official sites in every CI job. Is there a best practice we could follow?

I'll investigate further, but I guess because https://github.com/actions/runner-images/releases/tag/ubuntu24/20261004.327 upgraded Maven from 3.9.16 to 3.10.0 and then we made a change to require an exact version: https://github.com/apache/gluten/pull/13209/changes#diff-590845f9441f6be1f05f517fd1caf31d64d0b5126ea9a2a13d79c74f761417ce

@felipepessoto

Copy link
Copy Markdown
Contributor Author

Closing this without merging. After #13669 switched Maven bootstrap to Apache’s CDN, I checked 13 cold installs across #13512 (6), #13502 (5), and #13561 (2). All 13 downloaded Maven 3.9.16 and passed SHA-512 verification without this cache, with no logged retries or archive fallback. That included two runs of the CentOS 8 / Spark 3.5 / Java 8 case that originally hit HTTP 429.

From one of those CentOS jobs:

2026-11-21T02:20:47.7374003Z URL: https://dlcdn.apache.org/maven/maven-3/3.9.16/binaries/apache-maven-3.9.16-bin.tar.gz
2026-11-21T02:20:48.4893417Z apache-maven-3.9.16-bin.tar.gz: OK
2026-11-21T02:20:48.5538484Z Maven 3.9.16 installed successfully to /__w/gluten/gluten/build/.mvn/apache-maven-3.9.16

Four jobs failed after Maven started, while resolving maven-clean-plugin:3.2.0 in tools/gluten-it. #13703 addresses that separate plugin repository configuration; caching Maven itself would not help.

This is a small sample from one fork, but I don’t see a reason to add cache steps to 21 jobs now. We can revisit if cold Maven distribution downloads start failing again. Thanks for the review.

@felipepessoto
felipepessoto deleted the felipepessoto-maven-distribution-cache branch November 21, 2026 04:36
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.

4 participants