Skip to content

test_bot: avoid unbalanced shard#23023

Merged
MikeMcQuaid merged 2 commits into
mainfrom
avoid-unbalanced-shard
Jul 9, 2026
Merged

test_bot: avoid unbalanced shard#23023
MikeMcQuaid merged 2 commits into
mainfrom
avoid-unbalanced-shard

Conversation

@cho-m

@cho-m cho-m commented Jul 9, 2026

Copy link
Copy Markdown
Member

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

When there is a commonly used dependent, one group can end up with a majority or tested dependents and result in unbalanced shard.

As naive fix, limit the group size to balanced size and defer handling of remaining dependents in queue to later iterations of loop.


For now, mainly trying to see if we can get something usable in Homebrew/core.

There are likely better ways to improve sharding in future. Clustering around the most similar dependency trees could be better at reusing cached downloads

Alternatively, I wonder if there is a noticeable difference from the most basic sorted split into 4 groups. This at least is better at minimizing impact of possible race conditions (e.g. a PR getting merged in between CI runners can lead to a different sharding which can cause dependents to be skipped).

When there is a commonly used dependent, one group can end up with a
majority or tested dependents and result in unbalanced shard.

As naive fix, limit the group size to balanced size and defer handling
of remaining dependents in queue to later iterations of loop.
Copilot AI review requested due to automatic review settings July 9, 2026 03:41

Copilot AI 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.

Pull request overview

This PR adjusts test_bot’s formula dependents sharding logic to reduce the chance that a single highly-connected dependent group dominates a shard, leading to unbalanced workloads in CI.

Changes:

  • Switch seen tracking from an array to a Set when building dependent groups.
  • Cap the size of each discovered dependent group to a computed max_group_size before assigning groups to shards.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/test_bot/formulae_dependents.rb Outdated
Comment thread Library/Homebrew/test_bot/formulae_dependents.rb
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MikeMcQuaid MikeMcQuaid enabled auto-merge July 9, 2026 07:19
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jul 9, 2026
Merged via the queue into main with commit fa67017 Jul 9, 2026
44 of 47 checks passed
@MikeMcQuaid MikeMcQuaid deleted the avoid-unbalanced-shard branch July 9, 2026 07:47
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.

3 participants