From e7a605e4fe92e6b4ce88f6708f3ff9076c2ddf9d Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 19 Dec 2016 15:27:15 -0600 Subject: [PATCH 1/8] Update Bagent json tags --- cmd/pilosactl/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index 5ea23aab6..a48dd2f86 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -1158,7 +1158,7 @@ type BagentCommand struct { AgentNum int `json:"agent-num"` // Enable pretty printing of results, for human consumption. - HumanReadable bool + HumanReadable bool `json:"human-readable"` // Slice of pilosa hosts to run the Benchmarks against. Hosts []string `json:"hosts"` From b1795eb04e77082a6a7cc2e7a927043f74cfe003 Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 19 Dec 2016 15:27:50 -0600 Subject: [PATCH 2/8] Remove extraneous whitespace in JSON output --- cmd/pilosactl/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index a48dd2f86..741f48b9b 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -1284,8 +1284,8 @@ func (cmd *BagentCommand) Run(ctx context.Context) error { res := sbm.Run(ctx, cmd.AgentNum) res["metadata"] = cmd enc := json.NewEncoder(cmd.Stdout) - enc.SetIndent("", " ") if cmd.HumanReadable { + enc.SetIndent("", " ") res = bench.Prettify(res) } err = enc.Encode(res) From 7898f671646a3f31dbb8095bda827354006841ca Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 19 Dec 2016 17:59:49 -0600 Subject: [PATCH 3/8] Add Name field to benchmarks --- bench/diagonal.go | 6 ++++++ bench/import.go | 2 ++ bench/multidb.go | 12 +++++++++--- bench/random.go | 6 ++++++ bench/randquery.go | 6 ++++++ bench/sliceheight.go | 2 ++ bench/zipf.go | 2 ++ 7 files changed, 33 insertions(+), 3 deletions(-) diff --git a/bench/diagonal.go b/bench/diagonal.go index 10ed20368..fb782e97c 100644 --- a/bench/diagonal.go +++ b/bench/diagonal.go @@ -13,12 +13,18 @@ import ( // DiagonalSetBits sets bits with increasing profile id and bitmap id. type DiagonalSetBits struct { HasClient + Name string `json:"name"` BaseBitmapID int `json:"base-bitmap-id"` BaseProfileID int `json:"base-profile-id"` Iterations int `json:"iterations"` DB string `json:"db"` } +func (b *DiagonalSetBits) Init(hosts []string, agentNum int) error { + b.Name = "DiagonalSetBits" + return b.HasClient.Init(hosts, agentNum) +} + func (b *DiagonalSetBits) Usage() string { return ` diagonal-set-bits sets bits with increasing profile id and bitmap id. diff --git a/bench/import.go b/bench/import.go index 8a249abbb..b3708d1a4 100644 --- a/bench/import.go +++ b/bench/import.go @@ -22,6 +22,7 @@ func NewImport(stdin io.Reader, stdout, stderr io.Writer) *Import { // Import sets bits with increasing profile id and bitmap id. type Import struct { + Name string `json:"name"` BaseBitmapID int64 `json:"base-bitmap-id"` MaxBitmapID int64 `json:"max-bitmap-id"` BaseProfileID int64 `json:"base-profile-id"` @@ -107,6 +108,7 @@ func (b *Import) Init(hosts []string, agentNum int) error { if len(hosts) == 0 { return fmt.Errorf("Need at least one host") } + b.Name = "Import" b.Host = hosts[0] // generate csv data baseBitmapID, maxBitmapID, baseProfileID, maxProfileID := b.BaseBitmapID, b.MaxBitmapID, b.BaseProfileID, b.MaxProfileID diff --git a/bench/multidb.go b/bench/multidb.go index b8e4528cd..36e672219 100644 --- a/bench/multidb.go +++ b/bench/multidb.go @@ -12,9 +12,15 @@ import ( // MultiDBSetBits sets bits with increasing profile id and bitmap id. type MultiDBSetBits struct { HasClient - BaseBitmapID int `json:"base-bitmap-id"` - BaseProfileID int `json:"base-profile-id"` - Iterations int `json:"iterations"` + Name string `json:"name"` + BaseBitmapID int `json:"base-bitmap-id"` + BaseProfileID int `json:"base-profile-id"` + Iterations int `json:"iterations"` +} + +func (b *MultiDBSetBits) Init(hosts []string, agentNum int) error { + b.Name = "MultiDBSetBits" + return b.HasClient.Init(hosts, agentNum) } func (b *MultiDBSetBits) Usage() string { diff --git a/bench/random.go b/bench/random.go index a39d40106..cf0b55832 100644 --- a/bench/random.go +++ b/bench/random.go @@ -14,6 +14,7 @@ import ( // RandomSetBits sets bits randomly and deterministically based on a seed. type RandomSetBits struct { HasClient + Name string `json:"name"` BaseBitmapID int64 `json:"base-bitmap-id"` BaseProfileID int64 `json:"base-profile-id"` BitmapIDRange int64 `json:"bitmap-id-range"` @@ -23,6 +24,11 @@ type RandomSetBits struct { DB string `json:"db"` } +func (b *RandomSetBits) Init(hosts []string, agentNum int) error { + b.Name = "RandomSetBits" + return b.HasClient.Init(hosts, agentNum) +} + func (b *RandomSetBits) Usage() string { return ` random-set-bits sets random bits diff --git a/bench/randquery.go b/bench/randquery.go index 3d6228f74..5f54e1a1e 100644 --- a/bench/randquery.go +++ b/bench/randquery.go @@ -12,6 +12,7 @@ import ( // RandomQuery queries randomly and deterministically based on a seed. type RandomQuery struct { HasClient + Name string `json:"name"` MaxDepth int `json:"max-depth"` MaxArgs int `json:"max-args"` MaxN int `json:"max-n"` @@ -22,6 +23,11 @@ type RandomQuery struct { DBs []string `json:"dbs"` } +func (b *RandomQuery) Init(hosts []string, agentNum int) error { + b.Name = "RandomQuery" + return b.HasClient.Init(hosts, agentNum) +} + func (b *RandomQuery) Usage() string { return ` random-query constructs random queries diff --git a/bench/sliceheight.go b/bench/sliceheight.go index 31aad4531..94d97c419 100644 --- a/bench/sliceheight.go +++ b/bench/sliceheight.go @@ -26,6 +26,7 @@ type SliceHeight struct { MaxTime time.Duration `json:"max-time"` hosts []string + Name string `json:"name"` MinBitsPerMap int64 `json:"min-bits-per-map"` MaxBitsPerMap int64 `json:"max-bits-per-map"` Seed int64 `json:"seed"` @@ -84,6 +85,7 @@ func (b *SliceHeight) ConsumeFlags(args []string) ([]string, error) { } func (b *SliceHeight) Init(hosts []string, agentNum int) error { + b.Name = "SliceHeight" b.hosts = hosts return nil } diff --git a/bench/zipf.go b/bench/zipf.go index b3f443706..c487ee667 100644 --- a/bench/zipf.go +++ b/bench/zipf.go @@ -17,6 +17,7 @@ import ( // It also uses PermutationGenerator to permute IDs randomly. type ZipfSetBits struct { HasClient + Name string BaseBitmapID int64 BaseProfileID int64 BitmapIDRange int64 @@ -122,6 +123,7 @@ func getZipfOffset(N int64, exp, ratio float64) float64 { } func (b *ZipfSetBits) Init(hosts []string, agentNum int) error { + b.Name = "ZipfSetBits" rnd := rand.New(rand.NewSource(b.Seed + int64(agentNum))) bitmapOffset := getZipfOffset(b.BitmapIDRange, b.BitmapExponent, b.BitmapRatio) b.BitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1)) From eb7dfb1b99ce89c439ab6c2cf6be7309f10bf73e Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 19 Dec 2016 18:06:05 -0600 Subject: [PATCH 4/8] Add JSON tags to zipf benchmark --- bench/zipf.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/bench/zipf.go b/bench/zipf.go index c487ee667..c382d0aab 100644 --- a/bench/zipf.go +++ b/bench/zipf.go @@ -17,24 +17,23 @@ import ( // It also uses PermutationGenerator to permute IDs randomly. type ZipfSetBits struct { HasClient - Name string - BaseBitmapID int64 - BaseProfileID int64 - BitmapIDRange int64 - ProfileIDRange int64 - Iterations int // number of bits that will be set - Seed int64 - BitmapRng *rand.Zipf - ProfileRng *rand.Zipf - BitmapPerm *PermutationGenerator - ProfilePerm *PermutationGenerator - DB string // DB to use in pilosa. + Name string `json:"name"` + BaseBitmapID int64 `json:"base-bitmap-id"` + BaseProfileID int64 `json:"base-profile-id"` + BitmapIDRange int64 `json:"bitmap-id-range"` + ProfileIDRange int64 `json:"profile-id-range"` + Iterations int `json:"iterations"` + Seed int64 `json:"seed"` + BitmapRng *rand.Zipf `json:"-"` + ProfileRng *rand.Zipf `json:"-"` + BitmapPerm *PermutationGenerator `json:"-"` + ProfilePerm *PermutationGenerator `json:"-"` + DB string `json:"db"` - // TODO remove these - but theyre needed in ConsumeFlags - BitmapExponent float64 - BitmapRatio float64 - ProfileExponent float64 - ProfileRatio float64 + BitmapExponent float64 `json:"bitmap-exponent"` + BitmapRatio float64 `json:"bitmap-ratio"` + ProfileExponent float64 `json:"profile-exponent"` + ProfileRatio float64 `json:"profile-ratio"` } func (b *ZipfSetBits) Usage() string { From 0443fa9529c197c74dc25f16fe47bae4d9b737cc Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 19 Dec 2016 18:10:08 -0600 Subject: [PATCH 5/8] Unexport zipf implementation details --- bench/zipf.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bench/zipf.go b/bench/zipf.go index c382d0aab..1c27d6184 100644 --- a/bench/zipf.go +++ b/bench/zipf.go @@ -24,11 +24,11 @@ type ZipfSetBits struct { ProfileIDRange int64 `json:"profile-id-range"` Iterations int `json:"iterations"` Seed int64 `json:"seed"` - BitmapRng *rand.Zipf `json:"-"` + DB string `json:"db"` + bitmapRng *rand.Zipf `json:"-"` ProfileRng *rand.Zipf `json:"-"` BitmapPerm *PermutationGenerator `json:"-"` ProfilePerm *PermutationGenerator `json:"-"` - DB string `json:"db"` BitmapExponent float64 `json:"bitmap-exponent"` BitmapRatio float64 `json:"bitmap-ratio"` @@ -125,12 +125,12 @@ func (b *ZipfSetBits) Init(hosts []string, agentNum int) error { b.Name = "ZipfSetBits" rnd := rand.New(rand.NewSource(b.Seed + int64(agentNum))) bitmapOffset := getZipfOffset(b.BitmapIDRange, b.BitmapExponent, b.BitmapRatio) - b.BitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1)) + b.bitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1)) profileOffset := getZipfOffset(b.ProfileIDRange, b.ProfileExponent, b.ProfileRatio) - b.ProfileRng = rand.NewZipf(rnd, b.ProfileExponent, profileOffset, uint64(b.ProfileIDRange-1)) + b.profileRng = rand.NewZipf(rnd, b.ProfileExponent, profileOffset, uint64(b.ProfileIDRange-1)) - b.BitmapPerm = NewPermutationGenerator(b.BitmapIDRange, b.Seed) - b.ProfilePerm = NewPermutationGenerator(b.ProfileIDRange, b.Seed+1) + b.bitmapPerm = NewPermutationGenerator(b.BitmapIDRange, b.Seed) + b.profilePerm = NewPermutationGenerator(b.ProfileIDRange, b.Seed+1) return b.HasClient.Init(hosts, agentNum) } @@ -146,11 +146,11 @@ func (b *ZipfSetBits) Run(ctx context.Context, agentNum int) map[string]interfac var start time.Time for n := 0; n < b.Iterations; n++ { // generate IDs from Zipf distribution - bitmapIDOriginal := b.BitmapRng.Uint64() - profIDOriginal := b.ProfileRng.Uint64() + bitmapIDOriginal := b.bitmapRng.Uint64() + profIDOriginal := b.profileRng.Uint64() // permute IDs randomly, but repeatably - bitmapID := b.BitmapPerm.Next(int64(bitmapIDOriginal)) - profID := b.ProfilePerm.Next(int64(profIDOriginal)) + bitmapID := b.bitmapPerm.Next(int64(bitmapIDOriginal)) + profID := b.profilePerm.Next(int64(profIDOriginal)) query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+int64(bitmapID), b.BaseProfileID+int64(profID)) start = time.Now() From 6c87b5c9d14e3e952ef2f63879a609372af62f9c Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 19 Dec 2016 18:11:06 -0600 Subject: [PATCH 6/8] Remove extraneous JSON tags --- bench/zipf.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/bench/zipf.go b/bench/zipf.go index 1c27d6184..744db7e03 100644 --- a/bench/zipf.go +++ b/bench/zipf.go @@ -17,23 +17,22 @@ import ( // It also uses PermutationGenerator to permute IDs randomly. type ZipfSetBits struct { HasClient - Name string `json:"name"` - BaseBitmapID int64 `json:"base-bitmap-id"` - BaseProfileID int64 `json:"base-profile-id"` - BitmapIDRange int64 `json:"bitmap-id-range"` - ProfileIDRange int64 `json:"profile-id-range"` - Iterations int `json:"iterations"` - Seed int64 `json:"seed"` - DB string `json:"db"` - bitmapRng *rand.Zipf `json:"-"` - ProfileRng *rand.Zipf `json:"-"` - BitmapPerm *PermutationGenerator `json:"-"` - ProfilePerm *PermutationGenerator `json:"-"` - + Name string `json:"name"` + BaseBitmapID int64 `json:"base-bitmap-id"` + BaseProfileID int64 `json:"base-profile-id"` + BitmapIDRange int64 `json:"bitmap-id-range"` + ProfileIDRange int64 `json:"profile-id-range"` + Iterations int `json:"iterations"` + Seed int64 `json:"seed"` + DB string `json:"db"` BitmapExponent float64 `json:"bitmap-exponent"` BitmapRatio float64 `json:"bitmap-ratio"` ProfileExponent float64 `json:"profile-exponent"` ProfileRatio float64 `json:"profile-ratio"` + bitmapRng *rand.Zipf + ProfileRng *rand.Zipf + BitmapPerm *PermutationGenerator + ProfilePerm *PermutationGenerator } func (b *ZipfSetBits) Usage() string { From 57406c21420d73cda37c8a3954154adc33017e58 Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Tue, 20 Dec 2016 10:04:10 -0600 Subject: [PATCH 7/8] Unexport zipf implementation details --- bench/zipf.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bench/zipf.go b/bench/zipf.go index 744db7e03..580214459 100644 --- a/bench/zipf.go +++ b/bench/zipf.go @@ -30,9 +30,9 @@ type ZipfSetBits struct { ProfileExponent float64 `json:"profile-exponent"` ProfileRatio float64 `json:"profile-ratio"` bitmapRng *rand.Zipf - ProfileRng *rand.Zipf - BitmapPerm *PermutationGenerator - ProfilePerm *PermutationGenerator + profileRng *rand.Zipf + bitmapPerm *PermutationGenerator + profilePerm *PermutationGenerator } func (b *ZipfSetBits) Usage() string { From a049bd3b3459fa982345bd5c12c16b82c9de6701 Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Tue, 20 Dec 2016 10:08:37 -0600 Subject: [PATCH 8/8] Fix benchmark names to match CLI --- bench/diagonal.go | 2 +- bench/import.go | 2 +- bench/multidb.go | 2 +- bench/random.go | 2 +- bench/randquery.go | 2 +- bench/sliceheight.go | 2 +- bench/zipf.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bench/diagonal.go b/bench/diagonal.go index fb782e97c..2a8ee23cb 100644 --- a/bench/diagonal.go +++ b/bench/diagonal.go @@ -21,7 +21,7 @@ type DiagonalSetBits struct { } func (b *DiagonalSetBits) Init(hosts []string, agentNum int) error { - b.Name = "DiagonalSetBits" + b.Name = "diagonal-set-bits" return b.HasClient.Init(hosts, agentNum) } diff --git a/bench/import.go b/bench/import.go index b3708d1a4..1b564533b 100644 --- a/bench/import.go +++ b/bench/import.go @@ -108,7 +108,7 @@ func (b *Import) Init(hosts []string, agentNum int) error { if len(hosts) == 0 { return fmt.Errorf("Need at least one host") } - b.Name = "Import" + b.Name = "import" b.Host = hosts[0] // generate csv data baseBitmapID, maxBitmapID, baseProfileID, maxProfileID := b.BaseBitmapID, b.MaxBitmapID, b.BaseProfileID, b.MaxProfileID diff --git a/bench/multidb.go b/bench/multidb.go index 36e672219..91693c325 100644 --- a/bench/multidb.go +++ b/bench/multidb.go @@ -19,7 +19,7 @@ type MultiDBSetBits struct { } func (b *MultiDBSetBits) Init(hosts []string, agentNum int) error { - b.Name = "MultiDBSetBits" + b.Name = "multi-db-set-bits" return b.HasClient.Init(hosts, agentNum) } diff --git a/bench/random.go b/bench/random.go index cf0b55832..3a648940e 100644 --- a/bench/random.go +++ b/bench/random.go @@ -25,7 +25,7 @@ type RandomSetBits struct { } func (b *RandomSetBits) Init(hosts []string, agentNum int) error { - b.Name = "RandomSetBits" + b.Name = "random-set-bits" return b.HasClient.Init(hosts, agentNum) } diff --git a/bench/randquery.go b/bench/randquery.go index 5f54e1a1e..82431485c 100644 --- a/bench/randquery.go +++ b/bench/randquery.go @@ -24,7 +24,7 @@ type RandomQuery struct { } func (b *RandomQuery) Init(hosts []string, agentNum int) error { - b.Name = "RandomQuery" + b.Name = "random-query" return b.HasClient.Init(hosts, agentNum) } diff --git a/bench/sliceheight.go b/bench/sliceheight.go index 94d97c419..bb9131859 100644 --- a/bench/sliceheight.go +++ b/bench/sliceheight.go @@ -85,7 +85,7 @@ func (b *SliceHeight) ConsumeFlags(args []string) ([]string, error) { } func (b *SliceHeight) Init(hosts []string, agentNum int) error { - b.Name = "SliceHeight" + b.Name = "slice-height" b.hosts = hosts return nil } diff --git a/bench/zipf.go b/bench/zipf.go index 580214459..84759dc0a 100644 --- a/bench/zipf.go +++ b/bench/zipf.go @@ -121,7 +121,7 @@ func getZipfOffset(N int64, exp, ratio float64) float64 { } func (b *ZipfSetBits) Init(hosts []string, agentNum int) error { - b.Name = "ZipfSetBits" + b.Name = "zipf-set-bits" rnd := rand.New(rand.NewSource(b.Seed + int64(agentNum))) bitmapOffset := getZipfOffset(b.BitmapIDRange, b.BitmapExponent, b.BitmapRatio) b.bitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1))