Skip to content

storage: cheaper range key change detection #84379

@erikgrinaker

Description

@erikgrinaker

With combined point/range key iteration, we often find ourselves checking for changes to the range key by comparing the bounds to a previous range key, and then caching the range key stack. Something like:

if hasPoint, hasRange := iter.HasPointAndRange(); hasRange {
	if rangeBounds := iter.RangeBounds(); !rangeBounds.Key.Equal(rangeStart) {
		rangeStart = append(rangeStart[:0], rangeBounds.Key...)
		iter.RangeKeys().CloneInfo(&rangeKeys)

These constant key comparisons are expensive. Furthermore, it would be nice if it was safe to reuse the range key stack as long as the keys didn't change, so we wouldn't have to clone it.

This depends on cockroachdb/pebble#1775.

Jira issue: CRDB-17624

Epic CRDB-2624

Metadata

Metadata

Assignees

Labels

A-kv-replicationRelating to Raft, consensus, and coordination.A-storageRelating to our storage engine (Pebble) on-disk storage.C-performancePerf of queries or internals. Solution not expected to change functional behavior.T-storageStorage Team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions