[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倍.
 


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com