Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: Maintain a separate set of unquiesced replicas #24956

Merged
merged 4 commits into from
May 21, 2018

Conversation

bdarnell
Copy link
Contributor

This means that idle replicas no longer have a per-tick CPU cost,
which is one of the bottlenecks limiting the amount of data we can
handle per store.

Fixes #17609

Release note (performance improvement): Reduced CPU overhead of idle
ranges

The first five commits are from #24920; that PR should be merged and tested in isolation first.

@bdarnell bdarnell added the do-not-merge bors won't merge a PR with this label. label Apr 20, 2018
@bdarnell bdarnell requested review from tbg, petermattis and a team April 20, 2018 14:46
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@petermattis
Copy link
Collaborator

Reviewed 2 of 2 files at r1, 4 of 4 files at r2, 1 of 1 files at r3, 1 of 1 files at r4.
Review status: 2 of 5 files reviewed at latest revision, all discussions resolved, some commit checks failed.


pkg/storage/replica.go, line 592 at r4 (raw file):

	anotherOwnsLease := r.leaseStatus(*r.mu.state.Lease, r.store.Clock().Now(), r.mu.minLeaseProposedTS).State ==
		LeaseState_VALID &&
		!r.mu.state.Lease.OwnedBy(r.store.StoreID())

We've historically had subtle errors in logic like this. Perhaps this code should be restructured for testability. For example, the logic could be placed in a shouldCampaignOnWakeLocked function which takes a lease and other information and returns a boolean.


pkg/storage/replica.go, line 3914 at r8 (raw file):

// needsTick returns true if tick() should be called on this replica.
func (r *Replica) needsTick() bool {

Is this method being used anymore?


pkg/storage/store.go, line 511 at r8 (raw file):

	}

	// The uniquesed subset of mu.replicas.

s/uniquesed/unquiesced/g


pkg/storage/store.go, line 512 at r8 (raw file):

	// The uniquesed subset of mu.replicas.
	unquiescedReplicas syncutil.IntMap

syncutil.IntMap might not be a good idea here as it is optimized for read-mostly workloads.


Comments from Reviewable

@tbg
Copy link
Member

tbg commented Apr 23, 2018

:lgtm: mod @petermattis' comments and waiting until the precursor has merged.


Reviewed 2 of 4 files at r2, 2 of 2 files at r6, 1 of 1 files at r7, 2 of 2 files at r8.
Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


pkg/storage/store.go, line 2308 at r8 (raw file):

		return errors.Errorf("%s: replica already exists", repl)
	}
	s.unquiescedReplicas.Store(int64(repl.RangeID), unsafe.Pointer(repl))

LoadOrStore for symmetry (and an assertion)?


Comments from Reviewable

@bdarnell bdarnell removed the do-not-merge bors won't merge a PR with this label. label May 15, 2018
This means that idle replicas no longer have a per-tick CPU cost,
which is one of the bottlenecks limiting the amount of data we can
handle per store.

Fixes cockroachdb#17609

Release note (performance improvement): Reduced CPU overhead of idle
ranges
@bdarnell
Copy link
Contributor Author

Review status: 0 of 3 files reviewed at latest revision, 5 unresolved discussions.


pkg/storage/replica.go, line 3914 at r8 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Is this method being used anymore?

No. Removed.


pkg/storage/store.go, line 511 at r8 (raw file):

Previously, petermattis (Peter Mattis) wrote…

s/uniquesed/unquiesced/g

Done.


pkg/storage/store.go, line 512 at r8 (raw file):

Previously, petermattis (Peter Mattis) wrote…

syncutil.IntMap might not be a good idea here as it is optimized for read-mostly workloads.

OK, changed to a regular map with a mutex (a new mutex, since lock ordering gets tricky if we add it to Store.mu)


pkg/storage/store.go, line 2308 at r8 (raw file):

Previously, tschottdorf (Tobias Schottdorf) wrote…

LoadOrStore for symmetry (and an assertion)?

This has been changed to a regular map.


Comments from Reviewable

@petermattis
Copy link
Collaborator

:lgtm: modulo unaddressed comment.

Also, did you do any testing that shows that this reduces the CPU overhead of idle ranges? I believe I filed this issue when doing some scalability testing where I artificially created 500k ranges on a cluster. See the kv/splits/nodes=3 roachtest.


Review status: 0 of 3 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


pkg/storage/replica.go, line 592 at r4 (raw file):

Previously, petermattis (Peter Mattis) wrote…

We've historically had subtle errors in logic like this. Perhaps this code should be restructured for testability. For example, the logic could be placed in a shouldCampaignOnWakeLocked function which takes a lease and other information and returns a boolean.

Ping.


Comments from Reviewable

@bdarnell
Copy link
Contributor Author

Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions.


pkg/storage/replica.go, line 592 at r4 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Ping.

Done


Comments from Reviewable

@petermattis
Copy link
Collaborator

:lgtm:


Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@bdarnell
Copy link
Contributor Author

bors r=petermattis

I have not done any testing with large numbers of ranges, FYI.

craig bot pushed a commit that referenced this pull request May 21, 2018
24956: storage: Maintain a separate set of unquiesced replicas r=petermattis a=bdarnell

This means that idle replicas no longer have a per-tick CPU cost,
which is one of the bottlenecks limiting the amount of data we can
handle per store.

Fixes #17609

Release note (performance improvement): Reduced CPU overhead of idle
ranges


The first five commits are from #24920; that PR should be merged and tested in isolation first. 

25735: sql: fix null normalization r=RaduBerinde a=RaduBerinde

The normalization rules are happy to convert `NULL::TEXT` to `NULL`.
While both expressions evaluate to `DNull`, the `ResolvedType()` is
different. It seems unsound for normalization to change the type.

This issue is shown by trying to run a query containing
`ARRAY_AGG(NULL::TEXT)` through distsql planning: by the time the
distsql planner looks at it, the `NULL::TEXT` is just `DNull` (with
the `Unknown` type) and the distsql planner cannot find the builtin.

This change fixes the normalization rules by retaining the cast in
this case. In general, any expression that statically evaluates to
NULL gets a cast to the original expression type. The same is done in
the opt execbuilder.

Fixes #25724.

Release note (bug fix): Fixed query errors in some cases involving a
NULL constant that is cast to a specific type.

Co-authored-by: Ben Darnell <ben@cockroachlabs.com>
Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented May 21, 2018

Build succeeded

@craig craig bot merged commit a77ec80 into cockroachdb:master May 21, 2018
bdarnell added a commit to bdarnell/cockroach that referenced this pull request May 31, 2018
I suspect that cockroachdb#26257 is caused by the unquiescedReplicas map
introduced in cockroachdb#24956 getting out of sync with the per-replica
quiescent flag. Add debug pages to help us see if that's happening.

Release note: None
bdarnell added a commit to bdarnell/cockroach that referenced this pull request May 31, 2018
I suspect that cockroachdb#26257 is caused by the unquiescedReplicas map
introduced in cockroachdb#24956 getting out of sync with the per-replica
quiescent flag. Add debug pages to help us see if that's happening.

Release note: None
craig bot pushed a commit that referenced this pull request May 31, 2018
26269: server,ui: Add debugging for quiesced ranges r=bdarnell a=bdarnell

I suspect that #26257 is caused by the unquiescedReplicas map
introduced in #24956 getting out of sync with the per-replica
quiescent flag. Add debug pages to help us see if that's happening.

Release note: None

Co-authored-by: Ben Darnell <ben@cockroachlabs.com>
bdarnell added a commit to bdarnell/cockroach that referenced this pull request May 31, 2018
This reverts the main effect of cockroachdb#24956. The supporting infrastructure
is left in place to minimize merge conflicts and to aid in diagnosing
why the maps get out of sync.

Fixes cockroachdb#26257

Release note: None
craig bot pushed a commit that referenced this pull request May 31, 2018
26291: storage: Tick all replicas, not just unquiesced ones r=bdarnell a=bdarnell

This reverts the main effect of #24956. The supporting infrastructure
is left in place to minimize merge conflicts and to aid in diagnosing
why the maps get out of sync.

Fixes #26257

Release note: None

Co-authored-by: Ben Darnell <ben@cockroachlabs.com>
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.

4 participants