From 352572f80e4257279148c324d012aa66442f406f Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Tue, 2 Apr 2019 11:10:30 +0100 Subject: [PATCH 1/5] add support for two classes of clients experiment --- bin/run.sh | 8 +++----- src/client/client.go | 24 +++++++++++------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/bin/run.sh b/bin/run.sh index 6cec2b3ba..36fd75faa 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -59,11 +59,9 @@ fi # Usage of ./bin/client: # -c int -# Percentage of conflicts. Defaults to 0% +# Percentage of conflicts. Defaults to 0. If the conflict rate is 142, two classes of clients (conflict and non-conflicting) are created. # -e Egalitarian (no leader). # -f Fast Paxos: send message directly to all replicas. -# -id string -# the id of the client. Default is RFC 4122 nodeID. # -maddr string # Master address. Defaults to localhost # -mport int @@ -80,7 +78,7 @@ fi # -s replace read with short scan (100 elements) # -l local read if [ "${TYPE}" == "client" ]; then - args="-maddr ${MADDR} -mport ${MPORT} ${CLIENT_EXTRA_ARGS}" + args="-clients ${CLIENTS} -maddr ${MADDR} -mport ${MPORT} ${CLIENT_EXTRA_ARGS}" # aggregate all logs in a single file ALL=all_logs @@ -89,7 +87,7 @@ if [ "${TYPE}" == "client" ]; then mkdir -p logs/ for i in $(seq 1 ${NCLIENTS}); do - ${DIR}/client ${args} 2>&1 | tee -a logs/c_${i}.txt ${ALL} >/dev/null & + ${DIR}/client -id ${i} ${args} 2>&1 | tee -a logs/c_${i}.txt ${ALL} >/dev/null & echo "> Client $i of ${NCLIENTS} started!" done diff --git a/src/client/client.go b/src/client/client.go index 2a21ab192..46c2f5302 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -12,7 +12,8 @@ import ( "time" ) -var clientId string = *flag.String("id", "", "the id of the client. Default is RFC 4122 nodeID.") +var id *int = flag.Int("id", 0, "The id of the client.") +var clients *int = flag.Int("clients", 0, "Total number of clients.") var masterAddr *string = flag.String("maddr", "", "Master address. Defaults to localhost") var masterPort *int = flag.Int("mport", 7087, "Master port. ") var reqsNb *int = flag.Int("q", 1000, "Total number of requests. ") @@ -22,7 +23,7 @@ var noLeader *bool = flag.Bool("e", false, "Egalitarian (no leader). ") var fast *bool = flag.Bool("f", false, "Fast Paxos: send message directly to all replicas. ") var localReads *bool = flag.Bool("l", false, "Execute reads at the closest (local) replica. ") var procs *int = flag.Int("p", 2, "GOMAXPROCS. ") -var conflicts *int = flag.Int("c", 0, "Percentage of conflicts. Defaults to 0%") +var conflicts *int = flag.Int("c", 0, "Percentage of conflicts. Defaults to 0. If the conflict rate is 142, two classes of clients are created: one that issues conflicting commands, another that doesn't") var verbose *bool = flag.Bool("v", false, "verbose mode. ") var scan *bool = flag.Bool("s", false, "replace read with short scan (100 elements)") @@ -48,16 +49,14 @@ func main() { proxy.Disconnect() } - if clientId == "" { - clientId = uuid.New().String() - } - - log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v)", clientId, *verbose, *psize, *conflicts) + log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v)", *id, *verbose, *psize, *conflicts) karray := make([]state.Key, *reqsNb) put := make([]bool, *reqsNb) clientKey := state.Key(uint64(uuid.New().Time())) // a command id unique to this client. + blackColor := *conflicts == 142 && *id <= *clients/2 + for i := 0; i < *reqsNb; i++ { put[i] = false if *writes > 0 { @@ -66,12 +65,11 @@ func main() { put[i] = true } } - karray[i] = clientKey - if *conflicts > 0 { - r := rand.Intn(100) - if r <= *conflicts { - karray[i] = 42 - } + + if blackColor || rand.Intn(100) < *conflicts { + karray[i] = 42 + } else { + karray[i] = clientKey } } From 3f84b8a50ccc78f45d4dbabf4ede4fe6a7b600c9 Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Tue, 2 Apr 2019 11:13:24 +0100 Subject: [PATCH 2/5] log black color value --- src/client/client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/client.go b/src/client/client.go index 46c2f5302..8bcf2b415 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -49,13 +49,14 @@ func main() { proxy.Disconnect() } - log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v)", *id, *verbose, *psize, *conflicts) + blackColor := *conflicts == 142 && *id <= *clients/2 + + log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v, black color=%v)", *id, *verbose, *psize, *conflicts, blackColor) karray := make([]state.Key, *reqsNb) put := make([]bool, *reqsNb) clientKey := state.Key(uint64(uuid.New().Time())) // a command id unique to this client. - blackColor := *conflicts == 142 && *id <= *clients/2 for i := 0; i < *reqsNb; i++ { put[i] = false From 3d3218a020217c46c2c717a1642a72248ae0629a Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Thu, 18 Apr 2019 11:18:08 +0100 Subject: [PATCH 3/5] Fix two-class command generation --- src/client/client.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/client/client.go b/src/client/client.go index 8bcf2b415..e65feffb2 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -12,7 +12,7 @@ import ( "time" ) -var id *int = flag.Int("id", 0, "The id of the client.") +var id *int = flag.Int("id", 1, "The id of the client.") var clients *int = flag.Int("clients", 0, "Total number of clients.") var masterAddr *string = flag.String("maddr", "", "Master address. Defaults to localhost") var masterPort *int = flag.Int("mport", 7087, "Master port. ") @@ -49,9 +49,7 @@ func main() { proxy.Disconnect() } - blackColor := *conflicts == 142 && *id <= *clients/2 - - log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v, black color=%v)", *id, *verbose, *psize, *conflicts, blackColor) + log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v)", *id, *verbose, *psize, *conflicts) karray := make([]state.Key, *reqsNb) put := make([]bool, *reqsNb) @@ -67,10 +65,22 @@ func main() { } } - if blackColor || rand.Intn(100) < *conflicts { - karray[i] = 42 + // maybe issue unique key per client + // issue 42 if: + // - two-class experiment and we have an even id + // - normal experiment and the random says so + karray[i] = clientKey + + if *conflicts == 142 { + // two-class experiment + if client % 2 == 0 { + karray[i] = 42 + } } else { - karray[i] = clientKey + // normal experiment + if rand.Intn(100) < *conflicts { + karray[i] = 42 + } } } From 23fdd162396fb45ee7854a1953c36e5389d8859b Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Thu, 18 Apr 2019 11:25:42 +0100 Subject: [PATCH 4/5] Remove unnecessary client argument --- bin/run.sh | 2 +- src/client/client.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/run.sh b/bin/run.sh index 36fd75faa..20add1e53 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -78,7 +78,7 @@ fi # -s replace read with short scan (100 elements) # -l local read if [ "${TYPE}" == "client" ]; then - args="-clients ${CLIENTS} -maddr ${MADDR} -mport ${MPORT} ${CLIENT_EXTRA_ARGS}" + args="-maddr ${MADDR} -mport ${MPORT} ${CLIENT_EXTRA_ARGS}" # aggregate all logs in a single file ALL=all_logs diff --git a/src/client/client.go b/src/client/client.go index e65feffb2..9569fb806 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -13,7 +13,6 @@ import ( ) var id *int = flag.Int("id", 1, "The id of the client.") -var clients *int = flag.Int("clients", 0, "Total number of clients.") var masterAddr *string = flag.String("maddr", "", "Master address. Defaults to localhost") var masterPort *int = flag.Int("mport", 7087, "Master port. ") var reqsNb *int = flag.Int("q", 1000, "Total number of requests. ") @@ -73,7 +72,7 @@ func main() { if *conflicts == 142 { // two-class experiment - if client % 2 == 0 { + if *id % 2 == 0 { karray[i] = 42 } } else { From ae9a140175c2bc48193fa38a7ceba871ddef2bcf Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Thu, 18 Apr 2019 13:04:34 +0100 Subject: [PATCH 5/5] Remove conflict bounds check --- src/client/client.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/client/client.go b/src/client/client.go index 9569fb806..d7b28156b 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -34,10 +34,6 @@ func main() { rand.Seed(time.Now().UnixNano()) - if *conflicts > 100 { - log.Fatalf("Conflicts percentage must be between 0 and 100.\n") - } - var proxy *bindings.Parameters for { proxy = bindings.NewParameters(*masterAddr, *masterPort, *verbose, *noLeader, *fast, *localReads)