library cache mutxt竞争

本文探讨了Oracle 11g中Library Cache Latch的变化,介绍其被Library Cache Mutex取代的原因及如何减少资源竞争。通过调整参数和实验对比,展示了不同场景下Mutex的竞争情况。
11G后library cache latch已经消失,被library cache mutxt替代。
library cache latch的数量是比cpu_count值大的最小质数相同的子latch。
@>show parameter cpu

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
cpu_count                            integer                8
@>select count(*) from v$latch_children where name='library cache';

  COUNT(*)
----------
        11
在并发比较大的系统,非常容易造成争用。
11G以后,MUTXT的数量默认为131072,一个mutxt保护N个library cache buckets.这在很大程度上减小了争用。
-------------------查看MUTEXT的数量为131072,总共的桶数是4194304
sys@ROSE>set linesize 120
sys@ROSE>col name for a30
sys@ROSE>col value for a20
sys@ROSE>col describ for a60
sys@ROSE>SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
  2    FROM SYS.x$ksppi x, SYS.x$ksppcv y
  3   WHERE x.inst_id = USERENV ('Instance')
  4     AND y.inst_id = USERENV ('Instance')
  5     AND x.indx = y.indx
  6     AND x.ksppinm LIKE '%&par%'
  7  /
Enter value for par: _kdlu_max_bucket_size

NAME                           VALUE                DESCRIB
------------------------------ -------------------- ------------------------------------------------------------
_kdlu_max_bucket_size          4194304              UTS kdlu bucket size
_kdlu_max_bucket_size_mts      131072               UTS kdlu bucket size for mts

-----------------修改session_cached_cursors为0
sys@ROSE>alter system set session_cached_cursors=20 scope=spfile;

System altered.

sys@ROSE>startup force
ORACLE instance started.

Total System Global Area 8551575552 bytes
Fixed Size                  2243608 bytes
Variable Size            8472495080 bytes
Database Buffers           67108864 bytes
Redo Buffers                9728000 bytes
Database mounted.
Database opened.

----------------SQL文本不同,分别开3个SESSION 执行
declare
a number;
begin
        for i in 1 .. 10000000 loop
        select count(*) into a from wxh_tbd where rownum<2;  
end loop;
end;
/


declare
a number;
begin
        for i in 1 .. 10000000 loop
        select count(*) into a from   wxh_tbd where rownum<3;  
end loop;
end;
/

declare
a number;
begin
        for i in 1 .. 10000000 loop
        select count(*) into a from            wxh_tbd where rownum<4;  
end loop;
end;
/
    SID SPID       EVENT                    
------- ---------- -------------------------
    226 14350      latch: cache buffers chai
    242 14359      latch: cache buffers chai
    210 14341      latch: cache buffers chai
   
-----------------SQL文本有空格的差异,开3个SESSION
declare
a number;
begin
        for i in 1 .. 10000000 loop
        select count(*) into a from wxh_tbd where rownum<2;  
end loop;
end;
/
declare
a number;
begin
        for i in 1 .. 10000000 loop
        select count(*) into a from wxh_tbd    where rownum<2;  
end loop;
end;
/
declare
a number;
begin
        for i in 1 .. 10000000 loop
        select count(*) into a from    wxh_tbd where rownum<2;  
end loop;
end;
/
    SID SPID       EVENT                     
------- ---------- -------------------------
    226 14350      library cache: mutex X   
    242 14359      library cache: mutex X   
    210 14341      library cache: mutex X   
   
    SID SPID       EVENT                    
------- ---------- -------------------------
     66 14178      SQL*Net message to client
    210 14341      cursor: pin S            
    226 14350      cursor: pin S            
    242 14359      library cache: mutex X   
以上测试结果表名,貌似ORACLE是把SQL文本去掉空格,大小写之后分配的bucket,因为这种情况下也产生了mutxt竞争。
而SQL文本完全不一样的,完全不存在竞争MUTXT,因为分配在了不同的BUCKET.
   
-----------------修改session_cached_cursors为20   
sys@ROSE>alter system set session_cached_cursors=20 scope=spfile;

System altered.

sys@ROSE>startup force
ORACLE instance started.

Total System Global Area 8551575552 bytes
Fixed Size                  2243608 bytes
Variable Size            8472495080 bytes
Database Buffers           67108864 bytes
Redo Buffers                9728000 bytes
Database mounted.
Database opened.
-----------------SQL文本相同,开三个SESSION执行文本一摸一样的SQL
declare
a number;
begin
        for i in 1 .. 10000000 loop
        select count(*) into a from wxh_tbd where rownum<2;  
end loop;
end;
/

    SID SPID       EVENT                    
------- ---------- -------------------------
     66 16496      SQL*Net message to client
    242 16680      cursor: pin S            
    226 16671      cursor: pin S            
    194 16662      latch: cache buffers chai        

以上测试结果表名,session_cached_cursors参数值不为空的情况下,PGA保留了指向共享池的对象的LCO指针,使获得MUTXT的时间大大缩小,也就避免了竞争。

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

转载于:http://blog.itpub.net/22034023/viewspace-701601/

内容概要:本文介绍了一个针对电力系统连锁故障传播路径的N-k多阶段双层优化及故障场景筛选模型,该模型基于混合整数线性规划(MILP)方法构建,旨在全面评估电力系统在遭受多重故障时的脆弱性与恢复能力。通过引入故障传播路径的概念,模型能够动态模拟故障在电网中的逐级扩散过程,并结合多阶段优化策略,实现对关键故障场景的有效识别与优先排序。整个框架不仅考虑了初始故障元件的选取,还涵盖了后续因潮流转移引发的级联跳闸行为,从而提升了风险评估的准确性与时效性。该研究已在Matlab平台上完成代码实现,具备良好的可复现性和工程应用价值,适用于提升现代电网的安全防御水平。; 适合人群:电力系统、能源安全及相关领域的科研人员、高校研究生以及从事电网规划与运行管理的工程技术人员。; 使用场景及目标:①用于电力系统安全评估中识别最危险的N-k故障组合;②支撑电网应急预案制定与薄弱环节改造;③作为学术研究中关于级联故障建模与优化求解的教学与验证工具;④服务于智能电网背景下抵御蓄意攻击或极端事件的风险防控决策。; 阅读建议:建议读者结合Matlab代码深入理解模型的数学 formulation 与求解流程,重点关注目标函数设计、约束条件构建及双层优化结构的实现逻辑,同时可通过调整系统参数和故障设定进行仿真对比分析,以掌握不同因素对连锁故障演化的影响规律。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值