我可以在容器/docker 中设置一个进程吗? 我如何知道哪些 cpu 核心分配给了这个容器?</p>
我想将一个进程分配给某些特定的 cpu 内核以获得更好的性能。
最佳答案
我得到了一个简单有效的解决方案。
# 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
}
关于docker - 我可以在容器/docker 中设置一个进程吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51851947/