[20190419]shared latch spin count.txt

来源:https://www.cnblogs.com/lfree/archive/2019/04/19/10734803.html
-Advertisement-
Play Games

[20190419]shared latch spin count.txt--//昨天測試exclusive latch spin count = 20000(預設).--//今天測試shared latch spin count的情況,看了一些文章測試等於2 *_spin_count.--//有了 ...


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


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 背景 從mysql.slow_log 獲取慢查詢日誌很慢,該表是csv表,沒有索引。 想添加索引來加速訪問,而csv引擎不能添加索引(csv引擎存儲是以逗號分割的文本來存儲的),只能改存儲引擎來添加索引了 MySQL 中日誌表slow_log和general_log主要特點 日誌表只能是CSV和MY ...
  • DMLinsert關鍵字作用:往表中插入一條(多條)數據語法1:元祖值式的插入語法1: insert into tablename(column1,column2,...,columnN) values(value1,value2,...,valueN); insert into 表名 (列1 ,列 ...
  • 前言 關於索引,這是一個非常重要的知識點,同樣,在面試的時候也會被經常的問到; 本文描述了索引的結構,介紹了InnoDB的索引方案等知識點,感興趣的可以看一下; 引入 本文參考文章:MySQL的索引 回顧 在上篇文章中我們說到 InnoDB的數據頁結構 ,瞭解到了 數據頁的 7 個組成部分,知道了各 ...
  • 存儲過程的建立和調用 --1.1準備測試需要的資料庫:test,數據表:物料表,採購表if not exists (select * from master.dbo.sysdatabases where name='test')create database testgouse testgoif o ...
  • .1事務 redis中事務是一組命令的集合。 事務同命令一樣都是redis的最小執行單位,Redis保證一個事務中的命令要麼都執行,要麼都不執行。如果redisClient在發送EXEC命令前掉線,則redis會清空事務隊列,事務中的所有命令都不會執行;如果redisClient在發送EXEC命令後 ...
  • 結構化查詢語言SQL在20世紀70年代發展起來之後,很快就成為關係資料庫的標準語言。雖然理解SQL可能很複雜,但幸運的是,有許多書籍可以幫助你快速瞭解SQL。 ...
  • 1.安裝準備: Windows系統環境: 安裝:SQLiteExpert 及 官網的SQLite tool 我們要用到其中的SQLite.exe 地址:https://www.sqlite.org/download.html 2.新建資料庫 打開cmd:鍵入以下命令:D:\sqlite-tools- ...
  • [20190419]shared latch spin count 2.txt--//上午測試shared latch XX模式的情況,鏈接:http://blog.itpub.net/267265/viewspace-2641902/--//繼續測試其它情況.--//鏈接:http://andre ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...