Skip to content

Commit bdf3e6b

Browse files
authored
code cleanup (#41)
* code cleanup * address comments
1 parent b2a3ace commit bdf3e6b

File tree

6 files changed

+62
-20
lines changed

6 files changed

+62
-20
lines changed

bankofanthos_prototype/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Eval Driver Prototype on Bank Of Anthos
22
Eval driver runs diff testing for bank of anthos, it takes two versions of Bank Of Anthos and sampled requests as input, display response diff and database diff as output.
33

4+
For the same set of requests, we run 4 different trials:
5+
1. Send all requests to v1 as Control
6+
2. Send all requests to v2 as Experimental_1
7+
3. Send half request to v1, half request to v2 as Experimental_2
8+
4. Send half request to v2, half request to v1 as Experimental_3
9+
10+
While we do diffs at the end, we compare Control and Experimental_*.
11+
412
## Prereq
513
- Install [Service Weaver](https://serviceweaver.dev/docs.html#what-is-service-weaver) locally
614
- Install [Docker](https://www.docker.com/get-started) locally
Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Benchmark For R+/R- Database performance
22
## Prerequsite
33
- Install [Dolt](https://docs.dolthub.com/introduction/installation)
4-
- Install [pg2mysql tool](https://docs.dolthub.com/introduction/installation) to convert postgres database to mysql database
4+
- Install [pg2mysql tool](https://docs.dolthub.com/introduction/installation) to convert postgres database to mysql database for Dolt setup
55
- Install [Postgres](https://www.postgresql.org/download/)
66

77
## Setup
@@ -10,36 +10,52 @@ Run script to create `benchmark` database with two tables users(username, passwo
1010
./init.sh $row_num$
1111
```
1212

13-
## Cloning
13+
You can create multiple databases with different name by using ths script.
14+
15+
## Instruction
16+
```code
17+
go run . --dbUrlLists dbUrl1 --dbUrlLists dbUrl2 --dbUrlLIsts dbUrl3 ...
18+
```
19+
Pass multiple database urls to the command for benchmark.
20+
21+
All the stats will be dumped into a json file. Run the plot.py file to plot the benchmark stats.
22+
23+
```code
24+
python plot.py
25+
```
26+
27+
## Benchmarks
28+
We benchmark clone one entire database, read/write performance and diffing two tables.
29+
### Cloning
1430
Create a table with size X
15-
### Baseline 1: Postgres
31+
#### Baseline 1: Postgres
1632
Dump the whole database and then restore the database
17-
### Baseline 2: Dolt
33+
#### Baseline 2: Dolt
1834
Create a new branch for the database
19-
### R+/R-
35+
#### R+/R-
2036
Create a new branch for the database
2137

22-
## Read/Write Performance
38+
### Read/Write Performance
2339
Write Y row into Table X With and Without Primary Key\
2440
Read queries:
2541
- SELECT * FROM TABLE WHERE username = 'aaaa';
2642
- SELECT * FROM TABLE WHERE LENGTH(password) = 8 AND username LIKE 'a%';
2743
- SELECT COUNT(*) FROM TABLE;
2844
- SELECT * FROM TABLE
29-
### Baseline 1: Postgres
45+
#### Baseline 1: Postgres
3046
Execute Read/Write oprations on table
31-
### Baseline 2: Dolt
47+
#### Baseline 2: Dolt
3248
Execute Read/Write oprations on new branch
33-
### R+/R-
49+
#### R+/R-
3450
Execute Read/Write oprations on new branch
3551

36-
## Diffing
52+
### Diffing
3753
Diff table size X with Y modified rows
38-
### Baseline 1: Postgres
54+
#### Baseline 1: Postgres
3955
Compare two table with `SELECT * FROM TABLE A EXCEPT ALL SELECT * FROM TABLE B;` and `SELECT * FROM TABLE B EXCEPT ALL SELECT * FROM TABLE A;`
4056

41-
### Baseline 2: Dolt
57+
#### Baseline 2: Dolt
4258
Diff two branches
4359

44-
### R+/R-
60+
#### R+/R-
4561
Diff two branches

bankofanthos_prototype/eval_driver/benchmark/main.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"flag"
6+
"fmt"
67
"log"
78
"os"
89
"path/filepath"
@@ -11,9 +12,26 @@ import (
1112

1213
const dumpDir = "dump"
1314

15+
type arrayFlags []string
16+
17+
func (i *arrayFlags) String() string {
18+
return strings.Join(*i, ", ")
19+
}
20+
21+
func (i *arrayFlags) Set(value string) error {
22+
if i == nil {
23+
return fmt.Errorf("array flag is null")
24+
}
25+
*i = append(*i, value)
26+
return nil
27+
}
28+
1429
func main() {
1530
var debug bool
31+
var dbs arrayFlags
32+
1633
flag.BoolVar(&debug, "debug", false, "Debug / analyze R+/R- implementation")
34+
flag.Var(&dbs, "dbUrlLists", "Database url lists for benchmark to run")
1735
flag.Parse()
1836

1937
if _, err := os.Stat(dumpDir); os.IsNotExist(err) {
@@ -22,8 +40,6 @@ func main() {
2240
}
2341
}
2442

25-
dbs := []string{"postgresql://postgres:postgres@localhost:5433/benchmark_1mb", "postgresql://postgres:postgres@localhost:5433/benchmark_20mb", "postgresql://postgres:postgres@localhost:5433/benchmark_100mb"}
26-
2743
metricsStats := map[string]map[string]*metrics{} // {Database: {table:metrics, table_with_primary_key:metrics}}
2844

2945
for _, dbUrl := range dbs {

bankofanthos_prototype/eval_driver/benchmark/plot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import matplotlib.pyplot as plt
44
import numpy as np
55

6-
7-
database = ['benchmark_1mb','benchmark_20mb','benchmark_100mb']
6+
database = []
87
types = ['RPlusRMinus','Postgres', 'Dolt']
98
colors = ['blue', 'green', 'red']
109
table = 'users'
@@ -137,6 +136,9 @@ def plot(x_values, y_values, yerr_values, colors,line_names,title_name):
137136

138137
def main():
139138
data = readFromFile("dump/metrics.json")
139+
global database
140+
database = data.keys()
141+
140142
plotStats(data)
141143

142144
if __name__ == "__main__":

bankofanthos_prototype/eval_driver/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func runTrail(ctx context.Context, trail *utility.Trail, branchers map[string]*d
3636
var prodServices []*utility.ProdService
3737
if trail.IsControl() {
3838
prodServices = []*utility.ProdService{v1ProdService}
39-
} else if trail.IsConaryOnly() {
39+
} else if trail.IsCanaryOnly() {
4040
prodServices = []*utility.ProdService{v2ProdService}
4141
} else {
4242
prodServices = []*utility.ProdService{v1ProdService, v2ProdService}
@@ -90,7 +90,7 @@ func main() {
9090
var deleteBranches, inlineDiff, respDiff bool
9191
flag.StringVar(&configFile, "configFile", "config.toml", "Config file for eval")
9292
flag.BoolVar(&deleteBranches, "deleteBranches", true, "Delete branches at the end of eval run, only set false for investigation purpose")
93-
flag.BoolVar(&inlineDiff, "inlineDiff", false, "Whether to use inline diff or not")
93+
flag.BoolVar(&inlineDiff, "inlineDiff", false, "Whether to use inline diff or side by side diff")
9494
flag.BoolVar(&respDiff, "respDiff", true, "Whether to show response diff or not")
9595
flag.Parse()
9696

bankofanthos_prototype/eval_driver/utility/trail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ func (t *Trail) IsControl() bool {
6767
return t.Name == "Control"
6868
}
6969

70-
func (t *Trail) IsConaryOnly() bool {
70+
func (t *Trail) IsCanaryOnly() bool {
7171
return t.Name == "E_C"
7272
}

0 commit comments

Comments
 (0)