Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@farrokhi
Created January 19, 2020 11:15
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 farrokhi/fcc0d82789e01822e1f21397f5d5d2aa to your computer and use it in GitHub Desktop.
Save farrokhi/fcc0d82789e01822e1f21397f5d5d2aa to your computer and use it in GitHub Desktop.
Enforce dropping page cache and trigger memory page compactor for Linux MM
#!/bin/sh
set -u
NUMA_BEFORE=`numactl -H | grep free:`
SLAB_BEFORE=`grep Normal /proc/buddyinfo`
printf "Dropping page cache..."
sysctl -qw vm.drop_caches=1
echo
printf "Defragmenting memory pages..."
sysctl -qw vm.compact_memory=1
echo
NUMA_AFTER=`numactl -H | grep free:`
SLAB_AFTER=`grep Normal /proc/buddyinfo`
echo
echo "Free memory per NUMA domain:"
echo "Before: " ${NUMA_BEFORE} | tr -s ' ' '\t'
echo "After: " ${NUMA_AFTER} | tr -s ' ' '\t'
echo
echo "Slab Allocator status:"
echo "Before: " ${SLAB_BEFORE} | tr -s ' ' '\t'
echo "After: " ${SLAB_AFTER} | tr -s ' ' '\t'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment