Skip to content

Commit

Permalink
Merge #61535
Browse files Browse the repository at this point in the history
61535: base,kv: fix two error instantiations in the hot path r=stevendanna a=tbg

Found as part of the investigation in #61328, where these happened to
jump out at me in the CPU profile's top10 for a simple read-only
workload.

cc @cockroachlabs/kv

Release justification: low-risk perf improvements
Release note: None


Co-authored-by: Tobias Grieger <[email protected]>
  • Loading branch information
craig[bot] and tbg committed Mar 5, 2021
2 parents b703e66 + ac572af commit 9ccda03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/base/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import (
"github.com/cockroachdb/errors"
)

var errEnterpriseNotEnabled = errors.New("OSS binaries do not include enterprise features")

// CheckEnterpriseEnabled returns a non-nil error if the requested enterprise
// feature is not enabled, including information or a link explaining how to
// enable it.
//
// This function is overridden by an init hook in CCL builds.
var CheckEnterpriseEnabled = func(_ *cluster.Settings, _ uuid.UUID, org, feature string) error {
return errors.New("OSS binaries do not include enterprise features")
return errEnterpriseNotEnabled // nb: this is squarely in the hot path on OSS builds
}

// TimeToEnterpriseLicenseExpiry returns a duration object that measures the time until
Expand Down
4 changes: 3 additions & 1 deletion pkg/kv/kvclient/kvcoord/range_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ func (ri *RangeIterator) Valid() bool {
return ri.Error() == nil
}

var errRangeIterNotInitialized = errors.New("range iterator not intialized with Seek()")

// Error returns the error the iterator encountered, if any. If
// the iterator has not been initialized, returns iterator error.
func (ri *RangeIterator) Error() error {
if !ri.init {
return errors.New("range iterator not intialized with Seek()")
return errRangeIterNotInitialized // hot path
}
return ri.err
}
Expand Down

0 comments on commit 9ccda03

Please sign in to comment.