Skip to content

Commit c7a2b55

Browse files
committed
Enlarge TCP recv_buf to improve throughput
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]>
1 parent 5a53839 commit c7a2b55

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

illumos-utils/src/ipadm.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,36 @@ impl Ipadm {
197197
Self::ensure_ip_addrobj_exists(&addrobj, AddrObjType::DHCP)?;
198198
Ok(())
199199
}
200+
201+
/// Set TCP recv_buf to 1 MB.
202+
pub fn set_tcp_recv_buf() -> Result<(), ExecutionError> {
203+
let mut cmd = std::process::Command::new(PFEXEC);
204+
let cmd = cmd.args(&[
205+
IPADM,
206+
"set-prop",
207+
"-t",
208+
"-p",
209+
"recv_buf=1000000",
210+
"tcp",
211+
]);
212+
execute(cmd)?;
213+
214+
Ok(())
215+
}
216+
217+
/// Set TCP congestion control algorithm to `cubic`.
218+
pub fn set_tcp_congestion_control() -> Result<(), ExecutionError> {
219+
let mut cmd = std::process::Command::new(PFEXEC);
220+
let cmd = cmd.args(&[
221+
IPADM,
222+
"set-prop",
223+
"-t",
224+
"-p",
225+
"congestion_control=cubic",
226+
"tcp",
227+
]);
228+
execute(cmd)?;
229+
230+
Ok(())
231+
}
200232
}

zone-setup/src/bin/zone-setup.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,17 @@ async fn common_nw_set_up(
563563
Ipadm::set_interface_mtu(&datalink)
564564
.with_context(|| format!("failed to set MTU on datalink {datalink}"))?;
565565

566+
info!(
567+
log, "Setting TCP recv_buf size to 1 MB";
568+
);
569+
Ipadm::set_tcp_recv_buf().context("failed to set TCP recv_buf")?;
570+
571+
info!(
572+
log, "Setting TCP congestion control algorithm to cubic";
573+
);
574+
Ipadm::set_tcp_congestion_control()
575+
.context("failed to set TCP congestion_control")?;
576+
566577
if static_addrs.is_empty() {
567578
info!(
568579
log,

0 commit comments

Comments
 (0)