Skip to content

Push base branches before head branches again - #370

Open
huydhn wants to merge 1 commit into
ezyang:mainfrom
huydhn:grouped-pushes
Open

huydhn wants to merge 1 commit into
ezyang:mainfrom
huydhn:grouped-pushes

Conversation

@huydhn

@huydhn huydhn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

ghstack 0.16.0 (#342) combined the base, head and orig pushes into one git push. The code comment said to go back to three pushes if GitHub saw the base and head updates out of order. That seems to be happening.

On pytorch/pytorch, when an update also moves the base branch, GitHub often runs every pull_request workflow twice on the same head commit, starting in the same second. One run in each pair gets cancelled by concurrency settings at random. Example: pytorch/pytorch#206339. CI tools that look at a single run can then show the cancelled run (pytorch/test-infra#9616).

Data from the latest update of 128 open ghstack PRs on pytorch/pytorch:

Update Same-second duplicate runs
ghstack ≥ 0.16, base moved 8 / 13
ghstack ≥ 0.16, base not moved 0 / 11
ghstack < 0.16, base moved 0 / 42
new stack 0 / 18

This PR restores the grouped pushes (base, then head/next, then orig) for updates. Creating a new stack still uses one push. Direct mode doesn't change, since it pushes no base branches. The cost is up to two extra pushes per ghstack submit.

Not a full revert of #342: its other speedups (narrower fetch, parallel PR lookups, --no-fetch) and later work built on it stay as they are.

Testing: lint is clean. test/land/invalid_resubmit.py.test fails, but it fails the same way on main.

ghstack 0.16.0 (ezyang#342) combined the base, head and orig pushes into one
`git push`, with a comment saying to go back to three grouped pushes if
GitHub saw the base and head updates out of order. That seems to be
happening: when an update also moves the base branch, GitHub often runs
every pull_request workflow twice on the same head commit.

Restore the grouped pushes (base, then head/next, then orig) for updates.
New stack creation still uses one push, and direct mode is unchanged
because it pushes no base branches.
@huydhn
huydhn marked this pull request as ready for review November 26, 2026 00:19
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: a0648c9
Pull-Request: #206701
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: 1747105
Pull-Request: #206701
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: 7821f21
Pull-Request: #206701
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: a7f5ce6
Pull-Request: #206701
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: a4dab99
Pull-Request: #206701
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: cb62f6c
Pull-Request: #206701
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: b47591f
Pull-Request: #206701
huydhn added a commit to pytorch/pytorch that referenced this pull request Nov 26, 2026
Testing ezyang/ghstack#370. Will be closed.


ghstack-source-id: 37a5ccd
Pull-Request: #206701
@huydhn

huydhn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

I tested this on a real 2-PR stack on pytorch/pytorch (pytorch/pytorch#206700, pytorch/pytorch#206701). There were 8 updates, and each one rebased onto a newer main commit, so the base branch moved every time. The updates alternated between this PR and its parent commit on main (ad9a604), so the push change is the only difference.

ghstack Updates PR updates with duplicate pull_request runs
this PR (grouped pushes) 4 0 / 8 (5 workflows, 5 runs each time)
main @ ad9a604 (single batched push) 4 8 / 8 (all 5 workflows ran twice, both runs created in the same second)

Creating the stack with this PR also gave no duplicates. CI runs on the test PRs were cancelled after counting.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant