Skip to content

Commit

Permalink
perf: replace LLRB-tree with btree in interval.Tree
Browse files Browse the repository at this point in the history
Fixes #6465
  • Loading branch information
yaojingguo committed May 26, 2017
1 parent d962689 commit a61191e
Show file tree
Hide file tree
Showing 11 changed files with 2,277 additions and 701 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/sqlccl/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func allRangeDescriptors(ctx context.Context, txn *client.Txn) ([]roachpb.RangeD
// spansForAllTableIndexes returns non-overlapping spans for every index and
// table passed in. They would normally overlap if any of them are interleaved.
func spansForAllTableIndexes(tables []*sqlbase.TableDescriptor) []roachpb.Span {
sstIntervalTree := interval.Tree{Overlapper: interval.Range.OverlapExclusive}
sstIntervalTree := interval.Tree{Overlapper: interval.ExclusiveOverlapper}
for _, table := range tables {
for _, index := range table.AllNonDropIndexes() {
if err := sstIntervalTree.Insert(intervalSpan(table.IndexSpan(index.ID)), false); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/command_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func (c *cmd) String() string {
// typically contain many spans, but are spatially disjoint.
func NewCommandQueue(coveringOptimization bool) *CommandQueue {
cq := &CommandQueue{
reads: interval.Tree{Overlapper: interval.Range.OverlapExclusive},
writes: interval.Tree{Overlapper: interval.Range.OverlapExclusive},
reads: interval.NewTree(interval.ExclusiveOverlapper),
writes: interval.NewTree(interval.ExclusiveOverlapper),
wRg: interval.NewRangeTree(),
rwRg: interval.NewRangeTree(),
coveringOptimization: coveringOptimization,
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func (ic *IntervalCache) MakeKey(start, end []byte) IntervalKey {

// Implementation of cacheStore interface.
func (ic *IntervalCache) init() {
ic.tree = interval.Tree{Overlapper: interval.Range.OverlapExclusive}
ic.tree = interval.NewTree(interval.ExclusiveOverlapper)
}

func (ic *IntervalCache) get(key interface{}) *Entry {
Expand Down
Loading

0 comments on commit a61191e

Please sign in to comment.