Skip to content

Instantly share code, notes, and snippets.

@tobert
Last active August 29, 2015 14:26
Show Gist options
  • Save tobert/97c52f80fdff2ba79ee9 to your computer and use it in GitHub Desktop.
Save tobert/97c52f80fdff2ba79ee9 to your computer and use it in GitHub Desktop.
Pin Apache Cassandra compaction threads to a core
#!/bin/bash
# A quick & dirty script to pin compaction threads to a core without
# any consideration for HT or what kind of compaction any given thread
# is doing.
# atobey@datastax.com 2015-08-02
# match all processes with nice value 4, which is hard-coded in Cassandra
pids=$(ps -eLo nice,tid,args |awk '/^ *4 .*java/{print $2}')
ncores=$(grep ^processor /proc/cpuinfo |wc -l)
offset=1
for pid in $pids
do
core=$(($ncores - $offset))
offset=$(($offset + 1))
if [ $offset -gt $ncores ] ; then
offset=1
fi
taskset -pc $core $pid
ionice --class 3 --pid $pid
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment