Can I taskset a process inside container/docker? How can I tell which cpu cores are assigned to this container?
I want to taskset a process to some specific cpu cores to get better performance.
I got a simple solution that just works.
# shell function which gets the last `taskset`able cpu core findLastUsableCore() { count=`grep -c ^processor /proc/cpuinfo` count=$((count - 1)) while [ "${count}" -ge "0" ] ; do taskset -c ${count} echo >/dev/null 2>&1 if [ "$?" -eq "0" ];then return ${count} fi count=$((count - 1)) done return 0 }
I got a simple solution that just works.