mysql 自旋锁_mysql 自旋锁

参数是自旋锁的轮转数,可以通过show engine innodb status来查看。相较于系统等待,自旋锁是低成本的等待;不过它是一个活跃的等待,会浪费一些cpu资源。因此如果看到大量的自旋等待和自旋轮转,则很显然它浪费了很多cpu资源。浪费cpu时间和无谓的上下文切换之间可以通过该值来平衡。

innodb_spin_wait_delay

Vadim Tkachenko 在http://www.mysqlperformanceblog.com/2011/12/02/kernel_mutex-problem-or-double-throughput-with-single-variable/中对该参数进行了测试,并给出了结论。

Peter Zaitsev在http://www.mysqlperformanceblog.com/2011/07/28/how-innodb-contention-may-manifest-itself/中也进行了解释在不同状况下,该值的影响。并在http://www.mysqlperformanceblog.com/2006/07/17/show-innodb-status-walk-through/中详细解释了show innodb status的输出进行了详细解释。

innodb_thread_concurrency

关于innodb_thread_concurrency参数

http://dev.mysql.com/doc/refman/5.5/en/innodb-parameters.html#sysvar_innodb_thread_concurrencylinkext7.gif

Command-Line Format--innodb_thread_concurrency=#

Option-File Formatinnodb_thread_concurrency

Option Sets VariableYes, innodb_thread_concurrency

Variable Nameinnodb_thread_concurrency

Variable ScopeGlobal

Dynamic VariableYes

Permitted Values

Typenumeric

Default0

Range0 .. 1000

InnoDB tries to keep the number of operating system threads concurrently inside InnoDB less than or equal to the limit given by this variable. Once the number of threads reaches this limit, additional threads are placed into a wait state within a FIFO queue for execution. Threads waiting for locks are not counted in the number of concurrently executing threads.

The correct value for this variable is dependent on environment and workload. Try a range of different values to determine what value works for your applications. A recommended value is 2 times the number of CPUs plus the number of disks.

The range of this variable is 0 to 1000. A value of 0 (the default) is interpreted as infinite concurrency (no concurrency checking). Disabling thread concurrency checking enables InnoDB to create as many threads as it needs.

参数的含义是: InnoDB内部的并发线程数.

可以动态修改

具体解析: InnoDB 试图保持InnoDB内部的并发操作系统的线程数少于innodb_thread_concurrency设置的值

如果innodb并发线程数快要到达innodb_thread_concurrency=x,其他的innodb线程会被设置为等待状态,队列的算法是FIFO

处于等待拿锁状态的线程数,不会被计算入正在执行的并发线程数

innodb_thread_concurrency=x,x该设怎样的值,视服务器配置和服务器的负载情况。

默认推荐的值是 (cpu的数量+磁盘数量)x2 (我的理解,对于raid10的磁盘阵列,应该是磁盘总数/2)

参数取值范围 0-1000 当为默认值的时候,不是说0个并发线程。 而是被解释为无限并发(没有并发检查)

当innodb_thread_concurrency=0的时候,可以理解为 禁用线程并发检查,使InnoDB按照请求的需求, 创造尽可能多的线程.

http://www.dbathink.com/2012/10/trouble-shooting-the-high-sys-cpu-in-mysql-server/

mysql 自旋锁

标签:

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:http://www.cnblogs.com/yuyue2014/p/4809549.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值