mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
add MultiDBSetBits benchmark
This commit is contained in:
parent
62a571e442
commit
85b4e83c2d
3 changed files with 82 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
10
cmd/pilosactl/multidbspawn.json
Normal file
10
cmd/pilosactl/multidbspawn.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"PilosaHosts": ["localhost:19327","localhost:19328","localhost:19329"],
|
||||
"Agents": { "Type": "local" },
|
||||
"Benchmarks": [
|
||||
{
|
||||
"Num": 4,
|
||||
"Args": ["MultiDBSetBits", "-Iterations", "100000"]
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue