forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage/rangefeed: push rangefeed.Filter into Raft goroutine
This commit creates a rangefeed.Filter object, which informs the producer of logical operations of the information that a rangefeed Processor is interested in, given its current set of registrations. It can be used to avoid performing extra work to provide the Processor with information which will be ignored. This is an important optimization for single-key or small key span rangefeeds, as it avoids some extraneous work for the key spans not being watched. For now, this extra work is just fetching the post-operation value for MVCCWriteValueOp and MVCCCommitIntentOp operations, but this can be extended in the future to include the pre-operation value as well. This will be important to avoid any perf regression when addressing cockroachdb#28666. Release note (<category, see below>): <what> <show> <why>
- Loading branch information
1 parent
e78a2b6
commit 7df3b6f
Showing
8 changed files
with
208 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package rangefeed | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/util/interval" | ||
) | ||
|
||
// Filter informs the producer of logical operations of the information that a | ||
// rangefeed Processor is interested in, given its current set of registrations. | ||
// It can be used to avoid performing extra work to provide the Processor with | ||
// information which will be ignored. | ||
type Filter struct { | ||
needVals interval.RangeGroup | ||
// TODO(nvanbenschoten): When addressing #28666, we can extend this with | ||
// a second `needPreVals interval.RangeGroup` to avoid fetching existing | ||
// values for spans that don't need them. | ||
} | ||
|
||
func newFilterFromRegistry(reg *registry) *Filter { | ||
f := &Filter{ | ||
needVals: interval.NewRangeList(), | ||
} | ||
reg.tree.Do(func(i interval.Interface) (done bool) { | ||
r := i.(*registration) | ||
f.needVals.Add(r.Range()) | ||
return false | ||
}) | ||
return f | ||
} | ||
|
||
// NeedVal returns whether the Processor requires MVCCWriteValueOp and | ||
// MVCCCommitIntentOp operations over the specified key span to contain | ||
// populated Value fields. | ||
func (r *Filter) NeedVal(s roachpb.Span) bool { | ||
return r.needVals.Overlaps(s.AsRange()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.