Skip to content

Commit

Permalink
fixes #181 req could make use of Message.Clone()
Browse files Browse the repository at this point in the history
We've also added an inproc_reqlat mode to perf for testing this
change to measure the impact.
  • Loading branch information
gdamore committed Mar 11, 2020
1 parent f069ca6 commit 2aa83c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
25 changes: 23 additions & 2 deletions perf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"log"
"os"
"path"
"strconv"
"time"
)
Expand Down Expand Up @@ -152,6 +151,25 @@ func doInprocLat(args []string) {
os.Exit(0)
}

func doInprocReqRepLatency(args []string) {
if len(args) < 2 {
log.Fatalf("Usage: inproc_lat <msg-size> <roundtrip-count>")
}

size, err := strconv.Atoi(args[0])
if err != nil {
log.Fatalf("Bad msg-size: %v", err)
}
count, err := strconv.Atoi(args[1])
if err != nil {
log.Fatalf("Bad roundtrip-count: %v", err)
}
go ReqRepLatencyServer("inproc://inproc_lat", size, count)
time.Sleep(10 * time.Millisecond)
ReqRepLatencyClient("inproc://inproc_lat", size, count)
os.Exit(0)
}

func doInprocThr(args []string) {
if len(args) < 2 {
log.Fatalf("Usage: inproc_thr <msg-size> <msg-count>")
Expand All @@ -175,7 +193,7 @@ func main() {

tries := 0
for tries = 0; tries < 2; tries++ {
switch path.Base(args[0]) {
switch args[0] {
case "remote_reqlat":
doRemoteReqRepLatency(args[1:])

Expand Down Expand Up @@ -208,6 +226,9 @@ func main() {
case "inproc_lat":
doInprocLat(args[1:])

case "inproc_reqlat":
doInprocReqRepLatency(args[1:])

default:
args = args[1:]
}
Expand Down
3 changes: 2 additions & 1 deletion protocol/req/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func (s *socket) send() {
c.sendID = 0
c.cond.Broadcast()
}
m := c.reqMsg.Dup()
m := c.reqMsg
m.Clone()
p := s.readyq[0]
s.readyq = s.readyq[1:]

Expand Down

0 comments on commit 2aa83c8

Please sign in to comment.