cache buffers lru chain
cache buffers lru chain閂鎖競爭與解決
當使用者程式需要讀資料到buffer cache時,或cache buffer根據lru演算法進行管理時,就不可避免地要掃描
lru list獲取可用buffer或更改buffer的狀態,我們知道,oracle的buffer cache是共享記憶體,可以為眾多
併發程式併發訪問,所以在搜尋的過程中必須獲取latch(latch是oracle的一種序列鎖機制,用於保護共享記憶體結構)
,鎖定記憶體結構,防止併發訪問損壞記憶體中的資料.
這個用於鎖定lru的latch就是經常見到的cache buffers lru chain.
SQL> select addr,latch#,name,gets,misses,immediate_gets,immediate_misses
2 from v$latch where name='cache buffers lru chain';
ADDR LATCH# NAME GETS MISSES IMMEDIATE_GETS IMMEDIATE_MISSES
---------------- ---------- ----------------------------- ---------- ---------- -------------- ----------------
C00000000BE23B10 117 cache buffers lru chain 2601887 8060 106765296 597096
cache buffers lru chain latch存在多個子latch,它的數量受隱含引數_db_block_lru_latches控制
SQL> 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 '%_db_block_lru_latches%';
NAME VALUE DESCRIB
---------------------------- ------------- -------------------------------
_db_block_lru_latches 32 number of lru latches
可以從v$latch_children檢視檢視當前各子latch使用的情況:
SQL> select addr,latch#,name,gets,misses,immediate_gets,immediate_misses
2 from v$latch_children where name='cache buffers lru chain';
ADDR LATCH# NAME GETS MISSES IMMEDIATE_GETS IMMEDIATE_MISSES
---------------- ---------- ------------------------- -------------- ---------- -------------- ----------------
C00000047AB14E80 117 cache buffers lru chain 68 0 0 0
C00000047AB14928 117 cache buffers lru chain 68 0 0 0
C00000047AB143D0 117 cache buffers lru chain 68 0 0 0
C00000047AB13E78 117 cache buffers lru chain 68 0 0 0
C00000047AB13920 117 cache buffers lru chain 68 0 0 0
C00000047AB133C8 117 cache buffers lru chain 68 0 0 0
C00000047AB12E70 117 cache buffers lru chain 68 0 0 0
C00000047AB12918 117 cache buffers lru chain 68 0 0 0
C00000047AB123C0 117 cache buffers lru chain 68 0 0 0
C00000047AB11E68 117 cache buffers lru chain 68 0 0 0
C00000047AB11910 117 cache buffers lru chain 68 0 0 0
C00000047AB113B8 117 cache buffers lru chain 68 0 0 0
C00000047AB10E60 117 cache buffers lru chain 68 0 0 0
C00000047AB10908 117 cache buffers lru chain 68 0 0 0
C00000047AB103B0 117 cache buffers lru chain 68 0 0 0
C00000047AB0FE58 117 cache buffers lru chain 68 0 0 0
C00000047AB0F900 117 cache buffers lru chain 68 0 0 0
C00000047AB0F3A8 117 cache buffers lru chain 68 0 0 0
C00000047AB0EE50 117 cache buffers lru chain 68 0 0 0
C00000047AB0E8F8 117 cache buffers lru chain 68 0 0 0
ADDR LATCH# NAME GETS MISSES IMMEDIATE_GETS IMMEDIATE_MISSES
---------------- ---------- ------------------------- -------------- ---------- -------------- ----------------
C00000047AB0E3A0 117 cache buffers lru chain 658582 2096 27333396 148252
C00000047AB0DE48 117 cache buffers lru chain 659346 2092 27372470 148770
C00000047AB0D8F0 117 cache buffers lru chain 660582 2168 27373352 148620
C00000047AB0D398 117 cache buffers lru chain 657057 1824 27227832 152743
C00000047AB0CE40 117 cache buffers lru chain 68 0 0 0
C00000047AB0C8E8 117 cache buffers lru chain 68 0 0 0
C00000047AB0C390 117 cache buffers lru chain 68 0 0 0
C00000047AB0BE38 117 cache buffers lru chain 68 0 0 0
C00000047AB0B8E0 117 cache buffers lru chain 70 0 2 0
C00000047AB0B388 117 cache buffers lru chain 70 0 3 0
C00000047AB0AE30 117 cache buffers lru chain 70 0 3 0
C00000047AB0A8D8 117 cache buffers lru chain 70 0 2 0
32 rows selected
如果該latch競爭激烈,通常有如下方法可以採用.
適當的增大buffer cache,這樣可以減少讀資料到buffer cache的機會,減少掃描lru list的競爭
可以適當增加lru latch的數量,修改_db_block_lru_latches引數可以實現,但是該引數通常來說
是足夠的,除非在oracle support的建議下或確知是該引數帶來的影響,否則不推薦修改
透過多緩衝池技術,可以減少不希望的資料老化和全表掃描等操作對於default池的衝擊,
從而可以減少競爭
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-751839/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Leetcode LRU CacheLeetCode
- 用於排查cache buffers chainsAI
- LRU cache原理及go實現Go
- 動手實現一個 LRU cache
- LRU cache快取簡單實現快取
- 用 Go 實現一個 LRU cacheGo
- LRU Cache的原理和python的實現Python
- Android快取機制-LRU cache原理與用法Android快取
- Python 的快取機制: functools.lru_cachePython快取
- 通過原始碼學習@functools.lru_cache原始碼
- Python 中 lru_cache 的使用和實現Python
- PostgreSQL的shared_buffers和系統OS cache的關係SQL
- 從 LRU Cache 帶你看面試的本質面試
- Indirect Buffers
- python自帶快取lru_cache用法及擴充套件(詳細)Python快取套件
- Protocol Buffers 系列 (1) - 什麼是Protocol Buffers?Protocol
- 使用LinkedHashMap來實現一個使用LRU(Least Recently Used)演算法的cacheHashMapAST演算法
- 演算法題:設計和實現一個 LRU Cache 快取機制演算法快取
- ABAP 辨析ON INPUT|REQUEST|CHAIN-INPUT|CHAIN-REQUESTAI
- lru
- 給vnTrader 1.92版本加入lru_cache快取讀取提速優化回測快取優化
- Protocol Buffers 3 學習Protocol
- PostgreSQL的wal_buffersSQL
- Markov Chain & Monte CarloAI
- E. Chain ReactionAIReact
- C. Divisor ChainAI
- Chain-of-Thought PromptingAI
- iptables:No chain/target/match by the nameAI
- Trusted Block Chain Summit(2018.10.09)RustBloCAIMIT
- protobuf、LRU、sigleflight
- Protocol Buffers 在 iOS 中的使用ProtocoliOS
- 責任鏈模式(Chain Of Responsibility)模式AI
- LRU 演算法演算法
- [Python手撕]LRUPython
- Chain of responsibility-責任鏈模式AI模式
- 給 Java 造個輪子 - ChainJavaAI
- 146. LRU 快取快取
- LRU快取機制快取
- library cache pin和library cache lock(一)