Skip to content

Refactor cost model by splitting up the various steps into defined tiebreakers#3993

Open
alecgrieser wants to merge 18 commits intoFoundationDB:mainfrom
alecgrieser:cost-model-refactoring
Open

Refactor cost model by splitting up the various steps into defined tiebreakers#3993
alecgrieser wants to merge 18 commits intoFoundationDB:mainfrom
alecgrieser:cost-model-refactoring

Conversation

@alecgrieser
Copy link
Collaborator

This is some refactoring work on the CascadesCostModels to allow the re-use of the various conditions that go into it. It breaks up the work into defined Tiebreaker steps, each of which does one comparison that can return either a negative number, a positive number, or zero, just like a Comparator. The cost models have then been modified so that they string those steps along, invoking each tie breaker in turn until it gets a non-zero one.

This comes from a larger branch of work from @normen662 that also does some pre-pruning along the way with a smaller set of these Tiebreakers. This work is a preliminary step to that, and as such, it does not aim to modify any behavior, instead just reorganizing the existing logic.

@alecgrieser alecgrieser added the cleanup Style/code cleanup with no behavioral change label Mar 6, 2026
One thing that was subtle was that the choice of PickLeft (always returning -1) meant that the comparison in the PlanGenerator was always updating to the new plans when one was available. This flips the comparison so that we now only update the plan if the new plan is strictly better than the old plan. Because the as-yet-best plan is the right operand in the comparator, ties will result in us sticking with that plan.
@alecgrieser alecgrieser force-pushed the cost-model-refactoring branch from d4bc436 to 18d995a Compare March 6, 2026 15:49
@alecgrieser alecgrieser marked this pull request as ready for review March 11, 2026 17:27
@alecgrieser alecgrieser requested a review from normen662 March 11, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Style/code cleanup with no behavioral change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants