Skip to content

Commit

Permalink
tscache: use sklImpl as default tscache.Cache implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nvanbenschoten committed Nov 30, 2017
1 parent e29588c commit bcbde02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/storage/tscache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ type Cache interface {

// New returns a new timestamp cache with the supplied hybrid clock.
func New(clock *hlc.Clock) Cache {
if envutil.EnvOrDefaultBool("COCKROACH_USE_SKL_TSCACHE", false) {
return newSklImpl(clock)
if envutil.EnvOrDefaultBool("COCKROACH_USE_TREE_TSCACHE", false) {
return newTreeImpl(clock)
}
return newTreeImpl(clock)
return newSklImpl(clock)
}

// cacheValue combines a timestamp with an optional txnID. It is shared between
Expand Down
14 changes: 12 additions & 2 deletions pkg/storage/tscache/skl_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package tscache
import (
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
)
Expand Down Expand Up @@ -55,8 +56,16 @@ func (*sklImpl) ThreadSafe() bool { return true }

// clear clears the cache and resets the low-water mark.
func (tc *sklImpl) clear(lowWater hlc.Timestamp) {
tc.rCache = newIntervalSkl(tc.clock, MinRetentionWindow, sklPageSize)
tc.wCache = newIntervalSkl(tc.clock, MinRetentionWindow, sklPageSize)
pageSize := uint32(sklPageSize)
if util.RaceEnabled {
// Race testing consumes significantly more memory that normal testing.
// In addition, while running a group of tests in parallel, each will
// create a timestamp cache for every Store needed. Reduce the page size
// during race testing to accommodate these two factors.
pageSize /= 4
}
tc.rCache = newIntervalSkl(tc.clock, MinRetentionWindow, pageSize)
tc.wCache = newIntervalSkl(tc.clock, MinRetentionWindow, pageSize)
tc.rCache.floorTS = lowWater
tc.wCache.floorTS = lowWater
}
Expand Down Expand Up @@ -100,6 +109,7 @@ func (tc *sklImpl) AddRequest(req *Request) {
key := keys.TransactionKey(req.Txn.Key, req.TxnID)
tc.add(key, nil, req.Timestamp, req.TxnID, false /* readCache */)
}
req.release()
}

// ExpandRequests implements the Cache interface.
Expand Down

0 comments on commit bcbde02

Please sign in to comment.