Skip to content

kvserver: improve definition of equivalence classes#73951

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
aayushshah15:20211216_removeEquivalenceClassDeadCode
Dec 20, 2021
Merged

kvserver: improve definition of equivalence classes#73951
craig[bot] merged 1 commit intocockroachdb:masterfrom
aayushshah15:20211216_removeEquivalenceClassDeadCode

Conversation

@aayushshah15
Copy link
Copy Markdown
Contributor

This commit makes an effort to make equivalenceClasses more well-defined.
Previously, we would coalesce the equivalence classes for any two existing
replicas if they shared the exact same locality hierarchy (including the node
ids). This logic became ineffective with #51567 since we disallow multiple
replicas on a single node under all circumstances. Furthermore, coalescing the
equivalence classes for existing replicas did not buy us anything and instead
required a bunch of custom code for us to correctly deal with them.

This commit takes an opinionated approach and gets rid of the logic that
coalesces two existing replicas' equivalence classes together.

Release note: None

@aayushshah15 aayushshah15 requested a review from nvb December 16, 2021 23:18
@aayushshah15 aayushshah15 requested a review from a team as a code owner December 16, 2021 23:18
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@aayushshah15
Copy link
Copy Markdown
Contributor Author

First 3 commits are from #73597

@aayushshah15 aayushshah15 force-pushed the 20211216_removeEquivalenceClassDeadCode branch from fa8d46d to ec74388 Compare December 16, 2021 23:42
@nvb
Copy link
Copy Markdown
Contributor

nvb commented Dec 19, 2021

@aayushshah15 do you mind rebasing this on master now that #73597 has landed?

@aayushshah15 aayushshah15 force-pushed the 20211216_removeEquivalenceClassDeadCode branch from ec74388 to 85d6d5c Compare December 20, 2021 14:22
@aayushshah15
Copy link
Copy Markdown
Contributor Author

Done.

Copy link
Copy Markdown
Contributor

@nvb nvb left a comment

Choose a reason for hiding this comment

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

:lgtm: nice simplification! I'm glad we weren't missing something when discussing this.

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aayushshah15)


pkg/kv/kvserver/allocator.go, line 1082 at r1 (raw file):

	// pretty sure we won't want to remove immediately after adding it.
	// If we would, we don't want to actually rebalance to that target.
	var target *candidate

nit: var target, existingCandidate *candidate


pkg/kv/kvserver/allocator_scorer.go, line 771 at r1 (raw file):

}

// rebalanceOptions contains two candidate lists:

"two candidate lists" is no longer accurate.


pkg/kv/kvserver/allocator_scorer.go, line 775 at r1 (raw file):

// 1. an existing replica.
// 2. a corresponding list of comparable stores that could be legal replacements
// for the aforementioned existing replicas -- also ordered from `best()` to

Remove "also".


pkg/kv/kvserver/allocator_scorer.go, line 989 at r1 (raw file):

	results := make([]rebalanceOptions, 0, len(equivalenceClasses))
	for _, comparable := range equivalenceClasses {
		var candidates candidateList

nit: move this down right about the loop that populates it.


pkg/kv/kvserver/allocator_scorer.go, line 1058 at r1 (raw file):

func bestRebalanceTarget(
	randGen allocatorRand, options []rebalanceOptions,
) (*candidate, *candidate) {

Let's give these return vars names. That also lets us omit the repeat type. ) (target, existingCandidate *candidate) {

This commit makes an effort to make `equivalenceClass`es more well-defined.
Previously, we would coalesce the equivalence classes for any two existing
replicas if they shared the exact same locality hierarchy (including the node
ids). This logic became ineffective with cockroachdb#51567 since we disallow multiple
replicas on a single node under all circumstances.  Furthermore, coalescing the
equivalence classes for existing replicas did not buy us anything and instead
required a bunch of custom code for us to correctly deal with them.

This commit takes an opinionated approach and gets rid of the logic that
coalesces two existing replicas' equivalence classes together.

Release note: None
@aayushshah15 aayushshah15 force-pushed the 20211216_removeEquivalenceClassDeadCode branch from 85d6d5c to 7d51027 Compare December 20, 2021 16:06
Copy link
Copy Markdown
Contributor Author

@aayushshah15 aayushshah15 left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @nvanbenschoten)


pkg/kv/kvserver/allocator.go, line 1082 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

nit: var target, existingCandidate *candidate

Done.


pkg/kv/kvserver/allocator_scorer.go, line 771 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

"two candidate lists" is no longer accurate.

done.


pkg/kv/kvserver/allocator_scorer.go, line 775 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Remove "also".

done.


pkg/kv/kvserver/allocator_scorer.go, line 989 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

nit: move this down right about the loop that populates it.

done.


pkg/kv/kvserver/allocator_scorer.go, line 1058 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Let's give these return vars names. That also lets us omit the repeat type. ) (target, existingCandidate *candidate) {

done.

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 20, 2021

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 20, 2021

Build succeeded:

@craig craig bot merged commit 9838965 into cockroachdb:master Dec 20, 2021
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