Skip to content

Instantly share code, notes, and snippets.

@chrolis
Last active December 26, 2018 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrolis/049e18ddb66df415f23a0c6468c03af5 to your computer and use it in GitHub Desktop.
Save chrolis/049e18ddb66df415f23a0c6468c03af5 to your computer and use it in GitHub Desktop.
RFS/RPS/XPS 自動設定する君
#!/bin/sh
# references:
# - https://blog.yuuk.io/entry/linux-networkstack-tuning-rfs
# - https://qiita.com/saitara/items/aabb9c8869079ceb96a2
# - https://www.greptips.com/posts/1119/
set -ue
rps_sock_flow_entries=32768
for interface in /sys/class/net/eth*; do
# RFS/RPS
rxs=$(find "${interface}/queues" -maxdepth 1 -name 'rx-*' | wc -l)
rps_flow_cnt=$(( rps_sock_flow_entries / rxs ))
for qrx in "${interface}"/queues/rx-*; do
echo "echo 'FFFF' > ${qrx}/rps_cpus"
echo 'FFFF' > "${qrx}/rps_cpus"
echo "echo $rps_flow_cnt > ${qrx}/rps_flow_cnt"
echo $rps_flow_cnt > "${qrx}/rps_flow_cnt"
done
# XPS
i=0
for qtx in "${interface}"/queues/tx-*; do
echo "echo 2^${i} | bc > ${qtx}/xps_cpus"
echo 2^${i} | bc > "${qtx}/xps_cpus"
i=$(( i + 1 ))
done
done
echo 32768 > /proc/sys/net/core/rps_sock_flow_entries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment