Skip to content

ci: share native dependency fingerprint with builder image - #27330

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
daviszhen:ci/basic-image-tke
Aug 19, 2026
Merged

ci: share native dependency fingerprint with builder image#27330
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
daviszhen:ci/basic-image-tke

Conversation

@daviszhen

@daviszhen daviszhen commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #27333

What this PR does / why we need it:

  • Adds optools/images/ci-builder-fingerprint.sh, the canonical native-build contract shared by the Basic Image producer and CI consumers.
  • Includes the Go/toolchain, compiler/CMake, root Makefile, cgo sources, and third-party recipe inputs while ignoring generated native outputs and checkout paths.
  • Updates Dockerfile.ci-builder to emit the new fingerprint, with a schema-1 compatibility fallback for CI/MatrixOne merge-order safety.

The companion CI change is matrixorigin/CI#426. It consumes this fingerprint in TKE, restores prebuilt native dependencies only on an exact match, and falls back to source builds otherwise.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@daviszhen

Copy link
Copy Markdown
Contributor Author

@loveRhythm1990 loveRhythm1990 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.

Reviewed the fingerprint contract together with matrixorigin/CI#426. Overall the design is sound — but note that the fingerprint is the only thing standing between a dependency bump and a stale native build, so its coverage deserves a close look.

Why the fingerprint is the only guard

Every target in thirdparties/Makefile is an existence-only target — e.g.

install/include/xxhash.h:

has no prerequisites. So once a consumer restores thirdparties/install, make build will never rebuild a component, even if its tarball changed. There is no second line of defence behind the fingerprint comparison. That makes the coverage table below the whole correctness story.

Coverage

Captured correctly: all top-level tarballs, thirdparties/Makefile (including ONNX_REPO_COMMIT and the per-platform SHA256s), download / download_test, cgo sources, the root Makefile, and go/cc/cxx/cmake versions plus os/arch. A dependency bump changes the fingerprint and forces a source rebuild.

go.mod / go.sum are not captured, which is fine — only thirdparties/install is restored, and the Go module cache is a genuine cache that GOPROXY refills.

1. hash_thirdparties drops thirdparties/cuda/**

find . -maxdepth 1 -type f -print0

schema-1 used git rev-parse HEAD:thirdparties, which hashed the whole tree. thirdparties/cuda/Common/ holds several dozen headers that the new -maxdepth 1 no longer sees, so editing them will not invalidate the fingerprint. Today only GPU builds consume those headers and the CPU CI path does not fetch cuda, so the practical risk is low — but this is a capability regression versus schema-1 and it is exactly the class of miss that produces a silently stale native build. Suggest a full-tree walk that excludes generated output instead:

find . -type f -not -path './install/*' -not -path './_*' -print0

(Hashing working-tree content rather than the git tree is the right call otherwise — it is strictly more accurate for PR merge trees and dirty checkouts.)

2. xargs -0 sha256sum can hang on empty input

GNU xargs runs the command once with no arguments when input is empty, and sha256sum with no args reads stdin. hash_cgo's suffix filter currently always matches, but if it is ever narrowed this becomes a hang rather than an error. Please add -r / --no-run-if-empty to the three xargs -0 calls.

3. go env GOVERSION and PATH-dependent probes may make the fingerprint never match

Two determinism concerns, both fail-safe (they cause a source rebuild, not a stale restore) but both capable of silently reducing the cache hit rate to zero:

  • go env GOVERSION in a directory with a toolchain directive in go.mod can trigger toolchain resolution, and reports the toolchain version. The producer runs on main while a consumer runs on a PR branch; if the two go.mod toolchain lines differ at all, the fingerprint can never match.
  • cmake --version and compiler_version cc depend on PATH. The producer runs this script during docker build (with the Dockerfile's ENV applied); the consumer runs it under docker run ... bash as a non-login shell. If PATH differs, one side records unavailable and the comparison never succeeds.

Worth printing both fingerprints from a real CI run and diffing them before merging, rather than discovering after the fact that the optimisation never engages.

4. schema-1 compatibility branch has no removal trigger

The else branch in Dockerfile.ci-builder and the matching legacy acceptance on the CI side are correct — the old tree hash is actually stricter for thirdparties, and the compiler comes from the image itself so it is consistent by construction. No staleness risk. But nothing marks when it can go away. Please file a follow-up issue to delete both halves once the first schema-2 nightly image is published.

Merge order

Both sides are bidirectionally compatible, so either order is safe. Suggest landing this PR first, letting one nightly produce a schema-2 image, and only then landing matrixorigin/CI#426 — otherwise CI will silently take the fallback path throughout and the concerns in §3 will not surface.

The go env -w GOPROXY="${GOPROXY}" quoting fixes are necessary for the chained http://...|https://goproxy.cn|direct proxy on the CI side; CI#426 patches old MatrixOne checkouts with sed to compensate, which should be cleaned up once this lands.

@daviszhen

Copy link
Copy Markdown
Contributor Author

Addressed the fingerprint review findings in 1ac36bea3e (including the latest upstream merge).

  • hash_thirdparties now walks the complete native input tree, including thirdparties/cuda/**, while excluding generated install/ and _*/ output.
  • All three xargs calls use -r so empty input cannot block on stdin.
  • Tool discovery uses a stable image PATH; Go is probed with GOTOOLCHAIN=local from /, and cmake has an explicit unavailable fallback.
  • The contract is now schema 3, and CI logs both computed and cached fingerprints before comparison.

The schema-1 rollout removal is tracked in CI#427. Please re-review the updated PR.

@XuPeng-SH XuPeng-SH 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.

Exact-head deep review passed. I checked the shared producer/consumer contract with matrixorigin/CI#426: the consumer pins the pulled builder by immutable digest, computes the fingerprint inside that same image, restores only thirdparties/install on an exact schema-3 (or rollout-only legacy tree) match, and otherwise removes it before a source rebuild. The schema-3 input closure covers the current thirdparty tree, root/cgo native contract, target OS/arch, and fixed image toolchain; generated outputs are excluded. The legacy comparison is a full Git tree identity and is tracked for removal in CI#427. The configurable runtime base is guarded by ldconfig plus a real mo-service load, and the GOPROXY quoting is correct. Shell syntax, deterministic repeated fingerprint output, diff check, and the exact-head required CI set pass. No P0/P1/P2 correctness, lifecycle, or stale-artifact blocker found.

@mergify mergify Bot added the queued label Aug 19, 2026
@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-08-19 11:24 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • Checks passed · in-place
  • Merged2026-08-19 12:22 UTC · at 0c87cc4df7bfaa90968a85d11e53ac1200d7143d · squash

This pull request spent 58 minutes in the queue, including 57 minutes 24 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

@mergify
mergify Bot merged commit c30cd37 into matrixorigin:main Aug 19, 2026
30 of 31 checks passed
@mergify mergify Bot removed the queued label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants