Performance & Virtualization

Swap activity causes repeated interactive pauses

Occupied swap is not itself a fault. Correlate swap-in/out rates, memory pressure and working-set demand before changing swappiness or disabling swap.

On this page
  1. Symptoms & scope
  2. Possible causes
  3. Diagnose safely
  4. Evidence-guided next steps
  5. References & review
  6. Related problems

Symptoms & scope

  • Pauses coincide with sustained swap-in and swap-out traffic.
  • Memory pressure persists while the same pages are repeatedly revisited.

Relevant environment

Linux swap accounting, VM policy and procps vmstat; compressed swap has different cost tradeoffs.

Possible causes

These are possible explanations, not a confirmed diagnosis. Several independent faults can coexist.

  • The active working set may not fit accessible RAM, causing repeated page eviction and refaults.
  • Swap device latency, compression CPU cost or a cgroup's swap policy may amplify pressure; occupancy alone does not distinguish these.

Diagnose safely

Run one command at a time in the relevant session. Read the explanation first. Uppercase placeholders need your own values; tools and privileges vary by distribution. These commands are displayed here and never executed by the website.

Check 1

Read-only procps sampling for six reports; the first report summarizes time since boot.

vmstat 1 6

Interpret the result: Use later si/so intervals, not only total swap occupancy. Sustained traffic with latency supports thrashing, while old inactive swapped pages can be harmless.

Check 2

The --show form only lists active swap devices and usage; do not omit it.

swapon --show --bytes

Interpret the result: Compare device type, priority and use with observed rates. A high used value is not proof that this device is busy during the pause.

Check 3

Reads the current swappiness value without assigning one.

sysctl vm.swappiness

Interpret the result: Swappiness expresses relative reclaim cost; it is not a percentage of RAM at which swapping begins.

Evidence-guided next steps

Reduce recurring page demand

If the workload repeatedly exceeds RAM, reduce concurrent jobs, application caches or batch size, or provide capacity appropriate to its working set. Compare later vmstat intervals and PSI under the same load.

Precautions: Turning off occupied swap can force pages back into insufficient RAM and trigger OOM. Save application state before stopping work.

Recovery / rollback: Restore application sizing gradually only within the available budget; retain the previous scheduling plan.

Did this solution help you?

Share this solution#

Tune swap policy for measured cost

If measurements show swap cost differs from filesystem refault cost, trial a documented swappiness adjustment for this host and monitor latency plus OOM events. Evaluate compressed or faster swap as a separate planned configuration change.

Precautions: Keep the old value and change one factor. A lower value is not universally faster, particularly with compressed memory-backed swap.

Recovery / rollback: Restore the recorded swappiness and original swap configuration; do not deactivate busy swap without sufficient memory headroom.

Did this solution help you?

Share this solution#

References & review

This guide was prepared from primary project or distribution sources and reviewed on the date shown. This is an editorial source check, not evidence that a fix was reproduced on your hardware. Diagnostic log examples are synthetic fixtures. Version-dependent details must be checked against your installed release.