From 85b4e83c2dc95b6595dfa06b0ccd6ea211b7d0ef Mon Sep 17 00:00:00 2001 From: jaffee Date: Tue, 15 Nov 2016 13:01:31 -0600 Subject: [PATCH] add MultiDBSetBits benchmark --- bench/bench.go | 66 +++++++++++++++++++++++++++++++++ cmd/pilosactl/main.go | 10 +++-- cmd/pilosactl/multidbspawn.json | 10 +++++ 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 cmd/pilosactl/multidbspawn.json diff --git a/bench/bench.go b/bench/bench.go index b51840603..0b44dea20 100644 --- a/bench/bench.go +++ b/bench/bench.go @@ -116,6 +116,70 @@ func (b *DiagonalSetBits) Run(agentNum int) map[string]interface{} { return results } +// MultiDBSetBits sets bits with increasing profile id and bitmap id. +type MultiDBSetBits struct { + cli *pilosa.Client + BaseBitmapID int + BaseProfileID int + Iterations int +} + +func (b *MultiDBSetBits) Usage() string { + return ` +MultiDBSetBits sets bits with increasing profile id and bitmap id using a different DB for each agent. + +Usage: MultiDBSetBits [arguments] + +The following arguments are available: + + -BaseBitmapID int + bits being set will all be greater than BaseBitmapID + + -BaseProfileID int + profile id num to start from + + -Iterations int + number of bits to set + +`[1:] +} + +func (b *MultiDBSetBits) ConsumeFlags(args []string) ([]string, error) { + fs := flag.NewFlagSet("MultiDBSetBits", flag.ContinueOnError) + fs.SetOutput(ioutil.Discard) + fs.IntVar(&b.BaseBitmapID, "BaseBitmapID", 0, "") + fs.IntVar(&b.BaseProfileID, "BaseProfileID", 0, "") + fs.IntVar(&b.Iterations, "Iterations", 100, "") + + if err := fs.Parse(args); err != nil { + return nil, err + } + return fs.Args(), nil +} + +// Init connects to pilosa and sets the client on b. +func (b *MultiDBSetBits) Init(hosts []string) (err error) { + b.cli, err = pilosa.NewClient(hosts[0]) + if err != nil { + return err + } + return nil +} + +// Run runs the MultiDBSetBits benchmark +func (b *MultiDBSetBits) Run(agentNum int) map[string]interface{} { + results := make(map[string]interface{}) + if b.cli == nil { + results["error"] = fmt.Errorf("No client set for MultiDBSetBits agent: %v", agentNum) + return results + } + for n := 0; n < b.Iterations; n++ { + query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+n, b.BaseProfileID+n) + b.cli.ExecuteQuery("multidb"+strconv.Itoa(agentNum), query, true) + } + return results +} + // RandomSetBits sets bits randomly and deterministically based on a seed. type RandomSetBits struct { cli *pilosa.Client @@ -297,6 +361,7 @@ func (sb *serialBenchmark) Init(hosts []string) error { func (sb *serialBenchmark) Run(agentNum int) map[string]interface{} { results := make(map[string]interface{}, len(sb.benchmarkers)) runtimes := make(map[string]time.Duration) + total_start := time.Now() for i, b := range sb.benchmarkers { start := time.Now() ret := b.Run(agentNum) @@ -304,6 +369,7 @@ func (sb *serialBenchmark) Run(agentNum int) map[string]interface{} { results[strconv.Itoa(i)] = ret runtimes[strconv.Itoa(i)] = end.Sub(start) } + runtimes["total"] = time.Now().Sub(total_start) results["runtimes"] = runtimes return results } diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index 492ec3bfd..4d4c6f813 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -1319,6 +1319,8 @@ func (cmd *BagentCommand) ParseFlags(args []string) error { bm = &bench.DiagonalSetBits{} case "RandomSetBits": bm = &bench.RandomSetBits{} + case "MultiDBSetBits": + bm = &bench.MultiDBSetBits{} default: return fmt.Errorf("Unknown benchmark cmd: %v", remArgs[0]) } @@ -1357,6 +1359,8 @@ The following arguments are available: subcommands: DiagonalSetBits RandomSetBits + MultiDBSetBits + `) } @@ -1368,7 +1372,7 @@ func (cmd *BagentCommand) Run() error { if err != nil { return fmt.Errorf("in cmd.Run initialization: %v", err) } - fmt.Fprintf(cmd.Stderr, "cmd: %v\n", *cmd) + res := sbm.Run(cmd.AgentNum) fmt.Fprintln(cmd.Stdout, res) return nil @@ -1421,7 +1425,6 @@ func (cmd *BspawnCommand) ParseFlags(args []string) error { if err != nil { return err } - fmt.Fprintf(cmd.Stderr, "%v", cmd) // handle pilosa creation // handle agent creation @@ -1444,7 +1447,6 @@ pilosactl spawn configfile func (cmd *BspawnCommand) Run() error { switch cmd.Agents.Type { case "local": - fmt.Fprintf(cmd.Stderr, "running! local\n") return cmd.spawnLocal() case "remote": return fmt.Errorf("remote type spawning is unimplemented") @@ -1466,7 +1468,7 @@ func (cmd *BspawnCommand) spawnLocal() error { } } errors := make([]error, len(agents)) - fmt.Fprintf(cmd.Stderr, "agents: %v\n", agents) + wg := sync.WaitGroup{} for i, agent := range agents { wg.Add(1) diff --git a/cmd/pilosactl/multidbspawn.json b/cmd/pilosactl/multidbspawn.json new file mode 100644 index 000000000..338e35d4c --- /dev/null +++ b/cmd/pilosactl/multidbspawn.json @@ -0,0 +1,10 @@ +{ + "PilosaHosts": ["localhost:19327","localhost:19328","localhost:19329"], + "Agents": { "Type": "local" }, + "Benchmarks": [ + { + "Num": 4, + "Args": ["MultiDBSetBits", "-Iterations", "100000"] + } + ] +}