diff --git a/.gitignore b/.gitignore index 9db5f69..e30ff4e 100755 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ bin/* !bin/*.json .idea/* /protocols/topsmr +.DS_Store diff --git a/bench/benchmark.go b/bench/benchmark.go index 56152ca..ea57c34 100755 --- a/bench/benchmark.go +++ b/bench/benchmark.go @@ -134,6 +134,7 @@ func (b *Benchmark) Run() { } b.startTime = time.Now() + log.Infof("Benchmark Start\n") if b.T > 0 { timer := time.NewTimer(time.Second * time.Duration(b.T)) loop: diff --git a/bin/config.json b/bin/config.json index 35c7263..e233ad9 100755 --- a/bin/config.json +++ b/bin/config.json @@ -1,31 +1,32 @@ { "address": { - "1.1": "tcp://127.0.0.1:1735", - "1.2": "tcp://127.0.0.1:1736", - "1.3": "tcp://127.0.0.1:1737", - "1.4": "tcp://127.0.0.1:1738", - "1.5": "tcp://127.0.0.1:1739" + "1.1": "tcp://18.191.133.55:1735", + "1.2": "tcp://3.15.184.126:1736", + "1.3": "tcp://3.142.184.9:1737", + "1.4": "tcp://3.143.108.225:1738", + "1.5": "tcp://3.17.190.39:1739" + }, + "http_address": { + "1.1": "http://18.191.133.55:8080", + "1.2": "http://3.15.184.126:8081", + "1.3": "http://3.142.184.9:8082", + "1.4": "http://3.143.108.225:8083", + "1.5": "http://3.17.190.39:8084" }, - "ephemeral_leader": true, "policy": "majority", "threshold": 3, "thrifty": false, "chan_buffer_size": 1024, "buffer_size": 1024, "multiversion": false, - "num_relays": 2, - "regions_peer_groups": false, - "fixed_relays": false, - "relay_slack": 0, - "std_pig_timeout": 50, - "use_small_p2b": true, + "use_retro_log": false, "benchmark": { - "T": 10, + "T": 60, "N": 0, - "K": 1, + "K": 1000, "W": 0.5, "Throttle": 0, - "Concurrency": 15, + "Concurrency": 90, "Distribution": "conflict", "LinearizabilityCheck": false, "Conflicts": 0, @@ -42,4 +43,4 @@ "MaxOutstanding": 10, "OpenLoopThrottle": 0 } -} +} \ No newline at end of file diff --git a/bin/pigConfig.json b/bin/pigConfig.json new file mode 100644 index 0000000..593d3e5 --- /dev/null +++ b/bin/pigConfig.json @@ -0,0 +1,45 @@ +{ + "address": { + "1.1": "tcp://3.15.230.27:1735", + "1.2": "tcp://13.58.224.139:1736", + "1.3": "tcp://18.188.74.117:1737", + "1.4": "tcp://3.135.20.76:1738", + "1.5": "tcp://18.222.33.228:1739" + }, + "ephemeral_leader": true, + "policy": "majority", + "threshold": 3, + "thrifty": false, + "chan_buffer_size": 1024, + "buffer_size": 1024, + "multiversion": false, + "num_relays": 1, + "regions_peer_groups": false, + "fixed_relays": false, + "relay_slack": 0, + "std_pig_timeout": 50, + "use_small_p2b": true, + "benchmark": { + "T": 60, + "N": 0, + "K": 1, + "W": 0.5, + "Throttle": 0, + "Concurrency": 10, + "Distribution": "conflict", + "LinearizabilityCheck": false, + "Conflicts": 0, + "Min": 0, + "Mu": 500, + "Sigma": 50, + "Move": false, + "Speed": 10, + "Zipfian_s": 2, + "Zipfian_v": 1, + "Lambda": 0.01, + "Size": 8, + "OpenLoopWorker": false, + "MaxOutstanding": 10, + "OpenLoopThrottle": 0 + } +} \ No newline at end of file diff --git a/log/log.go b/log/log.go index 6c085fd..2303971 100755 --- a/log/log.go +++ b/log/log.go @@ -133,7 +133,7 @@ func Debug(v ...interface{}) { func Debugf(format string, v ...interface{}) { if log.severity == DEBUG { - log.debug.Output(2, fmt.Sprintf(format, v...)) + //log.debug.Output(2, fmt.Sprintf(format, v...)) } } diff --git a/main/client/client.go b/main/client/client.go index c04454a..e9ebb29 100755 --- a/main/client/client.go +++ b/main/client/client.go @@ -5,6 +5,7 @@ import ( "github.com/acharapko/pbench" "github.com/acharapko/pbench/bench" "github.com/acharapko/pbench/idservice" + "runtime/debug" ) var id = flag.String("id", "", "node id this client connects to") @@ -14,6 +15,7 @@ var load = flag.Bool("load", false, "Load K keys into DB") func main() { pbench.Init() + debug.SetGCPercent(-1) preferredId := idservice.ID(0) if *id != "" { preferredId = idservice.NewIDFromString(*id) diff --git a/main/server/server.go b/main/server/server.go index d281b7e..63c3f12 100755 --- a/main/server/server.go +++ b/main/server/server.go @@ -9,10 +9,15 @@ import ( "github.com/acharapko/pbench/protocols/batchedpaxos" "github.com/acharapko/pbench/protocols/epaxos" "github.com/acharapko/pbench/protocols/paxos" + "io/ioutil" + "os" + "runtime/debug" + "sync" + "strconv" + "strings" + "time" "github.com/acharapko/pbench/protocols/pigpaxos" "net/http" - "sync" - l "log" _ "net/http/pprof" ) @@ -47,9 +52,51 @@ func replica(id idservice.ID) { } } +func getCpuSample() (idle uint64, total uint64) { + contents, err := ioutil.ReadFile("/proc/stat") + if err != nil { + log.Errorf("node %v proc stat read %v ", id, err) + return + } + lines := strings.Split(string(contents), "\n") + //cpu user nice system idle io irq softirq + for _, line := range(lines) { + fields := strings.Fields(line) + if fields[0] == "cpu" { + for i := 1; i < len(fields); i++ { + time, err := strconv.ParseUint(fields[i], 10, 64) + if err != nil { + log.Errorf("node %v Atoi error %s ", id, line) + } + total += time + if i == 4 { + idle = time + } + } + return + } + } + return +} + +func cpuUtilization(id idservice.ID) { + idlePrev, totalPrev := getCpuSample() + for{ + time.Sleep(1 * time.Second) + idleCurr, totalCurr := getCpuSample() + idleTime := float64(idleCurr - idlePrev) + totalTime := float64(totalCurr - totalPrev) + cpuUtilization := 100 * (totalTime - idleTime)/totalTime + idlePrev, totalPrev = idleCurr, totalCurr + log.Infof("node %v CPU utilization: %f ", id, cpuUtilization) + } +} + + func main() { pbench.Init() - + log.Infof("Config: %s",os.Args[len(os.Args)-1]) + debug.SetGCPercent(-1) if *simulation { var wg sync.WaitGroup wg.Add(1) @@ -60,6 +107,7 @@ func main() { } wg.Wait() } else { + go cpuUtilization(idservice.NewIDFromString(*id)) replica(idservice.NewIDFromString(*id)) log.Debugf("Server done") }