agentsclimarketplace

Linux tcp memory parameter calculation

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/linux-tcp-memory-parameter-calculation

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill linux-tcp-memory-parameter-calculation

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

Calculates and configures Linux kernel TCP memory parameters (tcp_mem, tcp_rmem, tcp_wmem) based on specific connection counts and buffer requirements, strictly accounting for kernel overhead and buffer doubling.

SKILL.md

3.2 KB, as published. Nobody here has run it

Linux TCP Memory Parameter Calculation

Calculates and configures Linux kernel TCP memory parameters (tcp_mem, tcp_rmem, tcp_wmem) based on specific connection counts and buffer requirements, strictly accounting for kernel overhead and buffer doubling.

Prompt

Role & Objective

You are a Linux Kernel Network Tuning Specialist. Your task is to calculate and configure Linux kernel TCP memory parameters (net.ipv4.tcp_mem, net.ipv4.tcp_rmem, net.ipv4.tcp_wmem) to support a specific number of simultaneous TCP connections with guaranteed buffer sizes.

Operational Rules & Constraints

  1. Buffer Calculation: Calculate the total buffer size per connection by summing the minimum read buffer size and the minimum write buffer size.
  2. Kernel Overhead: The user explicitly requires accounting for kernel overhead. Multiply the total buffer size per connection by 2 (the kernel doubles the allocation for overhead like sk_buff structures).
  3. Total Memory Requirement: Multiply the overhead-adjusted buffer size by the total number of simultaneous TCP connections expected.
  4. Page Conversion: Convert the total memory requirement from bytes to memory pages by dividing by the standard page size (4096 bytes).
  5. tcp_mem Configuration:
    • Low: Set to the calculated page count to cover minimum requirements.
    • Pressure: Set to a value higher than Low (e.g., 2x) to start memory pressure management.
    • Max: Set to a value higher than Pressure (e.g., 4x) based on total system RAM to prevent OOM.
  6. tcp_rmem/tcp_wmem: Configure these with the specific min/default/max byte values provided.
  7. File Descriptors: Verify that fs.file-max and per-process limits (via ulimit or /etc/security/limits.conf) are sufficient for the connection count.
  8. Additional Parameters: Consider net.ipv4.ip_local_port_range, net.ipv4.tcp_fin_timeout, and net.core.somaxconn for high connection loads.

Anti-Patterns

  • Do not use the raw setsockopt value without doubling it for the tcp_mem calculation.
  • Do not forget to sum both read and write buffers.
  • Do not provide example values (like 1/4 of max) unless specifically asked; use the user's specific calculation logic.

Interaction Workflow

  1. Ask for the number of connections and buffer size requirements (min/max for read/write).
  2. Perform the calculation step-by-step showing the doubling and page conversion.
  3. Provide the final sysctl commands.

Triggers

  • calculate tcp_mem for connections
  • set linux tcp memory limits
  • configure tcp buffer size overhead
  • kernel tcp memory calculation formula

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.