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

RUST-1337 Use tokio's AsyncRead and AsyncWrite traits #668

Merged
merged 8 commits into from
Jun 1, 2022

Conversation

patrickfreed
Copy link
Contributor

RUST-1337

Upgrading to the most recent version tokio-rustls and/or rustls caused a significant performance reduction in the driver when using rustls. This seems to have been fixed by switching to using tokio's AsyncRead trait for our stream types. I'm not entirely sure why this is the case to be honest, but it seems to work and reduced the code complexity a bit 🤷. For consistency, I also updated the write ends to use tokio's AsyncWrite, though that didn't have any effect on performance. As part of this, we can now remove the dependency on futures_io.

perf patch: https://evergreen.mongodb.com/version/6296cd21d6d80a79a5061a14

@patrickfreed patrickfreed marked this pull request as ready for review June 1, 2022 15:55
@kmahar
Copy link
Contributor

kmahar commented Jun 1, 2022

Out of curiosity, is there a way to see how this patch affects the existing perf graph you linked from the jira ticket? or did you just confirm the perf has improved manually?

Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

LGTM!

@patrickfreed
Copy link
Contributor Author

So if you click on a task (e.g. test-5.0-standalone) and click on a data point (a little arrow should appear), the % difference column will be populated. So for example, on the pre-regression point for BenchRead I'm seeing anywhere from -5% in score to +5%, which seems to be on track.

Co-authored-by: Abraham Egnor <[email protected]>
Copy link
Contributor

@kmahar kmahar left a comment

Choose a reason for hiding this comment

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

one question but LGTM!

})
let conn = connector
.connect_with(name, tcp_stream, |c| {
c.set_buffer_limit(None);
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to set this explicitly now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not actually sure if this is required or not, but in the latest rustls version the default limit was changed from unlimited (what we use here) to 64KB. I changed it back to unlimited as that was my first guess at why the perf regression happened, though it alone didn't seem to have a significant impact. That said, rustls sets it to None in their benchmarks, so perhaps its worth keeping here.

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm to explicitly set it to future-proof things

Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

lgtm!

@patrickfreed patrickfreed merged commit 7b0e259 into mongodb:main Jun 1, 2022
patrickfreed added a commit to patrickfreed/mongo-rust-driver that referenced this pull request Jun 1, 2022
This fixes a performance regression that resulted from upgrading tokio-rustls and/or rustls.
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.

4 participants