Batch push webhook changed-path lookups into one Gitaly call
What does this MR do and why?
Gitlab::DataBuilder::Push.build previously issued one CommitDelta
RPC per commit (up to 20 per branch) to compute the push
webhook/integration payload's per-commit added/modified/removed
file lists. On pushes updating many branches at once this multiplied
into thousands of Gitaly calls — a production
Repositories::PostReceiveWorker job showed ~2207 Gitaly calls
dominated by CommitDelta.
This MR batches the changed-path lookup via FindChangedPaths:
- Non-merge commits use a single batched
find_changed_paths(commits, find_renames: false)call, with results grouped bycommit_id. - Merge commits use a per-merge
find_changed_pathsagainst aDiffTreeof the first parent, preserving the legacy first-parent diff semantics (Gitaly returns a blankcommit_idfor tree requests, so these are associated manually). - The per-commit N+1 and its
allow_n_plus_1_callsguard are removed.
On typical pushes this reduces the Gitaly call count from N + M to
1 + M (N non-merge, M merge commits).
Payload note: with find_renames: false, a pure rename now reports
the old path under removed and the new path under added (previously
added only). This is additive with no data loss; the webhook docs are
updated accordingly.
References
Closes #19600 (closed)
How to set up and validate locally
- Use a project with an active webhook or integration on push events.
- Push a branch containing several commits (and at least one merge commit).
- Observe the Gitaly call count for the
Repositories::PostReceiveWorkerjob /Gitlab::DataBuilder::Push.build:CommitDeltacalls are replaced by a singleFindChangedPathscall for non-merge commits (plus one per merge commit). - Confirm the webhook payload's per-commit
added/modified/removedlists are unchanged for non-merge and merge commits (merge commits diff against the first parent).
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.