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

Enlarge TCP recv_buf to improve throughput #6690

Merged
merged 3 commits into from
Oct 1, 2024
Merged

Conversation

wfchandler
Copy link
Contributor

@wfchandler wfchandler commented Sep 26, 2024

Image uploads performed via the web console are 3-4x slower than uploads performed via the Oxide CLI. We found that the CLI creates 8 separate TCP connections to upload the image chunks, while the console uses HTTP/2 to multiplex a single TCP connection six ways. The default TCP recv_buf size on Helios is 128 KB, which limits window size and therefore the number of packets that can be sent in parallel. By increasing this value to 1 MB, we can increase single-connection
throughput by ~3x, bringing console performance to rough parity with the CLI.

This does increase the amount of memory a potential DoS attack could consume, but 1 MB is still quite small relative to the total resources available on a compute sled.

While we're at it, also update the TCP congestion control algorithm to cubic from its default value of sunreno, which may also help improve throughput.

Closes #6601

@wfchandler wfchandler changed the title Wc/set recv buf Enlarge TCP recv_buf to improve throughput Sep 26, 2024
@wfchandler wfchandler marked this pull request as ready for review September 27, 2024 13:45
Copy link
Contributor

@karencfv karencfv left a comment

Choose a reason for hiding this comment

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

Sweet! Can't wait to have fast uploads through the console! Just have a question

Comment on lines +563 to +576
info!(
log, "Setting TCP recv_buf size to 1 MB";
);
Ipadm::set_tcp_recv_buf().context("failed to set TCP recv_buf")?;

info!(
log, "Setting TCP congestion control algorithm to cubic";
);
Ipadm::set_tcp_congestion_control()
.context("failed to set TCP congestion_control")?;

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this being set to all zones and not just nexus?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it's easier and Josh said it was "probably fine." However, it would probably be pretty easy to make it part of a command or flag that is only used by the Nexus zone setter upper.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's basically fine everywhere, FWIW. We should test to make sure that everything still works before and after obviously but I don't expect there will be any issues

Copy link
Contributor

Choose a reason for hiding this comment

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

Sadly, it wouldn't be as straightforward as it seems to implement only to Nexus. Currently there's no nexus-specific SMF service that's required before the nexus service starts. We'd have to create a new service and do something like #5440.

I'm a bit wary of doing a blanket change to system defaults of all zones as we don't really have a comprehensive integration testing suite for this.

If everyone is OK with it, perhaps we can go the safer way? Not sure how urgent this is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you would want to create a new service. Rather, I would have the existing service accept an SMF property for configuration, which would be absent by default, and which you could override in the SMF profile we pass to the Nexus zone specifically

Copy link
Collaborator

Choose a reason for hiding this comment

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

But also I think it's low risk and I would probably just do it

Copy link
Contributor

Choose a reason for hiding this comment

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

I trust the duke of illumos on this. From what I read elsewhere, it sounds like the default value is probably low for modern hardware anyway!

Copy link
Contributor

Choose a reason for hiding this comment

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

This service also runs in the switch zone, are we sure this wouldn't have unintended consequences?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll leave it up to all of you! If you're all ok with it then I'm ok with it. Can we just add a comment on the code with an explanation of why we're setting those new values?

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've added a comment explaining why we're increasing recv_buf.

Fix comment type on `set_interface_mtu`.
Image uploads performed via the web console are 3-4x slower than
uploads performed via the Oxide CLI[0]. We found that the CLI creates
8 separate TCP connections to upload the image chunks, while the console
uses HTTP/2 to multiplex a single TCP connection six ways. The default
TCP `recv_buf` size on Helios is 128 KB, which limits window size and
therefore the number of packets that can be sent in parallel. By
increasing this value to 1 MB, we can increase single-connection
throughput by ~3x, bringing console performance to rough parity with
the CLI.

This does increase the amount of memory a potential DoS attack could
consume, but 1 MB is still quite small relative to the total resources
available on a compute sled.

While we're at it, also update the TCP congestion control algorithm to
`cubic` from its default value of `sunreno`, which may also help improve
throughput.

Closes #6601

[0] oxidecomputer/console#2096

Assisted-by: David Crespo <[email protected]>
@wfchandler
Copy link
Contributor Author

Rebasing to resolve CI failures.

Copy link
Contributor

@david-crespo david-crespo left a comment

Choose a reason for hiding this comment

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

Let's do it! Might be good to get someone to test it on a full stack setup that's not dogfood. But merging to main will probably cause that to happen anyway.

@wfchandler wfchandler merged commit c9f739d into main Oct 1, 2024
16 checks passed
@wfchandler wfchandler deleted the wc/set-recv-buf branch October 1, 2024 20:33
hawkw pushed a commit that referenced this pull request Oct 2, 2024
Image uploads performed via the [web console are 3-4x slower than
uploads performed via the Oxide
CLI](oxidecomputer/console#2096). We found
that the CLI creates 8 separate TCP connections to upload the image
chunks, while the console uses HTTP/2 to multiplex a single TCP
connection six ways. The default TCP `recv_buf` size on Helios is 128
KB, which limits window size and therefore the number of packets that
can be sent in parallel. By increasing this value to 1 MB, we can
increase single-connection
throughput by ~3x, bringing console performance to rough parity with the
CLI.
      
This does increase the amount of memory a potential DoS attack could
consume, but 1 MB is still quite small relative to the total resources
available on a compute sled.
      
While we're at it, also update the TCP congestion control algorithm to
`cubic` from its default value of `sunreno`, which may also help improve
throughput.
      
Closes #6601
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.

Default 128 KB TCP receive buffer causes slow image uploads when using a single TCP connection
4 participants