Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kv: combine heap allocations in maybeStripInFlightWrites
This commit combines two of the heap allocations incurred by 1PC calls to `maybeStripInFlightWrites` when making a shallow copy of the provided `BatchRequest` into a single allocation. In a write-heavy workload, these were observed to account for about **0.8%** of all heap allocations, meaning that this change should reduce heap allocations in that workload by about **0.4%**. ``` File: cockroach Type: alloc_objects Time: Dec 31, 2021 at 3:51am (UTC) Active filters: focus=maybeStripInFlightWrites Showing nodes accounting for 2259283, 1.37% of 164666499 total ----------------------------------------------------------+------------- flat flat% sum% cum cum% calls calls% + context ----------------------------------------------------------+------------- ... ----------------------------------------------------------+------------- 506152 100% | github.com/cockroachdb/cockroach/pkg/kv/kvserver.(*Replica).sendWithRangeID /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/replica_send.go:140 0 0% 0.63% 506152 0.31% | github.com/cockroachdb/cockroach/pkg/kv/kvserver.maybeStripInFlightWrites /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/replica_batch_updates.go:58 506152 100% | github.com/cockroachdb/cockroach/pkg/roachpb.(*EndTxnRequest).ShallowCopy /go/src/github.com/cockroachdb/cockroach/pkg/roachpb/api.go:797 (inline) ----------------------------------------------------------+------------- 720901 100% | github.com/cockroachdb/cockroach/pkg/kv/kvserver.(*Replica).sendWithRangeID /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/replica_send.go:140 0 0% 0.63% 720901 0.44% | github.com/cockroachdb/cockroach/pkg/kv/kvserver.maybeStripInFlightWrites /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/replica_batch_updates.go:62 720901 100% | github.com/cockroachdb/cockroach/pkg/roachpb.(*RequestUnion).MustSetInner /go/src/github.com/cockroachdb/cockroach/pkg/roachpb/batch_generated.go:385 ----------------------------------------------------------+------------- ```
- Loading branch information