Skip to content

Commit 40b6da6

Browse files
committed
perftune: tune tcp_mem
tcp_mem defaults to 9% of memory, while Seastar defaults to 93% of memory. These sum to 102% which leads to OOM. Fix by tuning tcp_mem, by default to 3% of memory. The low/pressure/max ratios are the same as those selected by the kernel.
1 parent a3ccb7a commit 40b6da6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: scripts/perftune.py

+12
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,17 @@ def tune(self):
606606
# did not receive an acknowledgment from connecting client.
607607
fwriteln_and_log('/proc/sys/net/ipv4/tcp_max_syn_backlog', '4096')
608608

609+
self.tune_tcp_mem()
610+
611+
def tune_tcp_mem(self):
612+
page_size = os.sysconf("SC_PAGE_SIZE")
613+
phys_mem = os.sysconf("SC_PHYS_PAGES") * page_size
614+
# We only tune for physical memory since tcp_mem is virtualized
615+
def to_pages(bytes):
616+
return math.ceil(bytes / page_size)
617+
max = phys_mem * self.args.tcp_mem_fraction
618+
fwriteln_and_log('/proc/sys/net/ipv4/tcp_mem', f"{to_pages(max / 2)} {to_pages(max * 2/3)} {to_pages(max)}")
619+
609620
def nic_is_bond_iface(self, nic):
610621
return self.__nic_is_bond_iface.get(nic, False)
611622

@@ -1627,6 +1638,7 @@ def names():
16271638
"CPU cores out of available according to a 'cpu_mask' value."
16281639
"Default is 16",
16291640
type=int, default=16, dest='cores_per_irq_core')
1641+
argp.add_argument('--tcp-mem-fraction', default=0.03, type=float, help="Fraction of total memory to allocate for TCP buffers")
16301642

16311643
def parse_cpu_mask_from_yaml(y, field_name, fname):
16321644
hex_32bit_pattern='0x[0-9a-fA-F]{1,8}'

0 commit comments

Comments
 (0)