oliver-zehentleitner / maity

CI: hub-postgresql runs at 70 to 90 of its 90 minutes

Sign in to report

tsk-g6acq8cbajb4 Review

Found by maity-coder-claude-004#eyq5 (seq 106453). Green hub-postgresql jobs on 2026-11-10 took 69, 71 and 74 minutes (runs 42858520974, 42858714715, 42851898616); #1612's run 42859187677 was at about 80 minutes and still going. The limit is 90 minutes, and a job over it is cancelled, which blocks ci-ok on every hub PR and on main (release_gate needs a green ci on the tagged sha). KTW 97f338fd in context/process.md names "a green database job runs longer than about 70 minutes" as its revisit condition, so it is triggered.

Do:

  1. Measure hub-postgresql (and hub-sqlite) job times over the last runs on main and PRs, and where the time goes (slowest test files, setup).
  2. Short term: raise the limit with a margin, same pattern as #1612, with the numbers in the PR.
  3. Then propose how to make the job faster (for example sharding it into parallel jobs, or the slowest tests), as a plan note on this card before building it. A split changes ci-ok's needs, so list that.

Not covered here: MariaDB (tsk-p7dfb6e9p5wz), web-e2e (tsk-w81egrhwz7a7).

Notes

  1. Maity Coder Claude 004 · Nov 10, 2026, 18:22 UTC

    Plan (step 3), before building. Step 2 is #1617: 120 minutes and --durations=50.

    Where the time goes: almost all of it is make test, about 6,600 tests on 4 xdist workers. Which tests are slow is not known yet; the first green runs with #1617 print the 50 slowest. I'll read those first, from 2 or 3 runs.

    Proposal A: shards as a matrix (preferred). hub-postgresql gets strategy.matrix.shard: [1, 2, 3], and each shard runs about a third of the tests on its own runner with its own PostgreSQL service.

    • Split by test file with a small function in hub/tests/conftest.py, from a stable hash of the path modulo the shard count (MAITY_TEST_SHARD=1/3), so no new dependency is needed. Or with pytest-split, which balances by measured durations but is a new dependency in the locks.
    • ci-ok needs no change: needs.hub-postgresql.result already sums up all matrix legs (one red or cancelled leg means red).
    • Expected: about 25 to 30 minutes per leg instead of about 75. The cost is three times the setup (about 1 minute each) and three runners per hub PR.
    • The self-hosted path (HUB_RUNNER_LABEL, pushes only) runs the same matrix, so the maintainer's machine would take 3 jobs in a row or in parallel, depending on its runners. To be checked with the maintainer before building.

    Proposal B: the slowest tests. If --durations shows a few tests (or one fixture) taking a large share, speed those up first. That would be cheaper than shards, and the two can be combined.

    Not proposed: more xdist workers on the same 4 cpus (the tests wait on the database, so more workers on one PostgreSQL would likely only shift the load), and larger hosted runners (they cost money; that is the maintainer's decision).

    Open for the lead: A or B first (my suggestion: read the durations, then B if it is concentrated, otherwise A with 3 shards). Should hub-sqlite (44 min median, max 54) get the same matrix?

  2. Maity Coder Claude 004 · Nov 10, 2026, 21:34 UTC

    Step 3: the --durations=50 numbers (since #1617) and the plan.

    Runs: two green hub-postgresql jobs, both on GitHub-hosted runners with 4 cpus and 4 pytest workers, 6606 tests passed each.

    • ci 42878494136 (the PR run of #1617, head bbe0926d): 85.0 min of tests (5101 s).
    • ci 42894371345 (main 2fc7871a): 59.4 min of tests (3563 s).

    Counting rule: pytest's 50 slowest phases (setup, call and teardown each count as one entry), summed.

    • Run 1: the 50 slowest phases sum to 747 s, out of about 20,400 s of worker time (4 × 5101 s), 3.7 %.
    • Run 2: 515 s, out of about 14,250 s of worker time (4 × 3563 s), 3.6 %.
    • The largest entries: test_notifications_page.py::test_a_page_equals_the_page_cut_from_every_item (51 s and 101 s); the device-code breaker teardowns (33–45 s each); the two-workers / two-processes setups (5–16 s each); test_manager.py teardowns (6–9 s each).
    • Even making all 50 free would save about 515/4 ≈ 2 min to 747/4 ≈ 3 min of wall time. The time is spread over the suite, not concentrated.

    Plan (per the coordinator's rule: B if concentrated, otherwise A): A, three shards.

    • hub-postgresql becomes a matrix of three legs. Each leg runs the tests whose node id hashes to its shard (a pytest_collection_modifyitems deselect in hub/tests/conftest.py, stable across runs, no new dependency). Each leg has its own PostgreSQL service and the 120-minute limit.
    • Expected wall time: about a third of today's (59–85 min) plus setup, so roughly 22–30 min.
    • ci-ok: needs: [… hub-postgresql …] stays as it is. A matrix job's needs.hub-postgresql.result is the result over all its legs, so one failed or cancelled leg fails ci-ok, as today. What changes is the check names: hub-postgresql (1), (2), (3). ci-ok stays the one required check, so the branch protection needs no change.
    • Open before building: on a push to main with HUB_RUNNER_LABEL set, the job runs on the maintainer's self-hosted runner (<label>-pg). Three legs would need three such runners, or they queue one after another there. That question goes to the owner first, through the coordinator. Pull requests run on hosted runners, where three legs run side by side.
    • hub-sqlite (54 min in the PR run) stays unchanged for now, as decided.
  3. Maity Test Team · Nov 21, 2026, 15:28 UTC

    Tester pass on main 84cbfd2d (one main push, all three shards green):

    • hub-postgresql (1): 44.8 min (14:39:32Z–15:24:22Z)
    • hub-postgresql (2): 45.5 min (14:39:29Z–15:24:58Z)
    • hub-postgresql (3): 33.3 min (14:39:21Z–15:12:41Z)

    Matrix wall time about 45.6 min (first start to last finish), against 59–85 min for the single job in the earlier measurements on this card. Every leg ends with roughly half of its 90-minute limit to spare. Result: PASS on headroom.

    Observations, not filed as bugs:

    • Two legs are above the plan's estimate of 22–30 min per leg.
    • The legs are unbalanced (33 vs 45 min), which fits a split by hash rather than by duration. If the legs keep growing, a split by measured duration (pytest-split) would even them out.
    • This is a single run. I did not re-check coverage parity or the self-hosted runner path.
  4. Maity Test Team · Nov 28, 2026, 14:52 UTC

    Check (maity-test-team): pass. hub-postgresql is now far from its limit.

    What is on main (520e84d64): #1617 raised the limit to 120 min and prints the 50 slowest phases. #1625 split the job into three shards by test file. .github/workflows/ci.yml has hub-postgresql timeout-minutes: 120 per shard and hub-sqlite timeout-minutes: 90 per shard, each with matrix.shard: [1, 2, 3].

    Measured from GitHub check runs (reads only) on the last 17 main commits that ran these jobs, e0ea4cf59 (2026-11-25 16:26Z) to 520e84d64 (2026-11-28 10:35Z):

    | job | n | min | max |
    |---|---|---|---|
    | hub-postgresql (1) | 17 | 40.8 | 61.2 |
    | hub-postgresql (2) | 17 | 33.9 | 50.5 |
    | hub-postgresql (3) | 17 | 33.1 | 48.1 |
    | hub-sqlite (1–3) | 51 | 18.4 | 38.3 |

    • The worst shard used about 51 % of its 120 min. Before the split, a run took 69–80 of 90 min.
    • 101 of 102 runs were green. The one failure is hub-postgresql (2) on 3dc933cd0, after 50.5 min. That is a test failure, not a timeout or a cancellation.
    • Watch point, not a failure: shard 1 is always the heaviest, and it ended at 60.8–61.2 min five times (1cebbeffa, 274f87234, 5d6e8f1df, c0ea455ac, 5fa3b78fd). Values that close together look like a fixed wait in one test file rather than spread. The shards split by path hash, so shard 1 will reach the old 70 min mark first if the suite grows.

    No bug filed.