Skip to content

Conversation

ebarajas
Copy link
Contributor

@ebarajas ebarajas commented Oct 1, 2025

tl;dr

Added a new suite_bin_packing test ordering strategy that groups tests by suite and optimizes execution time.

What changed?

  • Added a new SuiteBinPacking strategy that groups tests by test suite and creates "chunks" for execution
  • Implemented TestChunk class to represent groups of tests that should be executed together
  • Updated the Redis worker to handle chunks alongside individual tests
  • Modified Minitest runner to execute chunks of tests
  • Added configuration options for controlling chunk size and duration limits
    • --suite-max-duration 180000  # Maximum chunk duration in ms (default: 120000)
      --suite-buffer 15            # buffer percentage (default: 10%)
      --timing-file path/to/timings.json  # Provide timing data
      

The strategy uses test timing data to:

  1. Keep small test suites together as a single unit
  2. Split large test suites into smaller-sized chunks using bin packing
  3. Order chunks by estimated duration (longest first)

Copy link
Contributor Author

ebarajas commented Oct 1, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ebarajas ebarajas marked this pull request as ready for review October 1, 2025 15:46
@ebarajas ebarajas force-pushed the ebarajas/10-01-support_suite-based_queueing branch 3 times, most recently from 243cd93 to ee83285 Compare October 1, 2025 17:20
@ebarajas ebarajas force-pushed the ebarajas/support-ordering-strategies branch from 9a1776f to 2818672 Compare October 1, 2025 19:40
@ebarajas ebarajas force-pushed the ebarajas/10-01-support_suite-based_queueing branch from 57648bc to 5f85a15 Compare October 1, 2025 19:40

# Separate chunks from individual tests
chunks = executables.select { |e| e.is_a?(CI::Queue::TestChunk) }
individual_tests = executables.select { |e| !e.is_a?(CI::Queue::TestChunk) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Conceptually, wondering if we should just stop using individual tests as a first class element in the queue, and just always use TestChunk. (An individual test can also be wrapped into a TestChunk).

Copy link
Contributor

Choose a reason for hiding this comment

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

The benefit is whenever we interact with an item from the queue, we have a single interface to deal with.

@index = tests.map { |t| [t.id, t] }.to_h
tests = Queue.shuffle(tests, random, config: config)
push(tests.map(&:id))
executables = Queue.shuffle(tests, random, config: config)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think "shuffle" (and the underlying "order_tests") now does more than reordering. Maybe we should rename this?
Or maybe separate to two function calls?

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.

2 participants