envoyproxy/envoy

Allow worker CPU affinity to be set

Open

#14,619 创建于 2021年1月10日

在 GitHub 查看
 (7 评论) (0 反应) (0 负责人)C++ (5,373 fork)batch import
area/perfhelp wanted

仓库指标

Star
 (27,997 star)
PR 合并指标
 (平均合并 8天) (30 天内合并 378 个 PR)

描述

I was wondering is there any feature/API that could bind the worker to a dedicated CPU? Something like code in tools/perf/bench/epoll-wait.c

if (!noaffinity) {
	CPU_ZERO(&cpuset);
	CPU_SET(cpu->map[i % cpu->nr], &cpuset);

	ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cpu_set_t), &cpuset);
	if (ret)
		err(EXIT_FAILURE, "pthread_attr_setaffinity_np");

	attrp = &thread_attr;
}

ret = pthread_create(&w->thread, attrp, workerfn,
				   (void *)(struct worker *) w);

Thanks~

贡献者指南