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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion illumos-utils/src/ipadm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Ipadm {
Ok(Self::addrobj_addr(addrobj)?.is_some())
}

// Set MTU to 9000 on both IPv4 and IPv6
/// Set MTU to 9000 on both IPv4 and IPv6
pub fn set_interface_mtu(datalink: &str) -> Result<(), ExecutionError> {
let mut cmd = std::process::Command::new(PFEXEC);
let cmd = cmd.args(&[
Expand Down Expand Up @@ -197,4 +197,44 @@ impl Ipadm {
Self::ensure_ip_addrobj_exists(&addrobj, AddrObjType::DHCP)?;
Ok(())
}

/// Set TCP recv_buf to 1 MB.
pub fn set_tcp_recv_buf() -> Result<(), ExecutionError> {
let mut cmd = std::process::Command::new(PFEXEC);

// This is to improve single-connection throughput on large uploads
// from clients, e.g., images. Modern browsers will almost always use
// HTTP/2, which will multiplex concurrent writes to the same host over
// a single TCP connection. The small default receive window size is a
// major bottleneck, see
// https://github.com/oxidecomputer/console/issues/2096 for further
// details.
let cmd = cmd.args(&[
IPADM,
"set-prop",
"-t",
"-p",
"recv_buf=1000000",
"tcp",
]);
execute(cmd)?;

Ok(())
}

/// Set TCP congestion control algorithm to `cubic`.
pub fn set_tcp_congestion_control() -> Result<(), ExecutionError> {
let mut cmd = std::process::Command::new(PFEXEC);
let cmd = cmd.args(&[
IPADM,
"set-prop",
"-t",
"-p",
"congestion_control=cubic",
"tcp",
]);
execute(cmd)?;

Ok(())
}
}
11 changes: 11 additions & 0 deletions zone-setup/src/bin/zone-setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,17 @@ async fn common_nw_set_up(
Ipadm::set_interface_mtu(&datalink)
.with_context(|| format!("failed to set MTU on datalink {datalink}"))?;

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")?;

Comment on lines +566 to +576
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.

if static_addrs.is_empty() {
info!(
log,
Expand Down
Loading