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

Add transaction rate setting to perfclient #1071

Merged
merged 5 commits into from
Apr 17, 2020
Merged

Add transaction rate setting to perfclient #1071

merged 5 commits into from
Apr 17, 2020

Conversation

lynshi
Copy link
Contributor

@lynshi lynshi commented Apr 15, 2020

The --transaction-rate flag allows one to specify the transaction rate (tx/s) of the client. If a transaction rate is specified, the client computes the interval between writes needed to maintain this rate, and waits this amount between writes.

@lynshi lynshi requested a review from a team as a code owner April 15, 2020 20:19
Copy link
Member

@achamayou achamayou left a comment

Choose a reason for hiding this comment

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

LGTM

@achamayou
Copy link
Member

/azp run

@ccf-bot
Copy link
Collaborator

ccf-bot commented Apr 16, 2020

master@7385 aka 20200417.2 vs master ewma over 50 builds from 6937 to 7385
images

@achamayou
Copy link
Member

@lynshi you need to format your code, that can be done with:

./check-format -f src samples

@@ -379,6 +391,12 @@ namespace client
size_t read;
size_t written;

if (options.transactions_per_s > 0) {
write_delay_us = 1000000 / options.transactions_per_s;
connection->set_tcp_nodelay(true);
Copy link
Member

Choose a reason for hiding this comment

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

We should set TCP_NODELAY in all cases, outside of this check. Even without a target transaction rate, this should make the performance tests more predictable.

Copy link
Member

Choose a reason for hiding this comment

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

In throughput tests, I don't expect it will produce a measurable effect, we are writing heavily.

Copy link
Member

@eddyashton eddyashton left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I have some minor suggestions to simplify the code, and please run clang-format.

@@ -431,13 +449,31 @@ namespace client
size_t& written,
const std::shared_ptr<RpcTlsClient>& connection)
{
if (write_delay_us > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

If I'm reading this correctly, we can remove time_elapsed_between_writes_ns entirely:

while (std::chrono::high_resolution_clock::now() - last_write_time < write_delay)
{
  continue;
}

Then we can remove the if (write_delay > 0) checks here and below - this while loop will always break on the first iteration, and writing last_write_time all the time is harmless.

@@ -289,6 +297,10 @@ namespace client
timing::ResponseTimes response_times;
timing::CommitPoint last_response_commit = {0, 0};

std::chrono::high_resolution_clock::time_point last_write_time;
int64_t time_elapsed_between_writes_us;
int64_t write_delay_us = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This could be more strongly typed: std::chrono::nanoseconds write_delay = 0;

(I'd prefer nanoseconds rather than microseconds so we keep some precision as we approach 100k tx/s)

@lynshi
Copy link
Contributor Author

lynshi commented Apr 16, 2020

Thanks for the suggestions @eddyashton; I've implemented them. However, I still only set TCP_NODELAY when a transaction rate is specified, since I'm not sure if setting it for your tests is what you want.

Copy link
Member

@eddyashton eddyashton left a comment

Choose a reason for hiding this comment

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

LGTM!

@eddyashton
Copy link
Member

/azp run

@achamayou achamayou merged commit d6aefca into microsoft:master Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants