[20190419]shared latch spin count 2.txt
[20190419]shared latch spin count 2.txt
--//上午測試shared latch XX模式的情況,連結:http://blog.itpub.net/267265/viewspace-2641902/
--//繼續測試其它情況.
--//連結:
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
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.測試1:
--//選擇一個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
2.測試一些細節不再列出,參考連結:http://blog.itpub.net/267265/viewspace-2641902/
--//測試XS模式的情況:
--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 x 100000
--//session 2:
SYS@book> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
1 11 31454 DEDICATED 31455 24 5 alter system kill session '1,11' immediate;
--//記下spid=31455.
SYS@book> @shared_latch.txt "test shared non-parent l0" 1 3 4 s 1
--//注意session 申請S mode.
--//window 3:執行:
$ rlwrap gdb -p 31455 -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.
...
kslgetl 6010d860, 1, 2126093176, 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
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:60009a18, willing:1, where:3, why:4, mode:8
kslgess 60009a18, 8, 0, 3
kslskgs 60009a18, 0, 1129096976, 1129097520
kslskgs 60009a18, 0, 1129096976, 1129097520
---Type <return> to continue, or q <return> to quit---
skgpwwait 1129096760, 202182304, -2044672536, 0
sskgpwwait 1129096760, 202182304, -2044672536, 0
semop 315588608, 1129096560, 1, -1
--//按ctrl+c出現如下:
kslskgs 60009a18, 0, 1129096976, 1129097520
--//可以看出X模式的情況,申請S mode,第2程式直接呼叫semop.根本不做spin操作.
3.測試2:
--//測試SX模式的情況:
--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 s 100000
--//session 持有S mode.
--//session 2:
SYS@book> @shared_latch.txt "test shared non-parent l0" 1 3 4 x 1
--//注意session 申請x mode.
--//window 3:執行:
$ rlwrap gdb -p 31455 -x spin_s.gdb
..
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:60009a18, willing:1, where:3, why:4, mode:16
kslgess 60009a18, 16, 0, 3
kslskgs 60009a18, 0, 1129096976, 1129097520
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
spin count loop: 1997 a875be
...
spin count loop: 3 a875be
spin count loop: 2 a875be
spin count loop: 1 a875be
kslskgs 60009a18, 0, 1129096976, 1129097520
spin count loop: 1 a875be
skgpwwait 1129096760, 202182304, -2044672536, 0
sskgpwwait 1129096760, 202182304, -2044672536, 0
semop 315588608, 1129096560, 1, -1
--//按ctrl+c後.
kslskgs 60009a18, 0, 1129096976, 1129097520
spin count loop: 2000 a875be
--//可以S模式的情況,申請X mode,第2程式spin_count=2000.
4.測試3:
--//Blocking mode,首先我對這個模式的理解不是非常清晰.
--//我的理解
A.當前X mode持有,不管S,X模式申請都會阻塞,再有程式申請的情況.
B.當前S mode持有,X模式申請,後續再有程式申請的情況.
--//也就是這個情況至少3個會話,我分別測試看看
--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 s 100000
--//session 2:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 3 4 x 1
--//session 3:
--//spid=31572
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 5 6 s 1
--//gdb監測session 3程式:
$ rlwrap gdb -p 31572 -x spin_s.gdb
...
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:95, mode:8
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:8
kslgess 60009a18, 8, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
kslskgs 60009a18, 0, -1923148048, -1923147504
skgpwwait -1923148264, 202182304, -2044655416, 0
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504
--//申請S mode,沒有spin.
--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 s 100000
--//session 2:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 3 4 x 1
--//session 3:
--//spid=31572
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 5 6 x 1
--//gdb監測session 3程式:
$ rlwrap gdb -p 31572 -x spin_s.gdb
...
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:16
kslgess 60009a18, 16, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
spin count loop: 2000 a875be
spin count loop: 1999 a875be
spin count loop: 1998 a875be
spin count loop: 1997 a875be
...
spin count loop: 1 a875be
kslskgs 60009a18, 0, -1923148048, -1923147504
spin count loop: 1 a875be
skgpwwait -1923148264, 202182304, -2044655416, 0
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504
spin count loop: 2000 a875be
--//申請X mode,spin_count=2000.
--//XSS的情況:
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:8
kslgess 60009a18, 8, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
kslskgs 60009a18, 0, -1923148048, -1923147504
skgpwwait -1923148264, 202182304, -2044655416, 0
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504
--//XSX的情況:
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:16
kslgess 60009a18, 16, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
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
...
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504
spin count loop: 2000 a875be
--//總之:阻塞申請X mode,spin_count=2000.S mode 直接呼叫semop休眠.
5.總結
--//畫一個表格:
S mode get X mode get
Held in S mode Compatible _spin_count
Held in X mode 0 _spin_count
Blocking mode 0 _spin_count
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2641911/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20190419]shared latch spin count.txt
- [20210218]shared latch spin count 6.txt
- [20210218]shared latch spin count 5.txt
- [20190418]exclusive latch spin count.txt
- [20190416]完善shared latch測試指令碼2.txt指令碼
- [20220412]shared pool latch與使用sga heap的疑問2.txt
- Latch的spin及sleep(zt)
- [20190417]隱含引數_SPIN_COUNT.txt
- [20210512]shared pool latch與library cache latch的簡單探究.txt
- [20190319]shared pool latch與library cache latch的簡單探究.txt
- [20190401]隱含引數_mutex_spin_count.txtMutex
- [20210413]CBC latch再討論2.txt
- [20210708]使用那個shared pool latch.txt
- [20190415]關於shared latch(共享栓鎖).txt
- [20210803]使用那個shared pool latch(補充).txt
- [20190416]檢視shared latch gets的變化.txt
- [20210208][20200426]檢視shared latch gets的變化.txt
- [20210209]修改CPU_COUNT引數2.txt
- [20220406]使用那個shared pool latch的疑問1.txt
- [20220413]shared pool latch與使用sga heap的疑問3.txt
- 透過案例學調優之--和 SHARED POOL 相關的主要 Latch
- [20200213]使用DBMS_SHARED_POOL.MARKHOT標識熱物件2.txt物件
- [20200211]使用DBMS_SHARED_POOL.MARKHOT與sql語句2.txtSQL
- [20210520]11g shared pool latch與library cache mutex的簡單探究.txtMutex
- [20200212]使用DBMS_SHARED_POOL.MARKHOT與sql的計算2.txtSQL
- [20210521]11g shared pool latch與library cache mutex的簡單探究4.txtMutex
- [20210520]11g shared pool latch與library cache mutex的簡單探究3.txtMutex
- MySQL的COUNT語句--count(*)、 count(常量)、 count(列名)MySql
- 【轉】spin lock 和mutexMutex
- count(*)、count(1)和count(列名)的區別
- count (*) 和 count (1) 和 count (列名) 區別
- count(*) 和 count(1)和count(列名)區別
- [20190419]bash單雙引號問題.txt
- mutex,latch,lock,enqueue hash chains latch基礎概念MutexENQAI
- 圖解MySQL:count(*) 、count(1) 、count(主鍵欄位)、count(欄位)哪個效能最好?圖解MySql
- MFC NumericUpDown Spin控制元件 CSpinButtonCtrl控制元件
- [20180727]再論count(*)和count(1).txt
- hiccup和Latch off