Benchmarking: More Stable Results with CPU Affinity Setting

栏目: IT技术 · 发布时间: 5年前

内容简介:Usually, this approach gives rather stable results; for example, benchmarking MySQL with Sysbench OLTP Read-Only workload I get a variance of less than one percent between 1-minute runs.In this case, though, I was seeing some

Benchmarking: More Stable Results with CPU Affinity Setting When I run a benchmark and want to measure the CPU efficiency of something, I find it’s often a good choice to run a benchmark program, as well as the database, on the same server. This is in order to eliminate network impact and to look at single-thread performance, to eliminate contention.

Usually, this approach gives rather stable results; for example, benchmarking MySQL with Sysbench OLTP Read-Only workload I get a variance of less than one percent between 1-minute runs.

In this case, though, I was seeing some 20 percent difference between the runs, which looked pretty random and would not go away even with longer 10-minute runs.

The benchmark I did was benchmarking MySQL through ProxySQL (all running on the same machine):

Sysbench -> ProxySQL -> MySQL 

As I thought more about possible reasons, I thought CPU scheduling might be a problem. As requests pass from one process to another, does Linux Kernel schedule requests at the same CPU core or a different one? Even though only one process can really be busy processing a request at the same time in this setup, there is the question of CPU cache usage, as well as other implications of scheduling work on the single CPU core or a different one.

To validate my assumptions, I used taskset , a little utility available in modern Linux distributions, which allows the mapping of a set process CPU affinity, essentially mapping it to some of the CPU cores.

I set MySQL and ProxySQL to be limited to different CPU cores:

taskset -pc 0 `pidof mysqld`
taskset -pc 1  8601     #pid of ProxySQL main process

And run sysbench bound to the given CPU core too:

taskset -c 2 sysbench  --rand-type=uniform --db-driver=mysql --db-ps-mode=auto  --mysql-socket="/tmp/proxysql.sock"  --mysql-user=sbtest --mysql-password=sbtest --mysql-db=sbtest /usr/share/sysbench/oltp_point_select.lua --table-size=10000000 --threads=1 --time=60 --rate=0 --percentile=99 run

With this change, I’m back to having very stable benchmark results. So if you ever run to a similar problem, see if setting process affinity with taskset helps!


以上所述就是小编给大家介绍的《Benchmarking: More Stable Results with CPU Affinity Setting》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

让创意更有黏性

让创意更有黏性

[美] 奇普·希思、[美] 丹·希思 / 姜奕晖 / 中信出版社 / 2014-1-8 / 49.00元

你或许相信在太空中唯一能看到的人工建筑就是万里长城,可乐能腐蚀人体骨骼,我们的大脑使用了10%;与此同时,你却记不得上周例会上领导的安排,昨天看过的那本书里写了什么,上次参加培训的主要内容…… 为什么? 这就引发出《让创意更有黏性》的核心问题:什么样的观点或创意具有强有力的黏性,能被他人牢牢记住? 国际知名行为心理学家希思兄弟根据大量的社会心理学研究案例,揭示了让创意或观点具有黏......一起来看看 《让创意更有黏性》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具