ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle Buffer Cache原理总结(二)

Oracle Buffer Cache原理总结(二)

原创 Linux操作系统 作者:oracle_ace 时间:2008-01-07 17:43:39 0 删除 编辑

    由于我们的buffer  cache是基于一种共享内存的结构,而且buffer的获取和修改都不可避免的要对Buffer cache中LRU List进行扫描,在runtime的环境中常常会存在并发进程的并发访问,由于shared memory type的原因,如果没有一种封锁机制,那么很可能会在多进程并发访问的时候破坏的buffer cache的内存结构和数据,在Oracle中latch是一种低级的串行化的设备,并发进程在scan LRU List的时候必须获取latch,这样一来就起了一个对buffer cache这种共享内存结构的保护作用.
 
  这个在多进程并发扫描的时候用于lock我们LRU List的latch就是:
Cache Buffers Lru Chain Latch

  如果我们在runtime环境中发现这个latch的竞争比较激烈,那么我们可以
  1.Enlarge the buffer cache size.
  2.Increate the count of LRU Latch(_db_block_lru_latches)   Highly not recommanded
  3.Adopt the multi-cached tech(default,recycle, keep)

  通过v$latch视图,我们可以看到这个cache buffers lru chain latch的状态

  SQL> select addr,latch#,name,gets,misses,immediate_gets,immediate_misses
  2  from v$latch
  3  where name='cache buffers lru chain';

ADDR         LATCH#
-------- --------- 
NAME                                                                   GETS
---------------------------------------------------------------- ----------
    MISSES IMMEDIATE_GETS IMMEDIATE_MISSES
---------- -------------- ----------------
02216258         93
cache buffers lru chain                                                4782
         1           4076                3  
 
  同时我们还要知道Cache Buffers Lru Chain Latch还有很多子Latch,这个子latch的数量受_db_block_lru_latches这个隐含参数的影响.
 
 SQL> select
  2  x.ksppinm name,
  3  y.ksppstvl value,
  4  y.ksppstdf isdefault,
  5  decode(bitand(y.ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE') ismod,
  6  decode(bitand(y.ksppstvf,2),2,'TRUE','FALSE') isadj from
  7  sys.x$ksppi x,
  8  sys.x$ksppcv y
  9  where
 10  x.inst_id=userenv('Instance') and
 11  y.inst_id=userenv('Instance') and
 12  x.indx=y.indx and
 13  x.ksppinm like '%_&par%'
 14  order by
 15  translate(x.ksppinm,'_','');
输入 par 的值:  lru
原值   13: x.ksppinm like '%_&par%'
新值   13: x.ksppinm like '%_lru%'

NAME
----------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
ISDEFAULT ISMOD      ISADJ
--------- ---------- -----
_db_block_lru_latches
8
TRUE      FALSE      FALSE

  在我的环境中,这个_db_block_lru_latches的数量是8个

  我们可以通过v$latch _children这个视图进一步来查看子latch的状态:

  SQL> select addr,child#,name,immediate_gets,immediate_misses from v$latch_children
  2  where name='cache buffers lru chain';

ADDR         CHILD#
-------- ----------
NAME                                                             IMMEDIATE_GETS
---------------------------------------------------------------- --------------
IMMEDIATE_MISSES
----------------
68AB27F4          8
cache buffers lru chain                                                       1
               0

68AB2328          7
cache buffers lru chain                                                       1
               0

ADDR         CHILD#
-------- ----------
NAME                                                             IMMEDIATE_GETS
---------------------------------------------------------------- --------------
IMMEDIATE_MISSES
----------------

68AB1E5C          6
cache buffers lru chain                                                       1
               0

68AB1990          5
cache buffers lru chain                                                       1

ADDR         CHILD#
-------- ----------
NAME                                                             IMMEDIATE_GETS
---------------------------------------------------------------- --------------
IMMEDIATE_MISSES
----------------
               0

68AB14C4          4
cache buffers lru chain                                                       1
               0

68AB0FF8          3

ADDR         CHILD#
-------- ----------
NAME                                                             IMMEDIATE_GETS
---------------------------------------------------------------- --------------
IMMEDIATE_MISSES
----------------
cache buffers lru chain                                                    4995
               3

68AB0B2C          2
cache buffers lru chain                                                       1
               0


ADDR         CHILD#
-------- ----------
NAME                                                             IMMEDIATE_GETS
---------------------------------------------------------------- --------------
IMMEDIATE_MISSES
----------------
68AB0660          1
cache buffers lru chain                                                       1
               0


已选择8行。

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

下一篇: TaoBao DBA
请登录后发表评论 登录
全部评论

注册时间:2007-12-10

  • 博文量
    284
  • 访问量
    793049