Skip to content

Commit

Permalink
Add fixes and benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
invpt committed Jul 22, 2023
1 parent 06a01cb commit fdc6439
Show file tree
Hide file tree
Showing 8 changed files with 1,689 additions and 6 deletions.
50 changes: 46 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,41 @@ package main

import (
drpdelta "drp-delta/src"
"encoding/csv"
"fmt"
"math/rand"
"os"
"strconv"
"time"
)

func main() {

file, err := os.Create("manyVars" + time.Now().Format("20060102150405") + ".csv")
if err != nil {
panic(err)
}
defer file.Close()

writer := csv.NewWriter(file)
defer writer.Flush()

numVars := 16
numTxns := 64

writer.Write([]string{"Benchmark parameters: manyVars(numVars=" + strconv.Itoa(numVars) + ", numTxns=" + strconv.Itoa(numTxns) + ")"})
writer.Write([]string{"mode", "numClients", "trial", "duration"})
for mode := lockModeFast; mode == lockModeFast || mode == lockModeSlow; mode++ {
for numClients := 1; numClients <= 2*numVars; numClients++ {
for trial := 0; trial < 128; trial++ {
fmt.Println(mode, numClients, trial)
duration := manyVars(numVars, numTxns, numClients, mode)
writer.Write([]string{strconv.Itoa(int(mode)), strconv.Itoa(numClients), strconv.Itoa(trial), strconv.FormatInt(duration.Microseconds(), 10)})
}
writer.Flush()
}
}

//manyVars(50, 100, 5, lockModeSlow)
//cross(20, 7, 19, 78, lockModeSlow)
//manyDefs(1, 100, 10, lockModeSlow)
Expand Down Expand Up @@ -77,7 +107,7 @@ func main() {
}

// numNodes and numTxns are powers of 2
func manyVars(numVars int, numTxns int, numClients int, mode lockMode) {
func manyVars(numVars int, numTxns int, numClients int, mode lockMode) time.Duration {
o := drpdelta.NewOrchestrator()

vars := make([]drpdelta.ReactiveNode, 0, numVars)
Expand All @@ -101,7 +131,7 @@ func manyVars(numVars int, numTxns int, numClients int, mode lockMode) {

var writeTarget drpdelta.Address
if mode == lockModeFast {
numTargets := rand.Int() % len(vars)
numTargets := 1 + rand.Int()%len(vars)

for target := 0; target < numTargets; target++ {
for {
Expand Down Expand Up @@ -149,6 +179,8 @@ func manyVars(numVars int, numTxns int, numClients int, mode lockMode) {
actions[i], actions[j] = actions[j], actions[i]
})

start := time.Now()

step := len(actions) / numClients
if step == 0 {
step = 1
Expand All @@ -171,10 +203,12 @@ func manyVars(numVars int, numTxns int, numClients int, mode lockMode) {
break
}
}

return time.Since(start)
}

// numNodes and numTxns are powers of 2
func cross(numPylons int, pylonLength int, numTxns int, numClients int, mode lockMode) {
func cross(numPylons int, pylonLength int, numTxns int, numClients int, mode lockMode) time.Duration {
o := drpdelta.NewOrchestrator()

vars := make([]drpdelta.ReactiveNode, 0, numPylons)
Expand Down Expand Up @@ -268,6 +302,8 @@ func cross(numPylons int, pylonLength int, numTxns int, numClients int, mode loc
actions[i], actions[j] = actions[j], actions[i]
})

start := time.Now()

step := len(actions) / numClients
if step == 0 {
step = 1
Expand All @@ -292,10 +328,12 @@ func cross(numPylons int, pylonLength int, numTxns int, numClients int, mode loc
}
}
}

return time.Since(start)
}

// numNodes and numTxns are powers of 2
func manyDefs(numDefs int, numTxns int, numClients int, mode lockMode) {
func manyDefs(numDefs int, numTxns int, numClients int, mode lockMode) time.Duration {
o := drpdelta.NewOrchestrator()

var_ := o.NewVariable(drpdelta.Address("var"), 0)
Expand Down Expand Up @@ -332,6 +370,8 @@ func manyDefs(numDefs int, numTxns int, numClients int, mode lockMode) {
actions[i], actions[j] = actions[j], actions[i]
})

start := time.Now()

step := len(actions) / numClients
if step == 0 {
step = 1
Expand All @@ -356,6 +396,8 @@ func manyDefs(numDefs int, numTxns int, numClients int, mode lockMode) {
}
}
}

return time.Since(start)
}

type lockMode int
Expand Down
Loading

0 comments on commit fdc6439

Please sign in to comment.