Repository navigation
fix(sharding): improve shard selection heuristic - #85
Conversation
This produces a better shard selection and provides a regression test to prove it.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78e925ce07
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (let index = 0; index < shards.length; ++index) { | ||
| const shard = shards[index]; | ||
| const shardMissingSetup = missingSetup(shard, family); | ||
| const minOtherMissingSetup = cheapestK.has(index) ? cheapestKTotal - shardMissingSetup : cheapestKMinusOneTotal; |
There was a problem hiding this comment.
Recompute co-host setup as shards are selected
When K > 1, every candidate outside cheapestK is scored as if the same cheapest K - 1 shards will accompany it, but the final slice(0, K) can select several such candidates and none of those assumed co-hosts. This occurs when multiple low-load shards lack expensive dependencies while a more-loaded shard already has them; the average term then omits setup copies that the selected combination actually introduces, potentially inflating the total work and worsening the final balance. Score candidate combinations or select iteratively while recomputing the remaining co-host setup.
Useful? React with 👍 / 👎.
This came up as we were authoring the article about the algorithm. Turns out, the current shard selection is suboptimal. This patch improves selection logic and adds a regression test.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 038c741fbf
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This produces a better shard selection and provides a regression test
to prove it.