Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

etcdctl: add initial check perf command #7591

Merged
merged 1 commit into from
Mar 28, 2017
Merged

Conversation

xiang90
Copy link
Contributor

@xiang90 xiang90 commented Mar 24, 2017

This is a very simple performance validation command. The output is PASS or FAIL. There is nothing much to tune by design. If users want to find out more information, they should use benchmark tool instead.

example output:

ETCDCTL_API=3 ./etcdctl validate-perf --load=m
 60 / 60 Booooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo! 100.00%1m0s
PASS: Throughput is 968 writes/s
PASS: Slowest request took 0.490595s
PASS: Stddev is 0.030787s
PASS

I am going to finish up docs if this direction looks good. /cc @heyitsanthony @gyuho

@xiang90
Copy link
Contributor Author

xiang90 commented Mar 24, 2017

My poor laptop failed large load test

ETCDCTL_API=3 ./etcdctl validate-perf --load=l
 60 / 60 Booooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo! 100.00%1m0s
FAIL: Throughput too low: 5007 writes/s
Slowest request took too long: 1.204120s
Stddev too high: 0.100497s
FAIL

@gyuho
Copy link
Contributor

gyuho commented Mar 24, 2017

Is this for #6991?

@xiang90
Copy link
Contributor Author

xiang90 commented Mar 24, 2017

@gyuho yes.

// NewValidatePerfCommand returns the cobra command for "validate-perf".
func NewValidatePerfCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "validate-perf [options]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-perf? check perf? perf check? perf? must be a better name..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perf seems ok. @gyuho @fanminshi any idea?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-perf +1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's going to be check-perf, then check perf might be better. There's probably a few aspects of the cluster worth checking aside from only performance (e.g., check if running latest version, check if hashes match, ...) so check could cover all those as subcommands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check perf sounds good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. will change.


for limit.Wait(ctx) == nil {
binary.PutVarint(k, int64(rand.Intn(math.MaxInt64)))
requests <- v3.OpPut(string(k), v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a cluster and it looks like it's performing slow. So I run validate-perf to check if it's OK and now the cluster is full of garbage.

Force the command to take a prefix, check if the prefix is empty, and if so, put into the prefix and delete the whole thing on completion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. My initial thought is that this tool should be used pre installation. But we can make it better with very little effort.

if ok {
fmt.Println("PASS")
} else {
fmt.Println("FAIL")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exit(1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@xiang90 xiang90 force-pushed the validate branch 4 times, most recently from f82ff26 to 27aefe9 Compare March 24, 2017 20:28
@xiang90 xiang90 changed the title etcdctl: add initial validate-perf command etcdctl: add initial check perf command Mar 24, 2017
@xiang90
Copy link
Contributor Author

xiang90 commented Mar 24, 2017

@heyitsanthony PTAL.


// TODO: support customized configuration
cmd.Flags().StringVar(&checkPerfLoad, "load", "s", "The workload to check the performance. Options are: s(small), m(medium), l(large), xl(xLarge).")
cmd.Flags().StringVar(&checkPerfPrefix, "prefix", "/etcdctl-check-perf/", "The key prefix used to check the performance.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix for writing the performance check's keys?

}

// TODO: support customized configuration
cmd.Flags().StringVar(&checkPerfLoad, "load", "s", "The workload to check the performance. Options are: s(small), m(medium), l(large), xl(xLarge).")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The performance check's workload model. Accepted workloads: s(small), m(medium), l(large), xl(xLarge)?

func NewCheckCommand() *cobra.Command {
cc := &cobra.Command{
Use: "check <subcommand>",
Short: "check related commands",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commands for checking properties of the etcd cluster?

var cfg checkPerfCfg
switch checkPerfLoad {
case "s", "small":
cfg = checkPerfCfgMap["s"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var checkPerfAlias = map[string]string {"s" : "s", "small" : "s", ...}
...
cfg, ok := checkPerfAlias[checkPerfLoad]
if !ok { ExitWithError(...) }

?

r := report.NewReport("%4.4f")
var wg sync.WaitGroup

for i := range clients {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wg.Add(len(clients)) before loop instead of wg.Add(1)?

ticker := time.NewTicker(time.Second)

for i := 0; i < cfg.duration; i++ {
<-ticker.C
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just time.Sleep(time.Second)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. I was going to add some cancelation logic. But I guess it is not needed.

for i := 0; i < cfg.clients; i++ {
clients = append(clients, mustClientFromCmd(cmd))
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some kind of check to avoid clobbering prefixes?

resp, _ := clients[0].Range(context.Background(), checkPerfPrefix, v3.WithPrefix(), v3.WithLimit(1))
if len(resp.Kvs) > 0 {
    ExitWithError(ExitInvalidInput, fmt.Sprintf("prefix %q has keys. Delete with etcdctl del --prefix %s", checkPerfPrefix, checkPerfPrefix)
}

@gyuho gyuho added this to the v3.2.0 milestone Mar 25, 2017
@codecov-io
Copy link

codecov-io commented Mar 25, 2017

Codecov Report

Merging #7591 into master will decrease coverage by 0.38%.
The diff coverage is 15.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7591      +/-   ##
==========================================
- Coverage   73.95%   73.56%   -0.39%     
==========================================
  Files         325      326       +1     
  Lines       26454    26552      +98     
==========================================
- Hits        19565    19534      -31     
- Misses       5441     5558     +117     
- Partials     1448     1460      +12
Impacted Files Coverage Δ
etcdctl/ctlv3/ctl.go 100% <100%> (ø) ⬆️
etcdctl/ctlv3/command/check.go 14.43% <14.43%> (ø)
pkg/transport/timeout_conn.go 80% <0%> (-20%) ⬇️
clientv3/namespace/watch.go 87.87% <0%> (-12.13%) ⬇️
pkg/adt/interval_tree.go 83.83% <0%> (-7.75%) ⬇️
etcdserver/api/v3rpc/util.go 52.77% <0%> (-2.78%) ⬇️
mvcc/watchable_store.go 84.49% <0%> (-1.56%) ⬇️
rafthttp/peer.go 90.07% <0%> (-1.53%) ⬇️
pkg/netutil/netutil.go 80.88% <0%> (-1.48%) ⬇️
clientv3/balancer.go 95.32% <0%> (-1.17%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4ab5e5...60d3375. Read the comment docs.

@xiang90 xiang90 force-pushed the validate branch 2 times, most recently from 2ab354d to 62e9390 Compare March 25, 2017 03:06
Copy link
Contributor

@heyitsanthony heyitsanthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two nits, lgtm otherwise

ExitWithError(ExitError, err)
}
if len(resp.Kvs) > 0 {
ExitWithError(ExitInvalidInput, fmt.Errorf("prefix %q has keys. Delete with etcdctl del --prefix %s before check the performance.", checkPerfPrefix, checkPerfPrefix))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ before check the performance./first.?

}

var cfg checkPerfCfg
switch checkPerfAlias[checkPerfLoad] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model, ok := checkPerfAlias[checkPerfLoad]
if !ok {
    ExitWithError(ExitBadFeature, fmt.Errorf("unknown load option %v", checkPerfLoad))
}
cfg := checkPerfCfgMap[model]

?

@heyitsanthony
Copy link
Contributor

lgtm. Thanks!

@xiang90 xiang90 merged commit 65ad91b into etcd-io:master Mar 28, 2017
@xiang90 xiang90 deleted the validate branch March 28, 2017 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants