Token导航 LogoToken导航TokenDH.com
前端设计可写文件github未标认证来源可访问许可证需确认审计提醒

performance-tuning性能调优

Agent Skill

用于辅助云资源、部署、容器、基础设施和运维自动化任务。它适合让 Agent 检查配置、整理部署步骤、分析资源状态、生成排障思路或辅助云服务接入。使用时需要明确目标环境、账号权限、区域和资源组,区分本地测试与生产操作;涉及删除资源、重启服务、修改网络或权限配置时,应先确认影响范围。

总安装

1,105

周安装

47

GitHub Stars

18

下载量

387
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:performance-tuning(性能调优)
来源仓库:https://github.com/bagelhole/devops-security-agent-skills
仓库路径:skills/performance-tuning
安装命令:
npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill performance-tuning
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill performance-tuning

简介

用于 Linux 系统性能优化,涵盖内核参数、I/O 调度、内存与 CPU 管理。

  • 适合解决高延迟、吞吐量瓶颈或资源耗尽问题,建立性能基准。
  • 提供 sysctl 调优、CPU governor 配置与 benchmark 工具使用指导。
  • 需 root/sudo 权限,适用于数据库、Web 服务器等高负载场景。
  • performance-tuning 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Performance Tuning

Optimize Linux system performance through kernel parameter tuning, I/O scheduler selection, memory management, CPU governor configuration, and benchmarking. Covers methodology, real sysctl settings, and tool-based validation.

When to Use

  • Server experiencing high latency, throughput bottlenecks, or resource exhaustion
  • Preparing infrastructure for high-traffic events or load tests
  • Tuning a database server, web server, or application host for production
  • Diagnosing whether a bottleneck is CPU, memory, disk I/O, or network
  • Establishing baseline performance metrics before and after changes
  • Configuring kernel parameters for containers, VMs, or bare-metal hosts

Prerequisites

  • Root or sudo access on the target system
  • sysstat package installed (provides sar, iostat, mpstat)
  • linux-tools or perf package for CPU profiling
  • Benchmarking tools: fio (disk), sysbench (CPU/memory), iperf3 (network)
  • Baseline metrics collected before making any changes

Performance Analysis Methodology

Always follow this order:

  1. Collect baseline -- measure current performance with tools
  2. Identify bottleneck -- determine if CPU, memory, I/O, or network
  3. Change one parameter -- apply a single tuning change
  4. Measure impact -- re-run the same benchmark
  5. Document -- record the change and its effect
  6. Iterate or revert -- keep the change if beneficial, revert if not

System Monitoring Tools

# CPU and process monitoring
top                              # Interactive process viewer
htop                             # Enhanced interactive viewer
mpstat -P ALL 2                  # Per-CPU utilization every 2 seconds
pidstat -u 2                     # Per-process CPU usage

# Memory monitoring
free -h                          # Memory summary
vmstat 2                         # Virtual memory stats every 2 seconds
# Columns: r=runnable, b=blocked, si/so=swap in/out, bi/bo=block I/O

# Disk I/O monitoring
iostat -xz 2                     # Extended disk stats every 2 seconds
# Key columns: %util, await (latency), r/s, w/s
iotop -oP                        # Show processes doing I/O

# Network monitoring
sar -n DEV 2                     # Network interface stats
ss -s                            # Socket summary
nstat                            # Network counters

# CPU profiling (requires perf)
perf top                         # Real-time function-level CPU profiling
perf stat -a sleep 10            # System-wide counters for 10 seconds
perf record -g -a sleep 30       # Record 30 seconds of call stacks
perf report                      # Analyze recorded data

# One-liner: check all major resources
echo "=== CPU ===" && mpstat 1 1 && echo "=== MEM ===" && free -h && echo "=== DISK ===" && iostat -x 1 1 && echo "=== NET ===" && ss -s

Sysctl Kernel Parameter Tuning

Network Tuning

# /etc/sysctl.d/60-network-performance.conf

# Increase the maximum socket receive/send buffer sizes
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.core.rmem_default = 1048576
net.core.wmem_default = 1048576

# TCP buffer auto-tuning (min, default, max in bytes)
net.ipv4.tcp_rmem = 4096 1048576 134217728
net.ipv4.tcp_wmem = 4096 1048576 134217728

# Increase connection backlog for high-traffic servers
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.core.netdev_max_backlog = 65535

# Enable TCP fast open (client and server)
net.ipv4.tcp_fastopen = 3

# Reuse TIME_WAIT sockets for new connections
net.ipv4.tcp_tw_reuse = 1

# Increase the range of ephemeral ports
net.ipv4.ip_local_port_range = 1024 65535

# TCP keepalive tuning (detect dead connections faster)
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 3

# Disable slow start after idle (keeps congestion window open)
net.ipv4.tcp_slow_start_after_idle = 0

# Enable BBR congestion control (requires kernel 4.9+)
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

Memory Tuning

# /etc/sysctl.d/60-memory-performance.conf

# Reduce swappiness (0-100, lower = less swap usage)
# 10 for general servers, 1 for database servers
vm.swappiness = 10

# Dirty page ratios (controls when dirty data is flushed to disk)
# Lower values = more frequent, smaller writes (better for SSDs)
vm.dirty_ratio = 20
vm.dirty_background_ratio = 5

# For large-memory systems writing to fast storage
# vm.dirty_ratio = 40
# vm.dirty_background_ratio = 10

# Increase inotify limits (for apps watching many files)
fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 1024

# Maximum number of open file descriptors system-wide
fs.file-max = 2097152

# Virtual memory overcommit
# 0 = heuristic (default), 1 = always overcommit, 2 = never overcommit
vm.overcommit_memory = 0

# For Redis or similar in-memory stores, use:
# vm.overcommit_memory = 1

# Disable Transparent Huge Pages if it causes latency spikes (common with databases)
# Done via boot parameter or runtime:
# echo madvise > /sys/kernel/mm/transparent_hugepage/enabled

Applying Sysctl Changes

# Apply all sysctl files
sysctl --system

# Apply a specific file
sysctl -p /etc/sysctl.d/60-network-performance.conf

# Set a parameter temporarily (lost on reboot)
sysctl -w vm.swappiness=10

# Verify a parameter
sysctl vm.swappiness
sysctl net.ipv4.tcp_congestion_control

I/O Scheduler Configuration

# Check the current scheduler for a device
cat /sys/block/sda/queue/scheduler
# Output example: [mq-deadline] none kyber bfq

# Set the scheduler temporarily
echo mq-deadline > /sys/block/sda/queue/scheduler   # Good for databases
echo none > /sys/block/nvme0n1/queue/scheduler       # Best for NVMe SSDs
echo bfq > /sys/block/sda/queue/scheduler            # Good for interactive desktop

# Scheduler recommendations:
# NVMe SSD:  none (noop)    -- minimal overhead, hardware handles scheduling
# SATA SSD:  mq-deadline    -- provides fairness with low latency
# HDD:       mq-deadline    -- prevents starvation, good for databases
# Desktop:   bfq            -- prioritizes interactive I/O

# Make persistent via udev rule
cat <<'EOF' > /etc/udev/rules.d/60-io-scheduler.rules
# Set mq-deadline for rotational (HDD) devices
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="mq-deadline"
# Set none for non-rotational (SSD/NVMe) devices
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="none"
EOF

udevadm control --reload-rules

# Tune read-ahead for sequential workloads (database sequential scans)
blockdev --setrahead 4096 /dev/sda    # 4096 sectors = 2 MB

# Enable TRIM for SSDs (weekly via systemd timer)
systemctl enable --now fstrim.timer
fstrim -av    # Manual run

CPU Governor Configuration

# Check available governors
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
# Output: performance powersave schedutil

# Check current governor
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Set all CPUs to performance mode (maximum frequency)
for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
  echo performance > "$cpu"
done

# Set using cpupower (if installed)
cpupower frequency-set -g performance

# Governor recommendations:
# Server (production):   performance    -- max frequency, lowest latency
# Server (general):      schedutil      -- kernel-driven dynamic scaling
# Laptop / idle server:  powersave      -- minimize power consumption

# Make persistent via systemd service
cat <<'EOF' > /etc/systemd/system/cpu-governor.service
[Unit]
Description=Set CPU governor to performance

[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower frequency-set -g performance
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

systemctl enable --now cpu-governor

# Disable CPU boost (turbo) if consistent latency is needed
echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo

Benchmarking Tools

fio -- Disk I/O Benchmarking

# Install fio
apt install -y fio    # Debian/Ubuntu
dnf install -y fio    # RHEL/CentOS

# Sequential read test (simulates backup reads)
fio --name=seq-read --ioengine=libaio --direct=1 --rw=read \
  --bs=1M --numjobs=4 --size=1G --runtime=60 --time_based --group_reporting

# Sequential write test
fio --name=seq-write --ioengine=libaio --direct=1 --rw=write \
  --bs=1M --numjobs=4 --size=1G --runtime=60 --time_based --group_reporting

# Random read (4K blocks -- simulates database IOPS)
fio --name=rand-read --ioengine=libaio --direct=1 --rw=randread \
  --bs=4k --numjobs=16 --iodepth=64 --size=1G --runtime=60 --time_based --group_reporting

# Random write (4K blocks)
fio --name=rand-write --ioengine=libaio --direct=1 --rw=randwrite \
  --bs=4k --numjobs=16 --iodepth=64 --size=1G --runtime=60 --time_based --group_reporting

# Mixed random read/write (70/30 -- typical database workload)
fio --name=mixed --ioengine=libaio --direct=1 --rw=randrw --rwmixread=70 \
  --bs=4k --numjobs=8 --iodepth=32 --size=1G --runtime=60 --time_based --group_reporting

sysbench -- CPU and Memory Benchmarking

# Install: apt install -y sysbench (Debian) / dnf install -y sysbench (RHEL)

# CPU benchmark
sysbench cpu --threads=4 --time=30 run

# Memory benchmark
sysbench memory --threads=4 --time=30 --memory-block-size=1K --memory-total-size=100G run

iperf3 -- Network Benchmarking

# Install iperf3
apt install -y iperf3

# Start server on one host
iperf3 -s

# Run client test from another host
iperf3 -c <server-ip> -t 30 -P 4    # 30 seconds, 4 parallel streams

# Test with UDP (measure packet loss)
iperf3 -c <server-ip> -u -b 1G -t 30

# Reverse mode (server sends to client)
iperf3 -c <server-ip> -R -t 30

Quick-Reference Tuning Profiles

Web Server (nginx/Apache)

# /etc/sysctl.d/60-webserver.conf
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fastopen = 3
net.ipv4.ip_local_port_range = 1024 65535
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
fs.file-max = 2097152
vm.swappiness = 10

Database Server (PostgreSQL/MySQL)

# /etc/sysctl.d/60-database.conf
vm.swappiness = 1
vm.dirty_ratio = 15
vm.dirty_background_ratio = 3
vm.overcommit_memory = 2
vm.overcommit_ratio = 80
net.core.somaxconn = 4096
fs.file-max = 2097152
# Disable THP for databases
# echo never > /sys/kernel/mm/transparent_hugepage/enabled

Troubleshooting

SymptomDiagnostic CommandCommon Fix
High CPU, no obvious processperf top, mpstat -P ALL 2Check for kernel-level issues: softirqs, interrupts
High load avg, low CPU usagevmstat 2 (check b column)I/O bottleneck: tune scheduler, check disk health
System swapping heavilyfree -h, vmstat 2 (check si/so)Reduce vm.swappiness, add RAM, find memory leak
Disk latency spikesiostat -x 2 (check await)Switch I/O scheduler, reduce dirty ratio, add SSD
"Too many open files" errorcat /proc/sys/fs/file-nrIncrease fs.file-max and LimitNOFILE
Network throughput lowiperf3 -c <server>, ethtoolIncrease buffer sizes, enable BBR, check MTU
Application timeout under loadss -s, sysctl net.core.somaxconnIncrease somaxconn and tcp_max_syn_backlog
Inconsistent latencyCheck CPU governorSet governor to performance, disable turbo boost

Related Skills

  • linux-administration -- General system monitoring and management
  • systemd-services -- Resource limits via cgroups in unit files
  • block-storage -- Storage-level performance (LVM, RAID, filesystems)
  • nfs-storage -- NFS-specific performance tuning

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.63%
按下载量换算138

Claude

31.14%
按下载量换算121

Cursor

19.09%
按下载量换算74

Gemini CLI

10.67%
按下载量换算41

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

可写文件

该 Skill 可能写入或修改本地文件,使用前需要确认目标目录和修改范围。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills