[20190419]shared latch spin count.txt
--//昨天测试exclusive latch spin count = 20000(缺省).
--//今天测试shared latch spin count的情况,看了一些文章测试等于2 *_spin_count.
--//有了昨天的测试经验,今天测试应该相对容易一些,不过shared latch有两种模式:
For the shared latches Oracle 10g uses kslgetsl(laddr, wait, why, where, mode) function. Oracle 11g has kslgetsl_w()
function with the same interface, but internally uses ksl_get_shared_latch(). Like in my previous post, I guess the
meaning of kslgetsl() arguments as:
--//对于共享锁存,Oracle 10g使用kslgetsl(laddr,wait,why,where,mode)函数。Oracle 11g具有相同接口的kslgetsl_w()函数,但
--//在内部使用ksl_get_share_latch()。与上一篇文章一样,我认为kslgetsl()参数的含义是:
--//注:我以前一直以为还是kslgetsl,原来11g已经改为kslgetsl_w,不过内部使用还是ksl_get_shared_latch().
laddress -- address of latch in SGA
wait -- flag. If not 0, then willing-to-wait latch get
why -- context why the latch is acquired at this where.
where -- location from where the latch is acquired (x$ksllw.indx)
And the last one is:
mode – Exclusive or shared mode
the mode argument took only two values:
8 -- "SHARED"
16 -- "EXCLUSIVE"
--//当时自己的总结:
--//A. S mode 下: peek记录的前4位持有S mode的数量.后4位是0x0. (这里针对的64位的系统)
--//B. S mode 下,如果出现X mode,peek记录的前4位持有S mode的数量.后4位是0x40000000.
--// 一旦X mode持有,前4位持有会话PID号,后4位0x20000000.
--//C. X mode 持有,会导致顺序的S mode 串行化.从调优角度讲这是最"可怕"的事情.
--//D. 从以上测试可以看出 shared latch优化的重点就是减少X mode出现的频次.
--//也就是测试要至少测试三种SX,XX,XS情况.是否这些情况下spin count是否一样.
--//链接 :http://andreynikolaev.wordpress.com/2011/01/14/spin-tales-part-2-shared-latches-in-oracle-9-2-11g/
sqlplus /nolog @latch_spin_trace.sql 102
...
LATCH_FUNC ADDR LNAME
---------- --------- --------------------------------------------------
kslgetsl 50009BAC gcs_partitioned_table_hash
...
pid: 7270
kslgetsl - KSL GET Shared Latch
kslgess - wait latch get
kslskgs - shared latch spin get
sskgslspin - spinning function
sskgslspin
sskgslspin
sskgslspin
sskgslspin
...
--//说明一下:作者测试环境10g,10g shared latch调用函数是kslgetsl,11g shared latch调用函数是kslgetsl_w.
--//latch spin 使用sskgslspin函数调用,可是linux下使用intel cpu并没有对应的oracle内部函数.
(gdb) b sskgslspin
Function "sskgslspin" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 3 (sskgslspin) pending.
1.环境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SYS@book> @ hide spin_count
NAME DESCRIPTION &nb