Skip to content

Add network-tunings.sh for NIC RX tuning#25

Open
Hutch-45D wants to merge 1 commit intomainfrom
dev-hutch
Open

Add network-tunings.sh for NIC RX tuning#25
Hutch-45D wants to merge 1 commit intomainfrom
dev-hutch

Conversation

@Hutch-45D
Copy link
Copy Markdown
Contributor

Add a new script that detects physical network interfaces and configures ethtool RX ring sizes (preferring 4096, falling back to 2047). The script sets net.core.netdev_budget, writes a persistent sysctl file (/etc/sysctl.d/99-netdev-budget.conf), and generates a NetworkManager dispatcher script (/etc/NetworkManager/dispatcher.d/45-ethtool) to reapply RX settings on interface up. It validates changes, creates backups of existing dispatcher/sysctl files, and requires root and ethtool to run.

Add a new script that detects physical network interfaces and configures ethtool RX ring sizes (preferring 4096, falling back to 2047). The script sets net.core.netdev_budget, writes a persistent sysctl file (/etc/sysctl.d/99-netdev-budget.conf), and generates a NetworkManager dispatcher script (/etc/NetworkManager/dispatcher.d/45-ethtool) to reapply RX settings on interface up. It validates changes, creates backups of existing dispatcher/sysctl files, and requires root and ethtool to run.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new host-tuning shell script intended to optimize NIC receive behavior by adjusting RX ring sizes via ethtool and increasing net.core.netdev_budget, with persistence across reboots and link events through a sysctl drop-in and a NetworkManager dispatcher script.

Changes:

  • Detects “physical” interfaces from /sys/class/net and applies RX ring sizing (prefer 4096, fall back to 2047).
  • Sets net.core.netdev_budget immediately and persists it via /etc/sysctl.d/99-netdev-budget.conf.
  • Generates /etc/NetworkManager/dispatcher.d/45-ethtool to reapply RX ring settings on interface “up”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread network-tunings.sh
echo
echo "Writing static dispatcher script: $DISPATCHER_SCRIPT"

[[ -f "$DISPATCHER_SCRIPT" ]] && cp "$DISPATCHER_SCRIPT" "$DISPATCHER_SCRIPT.bak"
Comment thread network-tunings.sh
Comment on lines +75 to +81
echo "Writing static dispatcher script: $DISPATCHER_SCRIPT"

[[ -f "$DISPATCHER_SCRIPT" ]] && cp "$DISPATCHER_SCRIPT" "$DISPATCHER_SCRIPT.bak"

cat > "$DISPATCHER_SCRIPT" <<'EOF'
#!/bin/bash
EOF
Comment thread network-tunings.sh
Comment on lines +32 to +42
detect_rx_size() {
local iface="$1"

if ethtool -G "$iface" rx "$PREFERRED_RX" >/dev/null 2>&1; then
echo "$PREFERRED_RX"
elif ethtool -G "$iface" rx "$FALLBACK_RX" >/dev/null 2>&1; then
echo "$FALLBACK_RX"
else
echo ""
fi
}
Comment thread network-tunings.sh
net.core.netdev_budget=$NETDEV_BUDGET
EOF

sysctl --system >/dev/null
Comment thread network-tunings.sh
Comment on lines +108 to +115
echo
echo "Validating applied settings..."
ACTUAL_BUDGET="$(sysctl -n net.core.netdev_budget)"
if [[ "$ACTUAL_BUDGET" == "$NETDEV_BUDGET" ]]; then
echo "✓ net.core.netdev_budget correctly set to $NETDEV_BUDGET"
else
echo "✗ Warning: net.core.netdev_budget is $ACTUAL_BUDGET (expected $NETDEV_BUDGET)"
fi
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.

2 participants