[20190419]shared latch spin count.txt
[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 default_value session_value system_value
----------------- ---------------------------------- ------------- ------------- ------------
_mutex_spin_count mutex spin count true 255 255
_spin_count amount to spin waiting for a latch true 2000 2000
$ cat shared_latch.txt
/* 参数如下: @ latch.txt latch_name willing why where mode sleep_num */
--//connect / as sysdba
col laddr new_value laddr
col vmode new_value vmode
select decode(lower('&&5'),'s',8,'x',16,'8',8,'16',16) vmode from dual ;
select addr laddr from v$latch_parent where name='&&1';
oradebug setmypid
oradebug call kslgetsl_w 0x&laddr &&2 &&3 &&4 &vmode
host sleep &&6
oradebug call kslfre 0x&laddr
--//exit
--//注:我前几天的测试脚本有connect / as sysdba,exit这两行,我为了调式方便,先注解这2行,避免反复退出进入会话.
2.测试:
--//选择一个shared latch测试,我选择"test shared non-parent l0" latch测试:
sys@book> select * from shared_latches where name='test shared non-parent l0';
version latch# name s
---------- ------ ------------------------- -
11.2.0.4.0 6 test shared non-parent l0 y
--//首先测试 xx 情况.
--//session 1:
sys@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 x 100000
vmode
----------
16
laddr
----------------
0000000060009a18
statement processed.
function returned 1
--//后面的参数是sleep的秒数,数值大一些,避免跟踪时退出.想继续按ctrl+c就可以中断sleep.
--//session 2:
sys@book> @ spid
sid serial# process server spid pid p_serial# c50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
44 23 30318 dedicated 30319 27 10 alter system kill session '44,23' immediate;
--//记下spid=30319.在打开一个终端窗口执行如下:
--//暂且称为window 3:
$ rlwrap gdb -p 30319
--//session 2:
sys@book> @ shared_latch.txt "test shared non-parent l0" 1 3 4 x 1
--//挂起!!
--//windows 3:
(gdb) c
continuing.
--//session 2:
sys@book> @shared_latch.txt "test shared non-parent l0" 1 3 4 x 1
vmode
----------
16
laddr
----------------
0000000060009a18
statement processed.
--//回到window 3,按ctrl+c中断:
(gdb) c
continuing.
^c
program received signal sigint, interrupt.
0x00000037990d6407 in semop () from /lib64/libc.so.6
(gdb) bt 8
#0 0x00000037990d6407 in semop () from /lib64/libc.so.6
#1 0x0000000009809c0f in sskgpwwait ()
#2 0x00000000098089ce in skgpwwait ()
#3 0x0000000000a86d3f in kslgess ()
#4 0x00000000093faca5 in ksl_get_shared_latch ()
#5 0x0000000004a2c53e in kslgetsl_w ()
#6 0x0000000007d74142 in skdxcall ()
#7 0x00000000076c96aa in ksdxcall ()
(more stack frames follow...)
--//可以确定函数调用的堆栈或者称为顺序,当前停在semop睡眠上,可以发现调用kslgetsl_w后,ksl_get_shared_latch,
--//紧接着的是kslgess.这样猜测spin计数在调用kslgess或者ksl_get_shared_latch函数里面.
2.重复前面测试,在gdb下设置断点:
--//在session 1按ctrl+c,退出window 3的gdb程序,重新执行gdb.
--//window 3:
$ rlwrap gdb -p 30319
(gdb) break kslgess
breakpoint 1 at 0xa865ca
--//设置断点在kslgess函数调用上.然后在session 1,2分别执行(后面不再说明):
--//再次挂起!在window 3,执行如下:
--//如果我执行ni 1000应该不会错过什么,可以这时看寄存器应该猜测spin count在那个寄存器中.
--//跟踪半天不对,看了链接https://fritshoogland.wordpress.com/2015/07/17/oracle-12-and-latches-part-2/
--//应该在kslskgs函数中.
(gdb) break kslskgs
breakpoint 1 at 0xa874fa
(gdb) c
continuing.
breakpoint 1, 0x0000000000a874fa in kslskgs ()
(gdb) ni 100
..
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875e3 0xa875e3 <kslskgs+237>
(gdb) ni
0x0000000000a875be in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875be 0xa875be <kslskgs+200>
(gdb) ni
0x0000000000a875c8 in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875c8 0xa875c8 <kslskgs+210>
(gdb) ni
0x0000000000a875cb in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875cb 0xa875cb <kslskgs+213>
(gdb) ni
0x0000000000a875d1 in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875d1 0xa875d1 <kslskgs+219>
(gdb) ni
0x0000000000a875d4 in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875d4 0xa875d4 <kslskgs+222>
(gdb) ni
0x0000000000a875da in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875da 0xa875da <kslskgs+228>
(gdb) ni
0x0000000000a875dd in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875dd 0xa875dd <kslskgs+231>
(gdb) ni
0x0000000000a875df in kslskgs ()
(gdb) info regi r13 rip
r13 0x764 1892
rip 0xa875df 0xa875df <kslskgs+233>
(gdb) ni
0x0000000000a875e3 in kslskgs ()
(gdb) info regi r13 rip
r13 0x763 1891
rip 0xa875e3 0xa875e3 <kslskgs+237>
--//可以确定循环开头在0xa875be地址.也是9条指令.
(gdb) disassemble kslskgs
--//反汇编看看.
...
0x0000000000a875be <kslskgs+200>: mov $0x4000000000000000,%rsi
0x0000000000a875c8 <kslskgs+210>: cmp %rsi,%rbx
0x0000000000a875cb <kslskgs+213>: je 0xa876db <kslskgs+485>
0x0000000000a875d1 <kslskgs+219>: test %rbx,%rbx
0x0000000000a875d4 <kslskgs+222>: je 0xa876db <kslskgs+485>
0x0000000000a875da <kslskgs+228>: mov (%r14),%rbx
0x0000000000a875dd <kslskgs+231>: pause
0x0000000000a875df <kslskgs+233>: add $0xffffffffffffffff,%r13d
0x0000000000a875e3 <kslskgs+237>: jne 0xa875be <kslskgs+200>
3.重复前面测试,先写出gdb脚本:
$ cat spin_s.gdb
break kslgetl
commands
silent
printf "kslgetl %x, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
end
break kslges
commands
silent
printf "kslges %x, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
end
break skgpwwait
commands
silent
printf "skgpwwait %d, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
end
break sskgpwwait
commands
silent
printf "sskgpwwait %d, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
end
break semop
commands
silent
printf "semop %d, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
end
break *0x93f9ddc
commands
silent
printf " spin count loop: %d %d %x\n", $rax,$rcx,$rip
c
end
##今天加入的内容
break ksl_get_shared_latch
commands
silent
printf "ksl_get_shared_latch laddr:%x, willing:%d, where:%d, why:%d, mode:%d\n", $rdi, $rsi, $rdx, $rcx, $r8
c
end
break kslgess
commands
silent
printf "kslgess %x, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
end
break kslskgs
commands
silent
printf "kslskgs %x, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
end
break *0xa875be
commands
silent
printf " spin count loop: %d %x\n", $r13,$rip
c
end
--//重复测试:
--//window 3:
$ rlwrap gdb -p 30319 -x spin_s.gdb
...
breakpoint 1 at 0x93f97a8
breakpoint 2 at 0x93f9b74
breakpoint 3 at 0x9808932
breakpoint 4 at 0x9809840
breakpoint 5 at 0x37990d6400
breakpoint 6 at 0x93f9ddc
breakpoint 7 at 0x93faa36
breakpoint 8 at 0xa865ca
breakpoint 9 at 0xa874fa
breakpoint 10 at 0xa875be
(gdb) c
continuing.
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:95, mode:8
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:96, mode:16
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:95, mode:8
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:96, mode:16
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:95, mode:8
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:96, mode:16
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:95, mode:8
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:96, mode:16
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:95, mode:8
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:96, mode:16
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:95, mode:8
ksl_get_shared_latch laddr:85f800a8, willing:1, where:-2043089904, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:3, why:4, mode:16
kslgess 60009a18, 16, 0, 3
kslskgs 60009a18, 0, 491913760, 491914304
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
spin count loop: 1997 a875be
spin count loop: 1996 a875be
spin count loop: 1995 a875be
spin count loop: 1994 a875be
...
.....
--//不断按return继续...
spin count loop: 6 a875be
spin count loop: 5 a875be
spin count loop: 4 a875be
spin count loop: 3 a875be
spin count loop: 2 a875be
spin count loop: 1 a875be
kslskgs 60009a18, 0, 491913760, 491914304
spin count loop: 1 a875be
--//这里有有1次奇怪!!
skgpwwait 491913544, 202182304, -2044659696, 0
sskgpwwait 491913544, 202182304, -2044659696, 0
semop 315195392, 491913344, 1, -1
--//session 1:
--//按ctrl+c中断.
sys@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 x 100000
vmode
----------
16
laddr
----------------
0000000060009a18
statement processed.
function returned 1
function returned 0
--//session 2等1秒也执行完成.
sys@book> @shared_latch.txt "test shared non-parent l0" 1 3 4 x 1
vmode
----------
16
laddr
----------------
0000000060009a18
statement processed.
function returned 1
function returned 0
--//window 3界面显示如下:
semop 315195392, 491913344, 1, -1
kslskgs 60009a18, 0, 491913760, 491914304
spin count loop: 2000 a875be
(gdb) info br 9
num type disp enb address what
9 breakpoint keep y 0x0000000000a874fa <kslskgs+4>
breakpoint already hit 3 times
silent
printf "kslskgs %x, %d, %d, %d\n", $rdi, $rsi, $rdx, $rcx
c
(gdb) info br 10
num type disp enb address what
10 breakpoint keep y 0x0000000000a875be <kslskgs+200>
breakpoint already hit 2002 times
silent
printf " spin count loop: %d %x\n", $r13,$rip
c
--//spin count=2002次.再次重复结果一样.也就是我的测试结果与https://fritshoogland.wordpress.com/2015/07/17/oracle-12-and-latches-part-2/
--//的测试基本一致.
4.换一种方式测试:
--//定制spin次数如下:
*._spin_count=20
sys@book> startup pfile=/tmp/@.ora
oracle instance started.
total system global area 643084288 bytes
fixed size 2255872 bytes
variable size 205521920 bytes
database buffers 427819008 bytes
redo buffers 7487488 bytes
database mounted.
database opened.
sys@book> select * from x$ksllclass ;
addr indx inst_id spin yield waittime sleep0 sleep1 sleep2 sleep3 sleep4 sleep5 sleep6 sleep7
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00000000861986c0 0 1 20 0 1 8000 8000 8000 8000 8000 8000 8000 8000
00000000861986ec 1 1 20 0 1 1000 1000 1000 1000 1000 1000 1000 1000
0000000086198718 2 1 20 0 1 8000 8000 8000 8000 8000 8000 8000 8000
0000000086198744 3 1 20 0 1 1000 1000 1000 1000 1000 1000 1000 1000
0000000086198770 4 1 20 0 1 8000 8000 8000 8000 8000 8000 8000 8000
000000008619879c 5 1 20 0 1 8000 8000 8000 8000 8000 8000 8000 8000
00000000861987c8 6 1 20 0 1 8000 8000 8000 8000 8000 8000 8000 8000
00000000861987f4 7 1 20 0 1 8000 8000 8000 8000 8000 8000 8000 8000
8 rows selected.
--//重复测试,细节不再列出,仅仅记录gdb输出.
(gdb) c
continuing.
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:95, mode:8
kslgetl 6010d860, 1, 2082043896, 3991
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:96, mode:16
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:95, mode:8
kslgetl 6010d860, 1, 0, 4039
kslgetl 6010d860, 1, 0, 3980
kslgetl 6010d860, 1, 0, 4039
kslgetl 6010d860, 1, 2081938320, 3991
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:96, mode:16
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:95, mode:8
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:96, mode:16
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:95, mode:8
kslgetl 6010d860, 1, 2081947264, 3991
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:96, mode:16
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:95, mode:8
kslgetl 6010d860, 1, 2081910208, 3991
kslgetl 6010d860, 1, 0, 4039
kslgetl 6010d860, 1, 0, 3980
kslgetl 6010d860, 1, 0, 4039
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:96, mode:16
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:95, mode:8
kslgetl 6010d860, 1, 2081915088, 3991
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:96, mode:16
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:95, mode:8
kslgetl 6010d860, 1, 2081924032, 3991
ksl_get_shared_latch laddr:85f7f7e8, willing:1, where:-2043265072, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:3, why:4, mode:16
kslgess 60009a18, 16, 0, 3
kslskgs 60009a18, 0, 1333839872, 1333840416
spin count loop: 20 a875be
spin count loop: 19 a875be
spin count loop: 18 a875be
spin count loop: 17 a875be
spin count loop: 16 a875be
spin count loop: 15 a875be
spin count loop: 14 a875be
spin count loop: 13 a875be
spin count loop: 12 a875be
spin count loop: 11 a875be
spin count loop: 10 a875be
spin count loop: 9 a875be
spin count loop: 8 a875be
spin count loop: 7 a875be
spin count loop: 6 a875be
spin count loop: 5 a875be
spin count loop: 4 a875be
spin count loop: 3 a875be
spin count loop: 2 a875be
spin count loop: 1 a875be
kslskgs 60009a18, 0, 1333839872, 1333840416
spin count loop: 1 a875be
skgpwwait 1333839656, 202182304, -2044663976, 0
sskgpwwait 1333839656, 202182304, -2044663976, 0
semop 315326464, 1333839456, 1, -1
kslskgs 60009a18, 0, 1333839872, 1333840416
spin count loop: 20 a875be
(gdb) info br 10
num type disp enb address what
10 breakpoint keep y 0x0000000000a875be <kslskgs+200>
breakpoint already hit 22 times
silent
printf " spin count loop: %d %x\n", $r13,$rip
c
--//22次spin count.
5.继续定制spin次数,采用不同类看看:
sys@book> select addr,name,level#,latch#,gets,misses,sleeps,immediate_gets,immediate_misses,waiters_woken,waits_holding_latch,spin_gets,wait_time from v$latch_parent where lower(name) ='test shared non-parent l0';
addr name level# latch# gets misses sleeps immediate_gets immediate_misses waiters_woken waits_holding_latch spin_gets wait_time
---------------- ---------------------------------------- ---------- ---------- ---------- ---------- ---------- -------------- ---------------- ------------- ------------------- ---------- ----------
0000000060009a18 test shared non-parent l0 0 6 4 2 2 0 0 0 0 0 23731310
--//latch#=6
--//定制spin次数如下,修改参数文件加入:
#*._spin_count=20
*._latch_classes='6:3'
*._latch_class_3='10 0 1 10000 20000 30000 40000 50000 60000 70000 50000'
sys@book> startup pfile=/tmp/@.ora
oracle instance started.
total system global area 643084288 bytes
fixed size 2255872 bytes
variable size 205521920 bytes
database buffers 427819008 bytes
redo buffers 7487488 bytes
database mounted.
database opened.
sys@book> select * from x$ksllclass ;
addr indx inst_id spin yield waittime sleep0 sleep1 sleep2 sleep3 sleep4 sleep5 sleep6 sleep7
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00000000861986c0 0 1 20000 0 1 8000 8000 8000 8000 8000 8000 8000 8000
00000000861986ec 1 1 20000 0 1 1000 1000 1000 1000 1000 1000 1000 1000
0000000086198718 2 1 20000 0 1 8000 8000 8000 8000 8000 8000 8000 8000
0000000086198744 3 1 10 0 1 10000 20000 30000 40000 50000 60000 70000 50000
0000000086198770 4 1 20000 0 1 8000 8000 8000 8000 8000 8000 8000 8000
000000008619879c 5 1 20000 0 1 8000 8000 8000 8000 8000 8000 8000 8000
00000000861987c8 6 1 20000 0 1 8000 8000 8000 8000 8000 8000 8000 8000
00000000861987f4 7 1 20000 0 1 8000 8000 8000 8000 8000 8000 8000 8000
8 rows selected.
sys@book> select class_ksllt,decode(class_ksllt,2,kslltnam,3,kslltnam) name,count(*) from x$kslltr group by class_ksllt,decode(class_ksllt,2,kslltnam,3,kslltnam);
class_ksllt name count(*)
----------- ------------------------- --------
0 580
2 process allocation 1
3 test shared non-parent l0 1
--//重复测试,细节不再列出,仅仅记录gdb输出.
continuing. [0/22415]
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
kslgetl 6010d860, 1, 2085717616, 3991
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
kslgetl 6010d860, 1, 0, 4039
kslgetl 6010d860, 1, 0, 3980
kslgetl 6010d860, 1, 0, 4039
kslgetl 6010d860, 1, 2085673168, 3991
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
kslgetl 6010d860, 1, 2085682112, 3991
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
kslgetl 6010d860, 1, 2085645056, 3991
kslgetl 6010d860, 1, 0, 4039
kslgetl 6010d860, 1, 0, 3980
kslgetl 6010d860, 1, 0, 4039
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
kslgetl 6010d860, 1, 2085649936, 3991
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
kslgetl 6010d860, 1, 2085658880, 3991
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:3, why:4, mode:16
kslgess 60009a18, 16, 0, 3
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
..
spin count loop: 3 a875be
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 10000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
..
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 20000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
...
spin count loop: 3 a875be
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 30000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
spin count loop: 1997 a875be
...
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 40000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
..
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 50000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
...
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 60000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
..
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 70000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 70000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 70000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
...
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 50000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
...
spin count loop: 2 a875be
spin count loop: 1 a875be
skgpwwait -331400584, 202182304, 0, 50000
kslskgs 60009a18, 0, -331400368, -331399824
spin count loop: 2000 a875be
spin count loop: 1999 a875be
...
spin count loop: 1963 a875be
spin count loop: 1962 a875be
spin count loop: 1961 a875be
---type <return> to continue, or q <return> to quit---q
quit
--//注意看skgpwwait最后参数,实际上就是sleep的时间,单位微秒.spin count不是10,而是2000.
(gdb) info br 10
num type disp enb address what
10 breakpoint keep y 0x0000000000a875be <kslskgs+200>
breakpoint already hit 18041 times
silent
printf " spin count loop: %d %x\n", $r13,$rip
c
--//使用跟踪可以发现如下:
$ strace -fttt -p 31247
process 31247 attached - interrupt to quit
11:06:41.497253 select(0, [], [], [], {0, 40191}) = 0 (timeout) <0.040333>
11:06:41.537915 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050145>
11:06:41.588209 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050140>
11:06:41.638518 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050108>
11:06:41.688774 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050146>
11:06:41.739070 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050147>
11:06:41.789366 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050110>
11:06:41.839640 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050141>
11:06:41.889947 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050143>
11:06:41.940240 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050121>
11:06:41.990509 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050153>
11:06:42.040831 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050145>
11:06:42.091124 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050151>
11:06:42.141462 select(0, [], [], [], {0, 50000}) = 0 (timeout) <0.050161>
...
总结:
1.不要在生产系统做这样测试.
2.shared latch 持有x 模式,申请 x 模式阻塞,spin_count=_spin_count.与exclusive latch不同.
3.对于修改latch类的参数仅仅sleepn参数有效.
4.其它模式比如sx,xs.另外写一篇blog测试.我看了连接,我还忘记考虑blocking mode下的情况.
--//链接:http://andreynikolaev.wordpress.com/2011/01/14/spin-tales-part-2-shared-latches-in-oracle-9-2-11g/
s mode get x mode get
held in s mode compatible 2*_spin_count
held in x mode 0 2*_spin_count
blocking mode 0 2*_spin_count
--//注我的测试仅仅_spin_count.而不是2倍.