Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvcoord: don't construct roachpb.Spans needlessly in several spots #81938

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pkg/kv/kvclient/kvcoord/dist_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ func maybeSetResumeSpan(
// Case 2.
return
}
key := req.Header().Span().Key
key := req.Header().Key
if isReverse {
if !nextKey.Less(roachpb.RKey(key)) {
// key <= nextKey, so this request was not completed (case 3).
Expand All @@ -1832,17 +1832,17 @@ func maybeSetResumeSpan(
return
}

origSpan := req.Header().Span()
origHeader := req.Header()
if isReverse {
if hdr.ResumeSpan != nil {
// The ResumeSpan.Key might be set to the StartKey of a range;
// correctly set it to the Key of the original request span.
hdr.ResumeSpan.Key = origSpan.Key
} else if roachpb.RKey(origSpan.Key).Less(nextKey) {
hdr.ResumeSpan.Key = origHeader.Key
} else if roachpb.RKey(origHeader.Key).Less(nextKey) {
// Some keys have yet to be processed.
hdr.ResumeSpan = new(roachpb.Span)
*hdr.ResumeSpan = origSpan
if nextKey.Less(roachpb.RKey(origSpan.EndKey)) {
*hdr.ResumeSpan = origHeader.Span()
if nextKey.Less(roachpb.RKey(origHeader.EndKey)) {
// The original span has been partially processed.
hdr.ResumeSpan.EndKey = nextKey.AsRawKey()
}
Expand All @@ -1854,16 +1854,16 @@ func maybeSetResumeSpan(
// doesn't know any better). In that case, we correct it to the EndKey
// of the original request span. Note that this doesn't touch
// ResumeSpan.Key, which is really the important part of the ResumeSpan.
hdr.ResumeSpan.EndKey = origSpan.EndKey
hdr.ResumeSpan.EndKey = origHeader.EndKey
} else {
// The request might have been fully satisfied, in which case it doesn't
// need a ResumeSpan, or it might not have. Figure out if we're in the
// latter case.
if nextKey.Less(roachpb.RKey(origSpan.EndKey)) {
if nextKey.Less(roachpb.RKey(origHeader.EndKey)) {
// Some keys have yet to be processed.
hdr.ResumeSpan = new(roachpb.Span)
*hdr.ResumeSpan = origSpan
if roachpb.RKey(origSpan.Key).Less(nextKey) {
*hdr.ResumeSpan = origHeader.Span()
if roachpb.RKey(origHeader.Key).Less(nextKey) {
// The original span has been partially processed.
hdr.ResumeSpan.Key = nextKey.AsRawKey()
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (tp *txnPipeliner) chainToInFlightWrites(ba roachpb.BatchRequest) roachpb.B
} else {
// Transactional reads and writes needs to chain on to any
// overlapping in-flight writes.
s := req.Header().Span()
s := req.Header()
tp.ifWrites.ascendRange(s.Key, s.EndKey, writeIter)
}
}
Expand Down