Skip to content

Commit

Permalink
kv/kvserverpb: rename RaftCommandFooter to MaxLeaseFooter
Browse files Browse the repository at this point in the history
Now that `ClosedTimestampFooter` exists, be more specific and symmetric.
  • Loading branch information
nvanbenschoten committed Feb 23, 2021
1 parent a2b9c19 commit e46511a
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 67 deletions.
10 changes: 5 additions & 5 deletions pkg/kv/kvserver/kvserverpb/proposer_kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/hlc"
)

var maxRaftCommandFooterSize = (&RaftCommandFooter{
var maxMaxLeaseFooterSize = (&MaxLeaseFooter{
MaxLeaseIndex: math.MaxUint64,
}).Size()

Expand All @@ -28,10 +28,10 @@ var maxClosedTimestampFooterSize = (&ClosedTimestampFooter{
},
}).Size()

// MaxRaftCommandFooterSize returns the maximum possible size of an
// encoded RaftCommandFooter proto.
func MaxRaftCommandFooterSize() int {
return maxRaftCommandFooterSize
// MaxMaxLeaseFooterSize returns the maximum possible size of an encoded
// MaxLeaseFooter proto.
func MaxMaxLeaseFooterSize() int {
return maxMaxLeaseFooterSize
}

// MaxClosedTimestampFooterSize returns the maximmum possible size of an encoded
Expand Down
113 changes: 59 additions & 54 deletions pkg/kv/kvserver/kvserverpb/proposer_kv.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions pkg/kv/kvserver/kvserverpb/proposer_kv.proto
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ message RaftCommand {
// updated accordingly. Managing retry of proposals becomes trickier as
// well as that uproots whatever ordering was originally envisioned.
//
// This field is set through RaftCommandFooter hackery.
// This field is set through MaxLeaseFooter hackery. Unlike with the
// ClosedTimestamp, which needs to be nullable in this proto (see comment),
// there are no nullability concerns with this field. This is because
// max_lease_index is a primitive type, so it does not get encoded when zero.
// This alone ensures that the field is not encoded twice in the combined
// RaftCommand+MaxLeaseFooter proto.
uint64 max_lease_index = 4;

// The closed timestamp carried by this command. Once a follower is told to
Expand Down Expand Up @@ -287,17 +292,17 @@ message RaftCommand {
reserved 1, 2, 10001 to 10014;
}

// RaftCommandFooter contains a subset of the fields in RaftCommand. It is used
// MaxLeaseFooter contains a subset of the fields in RaftCommand. It is used
// to optimize a pattern where most of the fields in RaftCommand are marshaled
// outside of a heavily contended critical section, except for the fields in the
// footer, which are assigned and marhsaled inside of the critical section and
// appended to the marshaled byte buffer. This minimizes the memory allocation
// and marshaling work performed under lock.
message RaftCommandFooter {
message MaxLeaseFooter {
uint64 max_lease_index = 4;
}

// ClosedTimestampFooter is similar to RaftCommandFooter, allowing the proposal
// ClosedTimestampFooter is similar to MaxLeaseFooter, allowing the proposal
// buffer to fill in the closed_timestamp field after most of the proto has been
// marshaled already.
message ClosedTimestampFooter {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/replica_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type ProposalData struct {
quotaAlloc *quotapool.IntAlloc

// tmpFooter is used to avoid an allocation.
tmpFooter kvserverpb.RaftCommandFooter
tmpFooter kvserverpb.MaxLeaseFooter

// ec.done is called after command application to update the timestamp
// cache and optionally release latches and exits lock wait-queues.
Expand Down
Loading

0 comments on commit e46511a

Please sign in to comment.