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

 


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2641902/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/267265/viewspace-2641902/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值