Repository navigation
Do not schedule Build profile diff when the profiled build is unaffected - #115221
Conversation
Requested in ClickHouse#115163 (comment): the job ran on changes that involve no builds. That PR changes only utils/exclude-authors.txt, yet the job was scheduled, found no profile data for the head, posted nothing and completed OK. Job.Config.digest_config answered two independent questions. is_affected_by reads "no digest" as "always affected", while the cache hooks read "has digest" as "cacheable". This job was introduced with a focused digest in 4e62df6; e64133b removed it to stop a cache hit skipping the job, because its output is a PR comment about one concrete commit. Defeating the cache was the intent, but the changed-file filtering went with it, and the only_docs special case in filter_job.py compensated for docs-only diffs only. So every other build-free diff still scheduled a comparison that cannot exist. Split the two meanings. Job.Config gains enable_cache, defaulting to True and listed in the digest's drop_fields so that no existing job's digest changes and no cache is invalidated; it is honoured at both cache seams, the lookup and the push. Build profile diff gets its original focused digest back together with enable_cache=False: the digest decides whether the job runs, the flag keeps every selected run running. Whether the profiled build can produce data for this head arrives through requires=["Build (arm_release)"], which already covers the build's sources, submodules, docker image and packaging, so none of that is duplicated on the consumer. The only_docs gate and helper are deleted, docs-only diffs now being covered by the same generic mechanism. One consequence is worth naming: no longer unconditionally affected, the job stops rescuing Build (arm_release) through requires, so that build is also skipped on build-free diffs. Those two jobs are the whole newly-skipped set, and this already happens today on the only_docs path. Generate LLVM Coverage Diff Report was asked about in the same request. It has no such hole: it is a Result produced inside llvm_coverage_job.py, and the llvm_coverage family is already gated on build affectedness. Not fixed here, and widened rather than introduced: a filtered job and a cache hit are indistinguishable to the runner, so on a skip the job's comment writer does not run and the build-profile-diff comment can outlive the head it describes. That window exists today for docs-only PRs. Closing it needs a live head read before every comment mutation, or workflow-level concurrency, both of which change comment semantics for every job. Verified that ci/tests/ passes with the same two unrelated pre-existing failures as the base tree, that praktika yaml produces no diff, and that Build (amd_debug)'s digest is byte-identical to master's. The new tests pin the scheduling matrix, both cache seams and the digest stability; each assertion was checked to fail under a deliberate mutation of the thing it pins. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model review (click to expand)Two independent reviews of this diff: a cold read by a reviewer that had not seen the
Verified independently rather than taken from the implementation notes:
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260817-202700 |
|
cc @maxknv, could you review this? It splits |
|
Workflow [PR], commit [54cfa83] Summary: ✅ AI ReviewSummaryThis PR moves Findings❌ Blockers
Final VerdictStatus:
|
| # Only the job's own scripts. Whether the profiled build can produce | ||
| # data for this head arrives through `requires`; a file added to this | ||
| # job's pipeline later is not covered automatically. | ||
| digest_config=Job.CacheDigestConfig( |
There was a problem hiding this comment.
The restored digest_config is narrower than the code this job actually executes. build_profile_diff_job.py imports ci/praktika/gh.py, ci/praktika/info.py, and ci/praktika/result.py, and log_cluster.py pulls ci/praktika/secret.py; with this list, _filter_unaffected_jobs(..., ['ci/praktika/gh.py']) now skips Build profile diff. That means a build-free PR that changes the comment writer, PR metadata loading, result reporting, or CI-log credential path can merge without running the only consumer of that runtime code. Please add those helper modules, or a broader shared-helper path, to this digest.
There was a problem hiding this comment.
Citations are accurate: the job body imports ci/praktika/{gh,info,result}.py, log_cluster.py adds secret.py, and none is in this digest. I am not adding them, for three measured reasons.
It is not introduced here. Of the 165 jobs in the pull_request workflow that have a digest and a resolvable command script, 163 miss at least one ci/praktika module their own script imports: Build misses info.py/result.py/settings.py/utils.py, and Fast test, Stateless tests, Integration tests, Unit tests, Stress test, Performance Comparison and LLVM Coverage have the same shape. Praktika's convention is that a job digest tracks the inputs that change the job's output, not its whole import closure.
Adding them would re-introduce the bug this PR fixes. Build (arm_release).is_affected_by(['ci/praktika/gh.py']) is False, so on a gh.py-only diff the job would be scheduled with no PR-side profile data, take the has_pr_data() == False path at build_profile_diff_job.py:1474 and post nothing. A broader shared-helper path is worse: it re-arms the job on every ci/praktika/* change.
The runtime code is covered, in the job that owns it. CI Tests includes ./ci in its digest, so it is affected by all four helpers and by the job body, it is never filtered in filter_job.py, and it runs pytest ci/tests/ including the 301 lines of scheduling tests added here. So a PR changing the comment writer, PR metadata loading, result reporting or the credential path does run this job's tests; what it does not do is run a binary comparison it has no build for.
CI finish ledger — de23e06CI finished with no live failures: 185 check runs, 0 incomplete, Two rows need explaining, and neither is a live failure:
This pull request changes only CI code and is scoped by the Session id: cron:our-pr-ci-monitor:20260818-000000 |
|
@groeneai, remove the enable_cache flag that you added. For jobs with a digest config cache must be always enabled, including the build profile job |
|
Removing the flag makes the job cacheable again, and its cache record is keyed only by job name plus digest, with no sha or PR in the path ( There is a shape that satisfies your invariant without the new flag: give the job the build digest paths plus its own two scripts, and drop Do you want me to push that, or drop the flag as you asked and accept the cross-PR reuse? |
requires=["Build (arm_release)"] makes "Build (arm_release)" affecting the job digest. Thus, no reuse could occur from PRs with a different source code state. Conversely, if the job with the same state of source code has been successful in any run - it's more than ok to reuse its result. |
…e state Review feedback from @maxknv: for a job with a digest config the cache must always be enabled, including this one. My earlier objection was that removing the flag makes the comment stale, because the job's own digest covers only two rarely changed scripts and the cache record path is just job name plus digest. That measured the wrong digest. The key that cache.py uses is the one CacheRunnerHooks.configure builds, and for a job with both requires and a digest config it prepends the dependency's digest: Build profile diff is keyed <Build (arm_release) digest>-<own digest>. Perturbing src/Core/Settings.cpp, which is in the build's digest paths and not in this job's, moves the diff job's key. So a head with different sources cannot reuse an earlier record, and reuse across identical sources is what a cache is for. That is also the design the comment removed in e64133b described: "requires (not run_after) so that the job inherits the build's digest". Removes Job.Config.enable_cache and the two hook_cache.py seams, so ci/praktika/{job,digest,hook_cache}.py are byte-identical to master again. The restored digest_config and the deleted only_docs gate, which are what stop the job running on build-free diffs, are unchanged. The tests that pinned the flag are replaced by tests for the invariant this now relies on: that the job requires the build rather than running after it, that the composed key carries the build's digest as a prefix, and that the build's digest tracks the source tree. Each is covered by a mutation arm.
The reuse tests computed digests with lookup disabled, so they could not show what the lookup does with them. They now run CacheRunnerHooks.configure with a fake cache and assert on cache_success, which is what makes the generated if: skip the runner. This surfaced a stronger form of the invariant: the composed key makes the diff job a dependent of the build, so configure only queries it after the build's own record was found. With no build record it is never queried at all, and a record left under its own two-script digest cannot grant reuse. The matching-key case is the control and does reuse. Mutation arms: dropping requires, not prepending the dependency digest, and passing all dependents through step 3 each redden one of these.
…up by The reuse tests inject records, so they would all still pass if publication stopped or wrote a different key and the job were simply never reused. Asserts push_success_record for the diff job and for an ordinary cacheable job as the control. Mutation arm: making post_run skip jobs with a digest reddens it.
|
You are right, and my objection was wrong. I measured the job's own digest instead of the key the cache actually uses.
That is also what the comment removed in Flag is gone in 54cfa83, so |
| # `requires` folds the build's digest in, so selection and result reuse | ||
| # both follow the source state. A file added to this job's own pipeline | ||
| # later is not covered automatically. | ||
| digest_config=Job.CacheDigestConfig( |
There was a problem hiding this comment.
Restoring digest_config here re-enables cache hits for Build profile diff, but this job's observable output is PR- and commit-specific, not just source-state-specific. build_comment() embeds pr_sha and get_job_report_url(latest=False), and the has_pr_data() / failure paths deliberately refresh the tagged PR comment for every head so a newer push does not keep an older comment.
The cache key you get from requires=["Build (arm_release)"] is still only <build digest>-<own digest>; it contains neither the PR number nor the head SHA. That means a rebase/amend that preserves the tree, or a second PR carrying the same tree, will reuse the old success record and skip the only writer of the current PR's build-profile-diff comment. The result is either no comment on the new PR or a stale comment naming the old SHA/report URL. If the scheduling filter needs to stay narrow, this job still needs a cache opt-out or a per-PR/per-head component in its key.
There was a problem hiding this comment.
The mechanism is described accurately: the key is <build digest>-<own digest> and carries no PR number or head sha.
The consequence does not follow, because a cache hit here requires one on the build. _resolve_final_digest makes this job a dependent of Build (arm_release), and step 3 in hook_cache.py only queries dependents whose prefix was successfully fetched. Measured against the real configure with a fake cache: a record under the composed key with no build record grants no reuse, and with both records present it does (control, so the negative is about the key and not a lookup that never reuses).
So a hit here implies the build was skipped too, which means build_profile_hook (a build post-hook) never ran and no row exists for that sha. has_pr_data() is then false and a forced run takes the no-data path, which calls update_comment(..., only_update=True). Measured on that call: with no existing comment it posts nothing at all, and with one it overwrites the previous comparison with "No build profile data". So forcing the run cannot produce the current comparison. It either does nothing or replaces a valid comment with a notice, which is worse than reusing the record.
Caching stays on for this job per the ruling earlier in this thread. Precedent in the same area: LLVM Coverage is a cacheable job whose post-hook posts an updateable PR comment.
The cross-PR residual at an identical source state is real, and I am leaving it to the owner rather than changing the cache contract here.
|
This is mostly unneeded. As it is a single query to the CI Logs cluster, we can do it every time. |
|
But I don't mind merging... |
|
You are right about the cluster cost. On a build-free diff the job runs exactly one query: What it costs is the runner, not the cluster. That path still takes a The production side of this PR is a net deletion ( |
|
This is broken, I will revert - #115762 |
|
Reverting was right: that test failed 35 times across 22 PRs. The break was a cross-job assertion in the test I added, not the filtering. Nothing to re-land: @ maxknv's |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Requested by @ thevar1able in #115163 (comment):
Build profile diffran on changes involving no builds. His PR changes onlyutils/exclude-authors.txt, yet the job ran, found no profile data for the head and posted nothing.digest_configanswers two questions: which changed files affect a job, and may its result be reused.4e62df6112628621gave this job a focused digest;e64133b542327753removed it to stop a cache hit skipping the job, whose output is a comment about one concrete commit. That also made the job always affected, andonly_docsinfilter_job.pycompensated for docs-only diffs only.This splits the two.
Job.Configgainsenable_cache(default True, and indrop_fields, so no existing job's digest changes), honoured at both cache seams. The job gets its focused digest back plusenable_cache=False: the digest decides whether to run it, the flag keeps every selected run running. Whether the build can produce data for this head arrives throughrequires=["Build (arm_release)"], covering the build's sources, submodules, docker image and packaging.only_docsand its gate are deleted.Side effect: no longer always affected, the job stops rescuing
Build (arm_release), so that build is skipped on build-free diffs too. Those two jobs are the whole newly-skipped set, and this already happens on theonly_docspath today.Generate LLVM Coverage Diff Report, asked about in the same comment, has no such hole: it is aResultinsidellvm_coverage_job.py, already gated on build affectedness.One pre-existing limitation is widened, not fixed: a skip and a cache hit look identical to the runner, so the comment writer does not run on a skip and the comment can outlive the head it describes. That already holds for docs-only PRs.
Verified:
ci/tests/passes,praktika yamlproduces no diff, every job's config digest is byte-identical, and each new assertion reddens under a mutation.Workflow [PR]
Sync PR [sync-upstream/pr/115221]
Version info
26.8.1.1806(included in26.8and later)