Skip to content

Commit 2aa83c8

Browse files
committed
fixes #181 req could make use of Message.Clone()
We've also added an inproc_reqlat mode to perf for testing this change to measure the impact.
1 parent f069ca6 commit 2aa83c8

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

perf/main.go

+23-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"fmt"
2222
"log"
2323
"os"
24-
"path"
2524
"strconv"
2625
"time"
2726
)
@@ -152,6 +151,25 @@ func doInprocLat(args []string) {
152151
os.Exit(0)
153152
}
154153

154+
func doInprocReqRepLatency(args []string) {
155+
if len(args) < 2 {
156+
log.Fatalf("Usage: inproc_lat <msg-size> <roundtrip-count>")
157+
}
158+
159+
size, err := strconv.Atoi(args[0])
160+
if err != nil {
161+
log.Fatalf("Bad msg-size: %v", err)
162+
}
163+
count, err := strconv.Atoi(args[1])
164+
if err != nil {
165+
log.Fatalf("Bad roundtrip-count: %v", err)
166+
}
167+
go ReqRepLatencyServer("inproc://inproc_lat", size, count)
168+
time.Sleep(10 * time.Millisecond)
169+
ReqRepLatencyClient("inproc://inproc_lat", size, count)
170+
os.Exit(0)
171+
}
172+
155173
func doInprocThr(args []string) {
156174
if len(args) < 2 {
157175
log.Fatalf("Usage: inproc_thr <msg-size> <msg-count>")
@@ -175,7 +193,7 @@ func main() {
175193

176194
tries := 0
177195
for tries = 0; tries < 2; tries++ {
178-
switch path.Base(args[0]) {
196+
switch args[0] {
179197
case "remote_reqlat":
180198
doRemoteReqRepLatency(args[1:])
181199

@@ -208,6 +226,9 @@ func main() {
208226
case "inproc_lat":
209227
doInprocLat(args[1:])
210228

229+
case "inproc_reqlat":
230+
doInprocReqRepLatency(args[1:])
231+
211232
default:
212233
args = args[1:]
213234
}

protocol/req/req.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ func (s *socket) send() {
8686
c.sendID = 0
8787
c.cond.Broadcast()
8888
}
89-
m := c.reqMsg.Dup()
89+
m := c.reqMsg
90+
m.Clone()
9091
p := s.readyq[0]
9192
s.readyq = s.readyq[1:]
9293

0 commit comments

Comments
 (0)