关于sharedpool的深入探讨(五)

来源:互联网 发布:网络棋牌害死人 编辑:程序博客网 时间:2024/05/29 18:58
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

关于sharedpool的深入探讨(五)

原文链接:

http://www.eygle.com/internal/shared_pool-5.htm

使用两种数据结构来进行sharedpool的并发控制:lock和pin.
Lock比pin具有更高的级别.

Lock在handle上获得,在pin一个对象之前,必须首先获得该handle的锁定.
锁定主要有三种模式:Null,share,Exclusive.
在读取访问对象时,通常需要获取Null(空)模式以及share(共享)模式的锁定.
在修改对象时,需要获得Exclusive(排他)锁定.

在锁定了LibraryCache对象以后,一个进程在访问之前必须pin该对象.
同样pin有三种模式,Null,shared和exclusive.
只读模式时获得共享pin,修改模式获得排他pin.

通常我们访问、执行过程、Package时获得的都是共享pin,如果排他pin被持有,那么此时就要产生等待.
在很多statspack的report中,我们可能看到以下等待事件:

Top5WaitEvents
~~~~~~~~~~~~~~~~~                                            Wait    %Total
Event                                              Waits Time(cs)  WtTime
---------------------------------------------------------------------------
librarycachelock                                75,884   1,409,500  48.44
latchfree                                    34,297,906   1,205,636  41.43
librarycachepin                                    563     142,491   4.90
dbfilescatteredread                           146,283      75,871   2.61
enqueue                                            2,211      13,003    .45
         -------------------------------------------------------------

这里的librarycachelock和librarycachepin都是我们关心的.接下来我们就研究一下这几个等待事件.         1<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击