[20160118]共享池的LRU链表.txt
共享池中的LRU和buffer cahce中的LRU算法有很大不同。共享池LRU链从总体上分两条:瞬时LRU,周期LRU。一个Chunk第1次被操作后,
会被放入瞬时LRU;如果又1次被用到了,将被移至周期LRU。
这两条LRU链有点像BUffer cache中的冷链和热链。瞬时LRU是冷链,周期LRU是热链。瞬时LRU中保存只被使用一次的chunk,周期LRU中保
存使用次数为2次及2次以上的Chunk。
--以上内容摘自vage的<oracle内核技术揭秘>,自己重复测试看看:
1.环境:
SCOTT@book> @ &r/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> alter system set cpu_count=1 scope=spfile;
System altered.
SYS@book> @ &r/hide _kghdsidx_count
NAME DESCRIPTION DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
---------------- ------------------- ---------------------- ---------------------- ----------------------
_kghdsidx_count max kghdsidx count TRUE 1 1
SYS@book> select * from x$kghlu;
ADDR INDX INST_ID KGHLUIDX KGHLUDUR KGHLUSHRPOOL KGHLUFSH KGHLUOPS KGHLURCR KGHLUTRN KGHLUMXA KGHLUMES KGHLUMER KGHLURCN KGHLURMI KGHLURMZ KGHLURMX KGHLUNFU KGHLUNFS
---------------- ---------- ---------- ---------- ---------- ------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00007FFAAB07B1E8 0 1 1 0 1 0 12928 1802 4088 2147483647 0 0 0 0 0 0 0 0
2.测试:
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
--再执行其他语句。
SYS@book> @ &r/sharepool/shp4 4xamnunv51w9j
old 16: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1'
new 16: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j'
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- -------- ---------- ---------- -------------
子游标句柄地址 000000007E29C690 000000007E29CB10 select * from dept where deptno=10 000000007E29C5D8 000000007DE74770 4488 12144 3067 19699 19699 911274289 4xamnunv51w9j
父游标句柄地址 000000007E29CB10 000000007E29CB10 select * from dept where deptno=10 000000007E29CA58 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j
new 1: select a.*,dump(a.KSMCHCOM,16) c60 from x$ksmsp a where a.ksmchpar='000000007DE74770'
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR C60
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ---------------- ------------------------------------------------------------
00007F569C133908 5065 1 1 4 SQLA^3650f131 000000007D92B1A0 4096 recr 4095 000000007DE74770 Typ=1 Len=13: 53,51,4c,41,5e,33,36,35,30,66,31,33,31
00007F569C1337A8 5069 1 1 4 SQLA^3650f131 000000007D9271A0 4096 freeabl 0 000000007DE74770 Typ=1 Len=13: 53,51,4c,41,5e,33,36,35,30,66,31,33,31
00007F569C133750 5070 1 1 4 SQLA^3650f131 000000007D9261A0 4096 freeabl 0 000000007DE74770 Typ=1 Len=13: 53,51,4c,41,5e,33,36,35,30,66,31,33,31
--看看07D92B1A0 位置。
SYS@book> ALTER SESSION SET EVENTS 'immediate trace name heapdump level 2';
Session altered.
SYS@book> @ &r/pp
TRACEFILE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/book/book/trace/book_ora_33635.trc
$ egrep -C1 -n "07d92b1a0|SEPARATOR" /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_33635.trc
4763- Chunk 07e29c7d0 sz= 544 recreate "KGLHD " latch=(nil)
4764: Chunk 07d92b1a0 sz= 4096 recreate "SQLA^3650f131 " latch=(nil)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4765- Chunk 07faff790 sz= 4096 recreate "KGLS^2aa27d0d " latch=(nil)
--
5041- Chunk 07ddcf000 sz= 4096 recreate "KGLH0^66d55af5 " latch=(nil)
5042:SEPARATOR
5043- Chunk 085067c40 sz= 1072 recreate "KQR PO " latch=0x81e35e48
--
19527-UNPINNED RECREATABLE CHUNKS (lru first):
19528:SEPARATOR
19529-Unpinned space = 0 rcr=0 trn=0
--
24853-UNPINNED RECREATABLE CHUNKS (lru first):
24854:SEPARATOR
24855-Unpinned space = 0 rcr=0 trn=0
--
26273- ds 07de71370 sz= 4096 ct= 1
26274: Chunk 07d92b1a0 sz= 4096 recreate "SQLA^3650f131 " latch=(nil)
$$$$$$$$$
26275- ds 07de74770 sz= 12288 ct= 3
--
36682-UNPINNED RECREATABLE CHUNKS (lru first):
36683:SEPARATOR
36684-Unpinned space = 0 rcr=0 trn=0
-- 注意看下划~的部分,现在4764行。 分割线5042:SEPARATOR.
--另外可以看到4个SEPARATOR,因为有4个subpool的原因。另外后面出现07d92b1a0($处)那是DS描述符,后面一样,不再重复。
3.继续测试:
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
--再执行其他语句。
SYS@book> ALTER SESSION SET EVENTS 'immediate trace name heapdump level 2';
Session altered.
SYS@book> @ &r/pp
TRACEFILE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/book/book/trace/book_ora_33702.trc
$ egrep -C1 -n "07d92b1a0|SEPARATOR" /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_33702.trc
5108- Chunk 07eb138c0 sz= 4096 recreate "SQLA^cffc296d " latch=(nil)
5109:SEPARATOR
5110- Chunk 085067c40 sz= 1072 recreate "KQR PO " latch=0x81e35e48
--
7112- Chunk 07de71000 sz= 4096 recreate "KGLH0^804f0d17 " latch=(nil)
7113: Chunk 07d92b1a0 sz= 4096 recreate "SQLA^3650f131 " latch=(nil)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7114- Chunk 07de73000 sz= 4096 recreate "KGLH0^3650f131 " latch=(nil)
--
19854-UNPINNED RECREATABLE CHUNKS (lru first):
19855:SEPARATOR
19856-Unpinned space = 0 rcr=0 trn=0
--
25292-UNPINNED RECREATABLE CHUNKS (lru first):
25293:SEPARATOR
25294-Unpinned space = 0 rcr=0 trn=0
--
26990- ds 07de71370 sz= 4096 ct= 1
26991: Chunk 07d92b1a0 sz= 4096 recreate "SQLA^3650f131 " latch=(nil)
26992- ds 07de74770 sz= 12288 ct= 3
--
37399-UNPINNED RECREATABLE CHUNKS (lru first):
37400:SEPARATOR
37401-Unpinned space = 0 rcr=0 trn=0
-- 注意看+的部分,现在7113行。 分割线5109:SEPARATOR.验证了vgae的测试。
4.继续测试:
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
--再执行其他语句。
SYS@book> ALTER SESSION SET EVENTS 'immediate trace name heapdump level 2';
Session altered.
SYS@book> @ &r/pp
TRACEFILE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/book/book/trace/book_ora_33725.trc
$ egrep -C1 -n "07d92b1a0|SEPARATOR" /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_33725.trc
5047- Chunk 07f0ae9e0 sz= 544 recreate "KGLHD " latch=(nil)
5048:SEPARATOR
5049- Chunk 085067c40 sz= 1072 recreate "KQR PO " latch=0x81e35e48
--
7051- Chunk 07de71000 sz= 4096 recreate "KGLH0^804f0d17 " latch=(nil)
7052: Chunk 07d92b1a0 sz= 4096 recreate "SQLA^3650f131 " latch=(nil)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7053- Chunk 07de73000 sz= 4096 recreate "KGLH0^3650f131 " latch=(nil)
--
19872-UNPINNED RECREATABLE CHUNKS (lru first):
19873:SEPARATOR
19874-Unpinned space = 0 rcr=0 trn=0
--
25316-UNPINNED RECREATABLE CHUNKS (lru first):
25317:SEPARATOR
25318-Unpinned space = 0 rcr=0 trn=0
--
27024- ds 07de71370 sz= 4096 ct= 1
27025: Chunk 07d92b1a0 sz= 4096 recreate "SQLA^3650f131 " latch=(nil)
27026- ds 07de74770 sz= 12288 ct= 3
--
37433-UNPINNED RECREATABLE CHUNKS (lru first):
37434:SEPARATOR
37435-Unpinned space = 0 rcr=0 trn=0
-- 注意看!的部分,现在7052行。 分割线5048:SEPARATOR.验证了vgae的测试。