我可以在容器/码头工作器中设置进程吗?

问题描述 投票:2回答:1

我可以在容器/码头工作器中设置进程吗?如何判断为此容器分配了哪些cpu内核?

我想为一些特定的cpu内核设置一个进程,以获得更好的性能。

docker taskset
1个回答
2
投票

我得到了一个简单的解决方案。

# 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
}
© www.soinside.com 2019 - 2024. All rights reserved.