Skip to content

Commit 21d2d85

Browse files
committed
Minor cleanup
1 parent d88aa48 commit 21d2d85

File tree

3 files changed

+4
-73
lines changed

3 files changed

+4
-73
lines changed

bench_apply_metrics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func BenchmarkApplyDetailedMetricsDataSizeAndLatency(b *testing.B) {
155155
b.ReportAllocs()
156156
for i := 0; i < b.N; i++ {
157157
// Call the function under test.
158-
cmd.applyDetailedMetricsDataSizeAndLatency(fcmd, bytesSent, time.Now())
158+
cmd.applyDetailedMetricsDataSizeAndLatencyOnWrite(fcmd, bytesSent, time.Now())
159159
}
160160
}
161161

command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,7 +3818,7 @@ func (cmd *baseCommand) executeAt(ifc command, policy *BasePolicy, deadline time
38183818
dataSent := len(cmd.dataBuffer[:cmd.dataOffset])
38193819
_, err = cmd.conn.Write(cmd.dataBuffer[:cmd.dataOffset])
38203820
// Capture sent bytes and transmission time.
3821-
cmd.applyDetailedMetricsDataSizeAndLatency(ifc, dataSent, start)
3821+
cmd.applyDetailedMetricsDataSizeAndLatencyOnWrite(ifc, dataSent, start)
38223822
} else {
38233823
_, err = cmd.conn.Write(cmd.dataBuffer[:cmd.dataOffset])
38243824
}
@@ -4117,8 +4117,8 @@ func (cmd *baseCommand) applyDetailedMetricsConnectionAq(ifc command, startTime
41174117
}
41184118
}
41194119

4120-
// applyDetailedMetricsDataSizeAndLatency updates the detailed metrics for bytes sent and transmission time.
4121-
func (cmd *baseCommand) applyDetailedMetricsDataSizeAndLatency(ifc command, bytesSent int, startTime time.Time) {
4120+
// applyDetailedMetricsDataSizeAndLatencyOnWrite updates the detailed metrics for bytes sent and transmission time.
4121+
func (cmd *baseCommand) applyDetailedMetricsDataSizeAndLatencyOnWrite(ifc command, bytesSent int, startTime time.Time) {
41224122
end := uint64(time.Since(startTime).Microseconds())
41234123
ct := ifc.commandType()
41244124
dm := &cmd.node.stats.DetailedMetrics

node_stats.go

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -547,30 +547,6 @@ func (ns *nodeStats) UnmarshalJSON(data []byte) error {
547547
}
548548

549549
// Clone returns a deep copy of the nodeStats DetailedMetrics object
550-
// func (ns *nodeStats) cloneDetailedMetrics() *amap.Map[string, *amap.Map[commandType, *commandMetric]] {
551-
// cloned := amap.New[string, *amap.Map[commandType, *commandMetric]](0)
552-
553-
// for _, namespace := range ns.DetailedMetrics.Keys() {
554-
// for _, command := range ns.DetailedMetrics.Get(namespace).Keys() {
555-
// cloned.UpdateOrInsertFn(namespace, func(clonedInner *amap.Map[commandType, *commandMetric]) *amap.Map[commandType, *commandMetric] {
556-
// clonedInner.UpdateOrInsertFn(command, func(clonedCommand *commandMetric) *commandMetric {
557-
// clonedCommand.ConnectionAq = *ns.DetailedMetrics.Get(namespace).Get(command).ConnectionAq.Clone()
558-
// clonedCommand.Latency = *ns.DetailedMetrics.Get(namespace).Get(command).Latency.Clone()
559-
// clonedCommand.Parsing = *ns.DetailedMetrics.Get(namespace).Get(command).Parsing.Clone()
560-
// clonedCommand.BytesSent = *ns.DetailedMetrics.Get(namespace).Get(command).BytesSent.Clone()
561-
// return clonedCommand
562-
// }, func() *commandMetric {
563-
// return ns.newCommandMetric()
564-
// })
565-
// return clonedInner
566-
// }, func() *amap.Map[commandType, *commandMetric] {
567-
// return amap.NewWithValue(command, ns.newCommandMetric())
568-
// })
569-
// }
570-
// }
571-
572-
// return cloned
573-
// }
574550
func (ns *nodeStats) cloneDetailedMetrics() *amap.Map[string, *amap.Map[commandType, *commandMetric]] {
575551
// allocate the top‐level map once
576552
cloned := amap.New[string, *amap.Map[commandType, *commandMetric]](0)
@@ -609,27 +585,6 @@ func (ns *nodeStats) cloneDetailedMetrics() *amap.Map[string, *amap.Map[commandT
609585
}
610586

611587
// Clone returns a deep copy of the nodeStats DetailedResultCodes object
612-
// func (ns *nodeStats) cloneDetailedResultCodeCounts() *amap.Map[string, *amap.Map[commandType, *commandResultCodeMetric]] {
613-
// cloned := amap.New[string, *amap.Map[commandType, *commandResultCodeMetric]](0)
614-
615-
// for _, namespace := range ns.DetailedResultCodeCounts.Keys() {
616-
// for _, command := range ns.DetailedResultCodeCounts.Get(namespace).Keys() {
617-
// cloned.UpdateOrInsertFn(namespace, func(clonedInner *amap.Map[commandType, *commandResultCodeMetric]) *amap.Map[commandType, *commandResultCodeMetric] {
618-
// clonedInner.UpdateOrInsertFn(command, func(clonedCommand *commandResultCodeMetric) *commandResultCodeMetric {
619-
// clonedCommand.ResultCodeCounts = *ns.DetailedResultCodeCounts.Get(namespace).Get(command).ResultCodeCounts.CloneMap()
620-
// return clonedCommand
621-
// }, func() *commandResultCodeMetric {
622-
// return ns.newCommandResultCodeMetric()
623-
// })
624-
// return clonedInner
625-
// }, func() *amap.Map[commandType, *commandResultCodeMetric] {
626-
// return amap.NewWithValue(command, ns.newCommandResultCodeMetric())
627-
// })
628-
// }
629-
// }
630-
631-
// return cloned
632-
// }
633588
func (ns *nodeStats) cloneDetailedResultCodeCounts() *amap.Map[string, *amap.Map[commandType, *commandResultCodeMetric]] {
634589
cloned := amap.New[string, *amap.Map[commandType, *commandResultCodeMetric]](0)
635590

@@ -659,30 +614,6 @@ func (ns *nodeStats) cloneDetailedResultCodeCounts() *amap.Map[string, *amap.Map
659614
}
660615

661616
// Clone and reset returns a deep copy of the nodeStats DetailedMetrics object and resets the original
662-
// func (n *nodeStats) cloneAndResetDetailedMetrics() *amap.Map[string, *amap.Map[commandType, *commandMetric]] {
663-
// cloned := amap.New[string, *amap.Map[commandType, *commandMetric]](0)
664-
665-
// for _, namespace := range n.DetailedMetrics.Keys() {
666-
// for _, ct := range n.DetailedMetrics.Get(namespace).Keys() {
667-
// cloned.UpdateOrInsertFn(namespace, func(old *amap.Map[commandType, *commandMetric]) *amap.Map[commandType, *commandMetric] {
668-
// old.UpdateOrInsertFn(ct, func(od *commandMetric) *commandMetric {
669-
// od.ConnectionAq = *n.DetailedMetrics.Get(namespace).Get(ct).ConnectionAq.CloneAndReset()
670-
// od.Latency = *n.DetailedMetrics.Get(namespace).Get(ct).Latency.CloneAndReset()
671-
// od.Parsing = *n.DetailedMetrics.Get(namespace).Get(ct).Parsing.CloneAndReset()
672-
// od.BytesSent = *n.DetailedMetrics.Get(namespace).Get(ct).BytesSent.CloneAndReset()
673-
// return od
674-
// }, func() *commandMetric {
675-
// return n.newCommandMetric()
676-
// })
677-
// return old
678-
// }, func() *amap.Map[commandType, *commandMetric] {
679-
// return amap.NewWithValue(ct, n.newCommandMetric())
680-
// })
681-
// }
682-
// }
683-
684-
// return cloned
685-
// }
686617
func (n *nodeStats) cloneAndResetDetailedMetrics() *amap.Map[string, *amap.Map[commandType, *commandMetric]] {
687618
// one allocation for the top-level map
688619
cloned := amap.New[string, *amap.Map[commandType, *commandMetric]](0)

0 commit comments

Comments
 (0)