Skip to content

Commit

Permalink
Merge pull request #1239 from ondrej-fabry/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ondrej-fabry committed Mar 18, 2019
2 parents 3b7d568 + 9a15775 commit ff294f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
6 changes: 5 additions & 1 deletion plugins/orchestrator/dispatcher.go
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"runtime/trace"
"sync"
"time"

"github.com/ligato/cn-infra/logging"
"golang.org/x/net/context"
Expand Down Expand Up @@ -105,6 +106,8 @@ func (p *dispatcher) PushData(ctx context.Context, kvPairs []KeyVal) (kvErrs []k

pr.End()

t := time.Now()

seqID, err := txn.Commit(ctx)
if err != nil {
if txErr, ok := err.(*kvs.TransactionError); ok && len(txErr.GetKVErrors()) > 0 {
Expand All @@ -121,7 +124,8 @@ func (p *dispatcher) PushData(ctx context.Context, kvPairs []KeyVal) (kvErrs []k
return kvErrs, err
}

p.log.Infof("Transaction #%d successful!", seqID)
took := time.Since(t).Round(time.Microsecond * 100)
p.log.Infof("Transaction #%d successful! (took %v)", seqID, took)

return nil, nil
}
Expand Down
14 changes: 7 additions & 7 deletions tests/perf/grpc-perf/main.go
Expand Up @@ -41,10 +41,10 @@ import (
var (
address = flag.String("address", "127.0.0.1:9111", "address of GRPC server")
socketType = flag.String("socket-type", "tcp", "socket type [tcp, tcp4, tcp6, unix, unixpacket]")
numTunnels = flag.Int("tunnels", 1, "number of tunnels to stress per client")
numClients = flag.Int("clients", 1, "number of concurrent grpc clients")
numTunnels = flag.Int("tunnels", 100, "number of tunnels to stress per client")
numPerRequest = flag.Int("numperreq", 1, "number of tunnels/routes per grpc request")
debug = flag.Bool("debug", false, "turn on debug dump")
numClients = flag.Int("clients", 1, "number of concurrent grpc clients")

dialTimeout = time.Second * 2
reqTimeout = time.Second * 10
Expand Down Expand Up @@ -108,9 +108,6 @@ func dialer(socket, address string, timeoutVal time.Duration) func(string, time.
}

func (p *GRPCStressPlugin) setupInitial() {
// create a conn/client to create the red/black interfaces
// that each tunnel will reference

conn, err := grpc.Dial("unix",
grpc.WithInsecure(),
grpc.WithDialer(dialer(*socketType, *address, dialTimeout)),
Expand All @@ -120,6 +117,9 @@ func (p *GRPCStressPlugin) setupInitial() {
}

client := configurator.NewConfiguratorClient(conn)

// create a conn/client to create the red/black interfaces
// that each tunnel will reference
p.runGRPCCreateRedBlackMemifs(client)
}

Expand Down Expand Up @@ -192,11 +192,11 @@ func (p *GRPCStressPlugin) runAllClients() {
p.Log.Debugf("numTunnels: %d, numPerRequest: %d, numClients=%d",
*numTunnels, *numPerRequest, *numClients)

p.wg.Add(*numClients)
p.Log.Infof("Running for %d clients", *numClients)

t := time.Now()

p.wg.Add(*numClients)
for i := 0; i < *numClients; i++ {
// Set up connection to the server.
conn, err := grpc.Dial("unix",
Expand All @@ -212,7 +212,7 @@ func (p *GRPCStressPlugin) runAllClients() {
go p.runGRPCStressCreate(i, client, *numTunnels)
}

p.Log.Debugf("Waiting..")
p.Log.Debugf("Waiting for clients..")
p.wg.Wait()

took := time.Since(t).Round(time.Microsecond * 100)
Expand Down
16 changes: 8 additions & 8 deletions tests/perf/grpc-perf/test.sh
Expand Up @@ -24,6 +24,8 @@ agent_info="${REPORT_DIR}/agent-info.txt"
# -------

function run_test() {
# create report directory
mkdir -p ${REPORT_DIR}
perftest "$1" 2>&1 | tee $log_report
}

Expand Down Expand Up @@ -93,8 +95,6 @@ function prepare_test() {
echo "-> compiling grpc-perf.."
go build -v
}
# create report directory
mkdir -p ${REPORT_DIR}
}

function fail() {
Expand Down Expand Up @@ -134,8 +134,8 @@ function start_vpp() {
rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api
vpp -c /etc/vpp/vpp.conf > "$log_vpp" 2>&1 &
pid_vpp="$!"
timeout "${wait_vpp_boot}" grep -q "vlib_plugin_early_init" <(tail -qF $log_vpp)
echo "ok! (PID:${pid_vpp})"
sleep $wait_vpp_boot
}

function stop_vpp() {
Expand Down Expand Up @@ -177,16 +177,16 @@ function vppcli() {
# agent
# -------

wait_agent_boot=3
wait_agent_boot=5

function start_agent() {
echo -n "-> starting agent.. "
# DEBUG_MEMPROFILE=/tmp/perf_mem.prof
DEBUG_ENABLED=true DEBUG_CPUPROFILE=/tmp/perf_cpu.prof DEBUG_TRACEPROFILE=/tmp/perf_trace.out \
vpp-agent -grpc-config=grpc.conf > "$log_agent" 2>&1 &
vpp-agent -etcd-config=etcd.conf -grpc-config=grpc.conf > "$log_agent" 2>&1 &
pid_agent="$!"
timeout "${wait_agent_boot}" grep -q "Agent started" <(tail -qF $log_agent) || {
fail "timeout!"
}
echo "ok! (PID:${pid_agent})"
sleep $wait_agent_boot
}

function stop_agent() {
Expand Down

0 comments on commit ff294f1

Please sign in to comment.