Skip to content

fix(sharding): count work already on shards when choosing family span - #90

Merged
aslushnikov merged 1 commit into
flakiness:mainfrom
miluoshi:fix/span-counts-shard-load
Nov 27, 2026
Merged

aslushnikov merged 1 commit into
flakiness:mainfrom
miluoshi:fix/span-counts-shard-load

Conversation

@miluoshi

Copy link
Copy Markdown
Contributor

Fixes #89.

computeSpan() estimated the most loaded host as setup + work / k, as if the shards were empty. So when a family with a cheap setup was placed after others, all its tests could go to one shard that already had as much work as the rest. The estimate now adds the load of the k least loaded shards, the same way selectShards() already counts shard.total. I also updated the SALT comment that describes this bound.

The new test is the example from the issue: without the fix the shards get 211 / 110, with it 161 / 161.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T12:28:09.896829Z f68043d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

computeSpan estimated the busiest host as if the shards were empty, so a family with a cheap setup placed after others could land in full on one already loaded shard. The estimate now includes the load of the k least loaded shards, which matches what selectShards already counts.

Fixes flakiness#89
Comment thread src/sharding.ts
* - makespan >= family.work / K + family.setup
* Makespan is AT LEAST the chunk of work + a family setup. We might have a shard that
* has only this chunk of a family
* - makespan >= max(load(K), (load(1) + ... + load(K) + family.work) / K)

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.

indeed! good point!

Comment thread src/sharding.ts
const total = estimateTotalWork(shards, [...families, heaviest]);
const missingSetups = shards.map(shard => missingSetup(shard, heaviest)).sort((a, b) => a - b);
// `load(i)` from the SALT comment, sorted from least to most loaded.
const hostLoads = shards.map(shard => shard.total + missingSetup(shard, heaviest)).sort((a, b) => a - b);

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.

can't we reuse missingSeutps defined on the previous line?

@flakiness-io

flakiness-io Bot commented Nov 27, 2026

Copy link
Copy Markdown

Test Results Summary

This comment shows the latest test results for this pull request.

Commit Status Test Results CI Runs
6a08922 ✅ Passed 236 passed · 1 skipped 3 runs

View full report

ℹ️ About Flakiness.io in GitHub

Your team has set up Flakiness.io pull request comments. This comment is updated when

  • The first test results arrive for this pull request
  • A later run reports more results for the same commit
  • A new commit is pushed and tested

Flakiness.io rewrites the comment in place, so it always reflects the most recently tested commit.

@aslushnikov
aslushnikov merged commit af1be75 into flakiness:main Nov 27, 2026
4 checks passed
@aslushnikov

Copy link
Copy Markdown
Contributor

@miluoshi thank you for the fix!

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.

Shard balancing can put all of a project's tests on one already busy shard

2 participants