-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Producer performance tool #1222
Conversation
Looks great. 👍 |
default: | ||
printUsageErrorAndExit(fmt.Sprintf("Unknown -compression: %s", scheme)) | ||
} | ||
panic("should not happen") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason to use panic
, what about log.Fatal("should not happen")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is programming error and panic
prints a stack trace; if we hit this line, there's clearly a bug since we would have expected to exit on line 136.
} | ||
}() | ||
|
||
messagesDone := make(chan struct{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can pass context to these function and then exit on context.Done()
from go routine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean passing the context from the main routine to runAsyncProducer
or instantiating a new context in this function and replacing messagesDone
with it? The first case is not desirable because we don't want to exit from this function until this goroutine has finished (i.e. all the messages have been successfully sent, or an error occurred). The second case is really just a matter of style; we can wait on context.Done
at the end of the function or this messagesDone
channel. I don't have a huge preference here.
The channel removed in da81d9c was actually necessary to ensure that the final metrics are printed after the periodic ones are all finished.
This can be helpful, can we get it going? |
@thesalmontapes should I merge it? |
By all means! |
This tool mirrors
kafka-producer-perf-test.sh
in the Kafka distribution. I was using this myself for some performance testing on this library and thought I might as well drop this here in in case others find it useful.