Professional Documents
Culture Documents
(CBC)
Analysis
CBC Analysis
Objectives
• Understanding CBC internals; structures and
algorithms
CBC Analysis
OraPub is about Oracle performance.
• OraPub is all about Oracle performance analysis; Resources
systematic and quantitative firefighting and
predictive analysis. • Research Blog
• Web site started in 1995 and the company was • Training
founded in 1998 by Craig Shallahamer.
CBC Analysis
CBC Analysis
My two books...
CBC Analysis
CBC Analysis
The Oracle Block & Buffer…
Variable Space
(internal control structures)
Free Space
Row Space
CBC Analysis
CBC Analysis
http://shallahamer-orapub.blogspot.com/2011/11/are-you-sure-its-index-root-block.html!
CBC Analysis
Identifying an index root block.
SQL> select blevel, leaf_blocks, num_rows from dba_indexes where index_name = 'FINDME_C2';!
!
!
BLEVEL LEAF_BLOCKS NUM_ROWS!
---------- ----------- ----------!
2 500 100000!
!
SQL> select header_file,header_block from dba_segments where segment_name = 'FINDME_C2';!
!
HEADER_FILE HEADER_BLOCK!
----------- ------------! The root block is the
!
1 412480! header block + 1.
SQL> select dbms_utility.make_data_block_address(1,412481) from dual;!
!
DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(1,412481)!
----------------------------------------------!
4606785!
Remember this DBA!
!
SQL> select object_id from dba_objects where object_name = 'FINDME_C2';!
!
OBJECT_ID!
----------!
110869!
Must “treedump” by object_id.
!
SQL> alter session set events 'immediate trace name treedump level 110869';!
!
Session altered.!
!
CBC Analysis
CBC Analysis
There are three key lists...
CBCs
LRUs
WLs
CBC Analysis
400 BHs!
350 CBCs!
2 LRUs!
20% dirty!
No cloning!
CBC Analysis
Buffer headers : the map.
CBC Analysis
CBC Analysis
CBC Analysis
CBC Analysis
Massive memory structure...
Hash Chain
153,600 1,400,000 1,048,576 65,536
Buckets
CBC Buckets/
153 170 256 32
CBC Latch
CBC Analysis
CBC Analysis
Q: Is the buffer in the cache?
A: Check a hash chain.
• To quickly locate a buffer in the cache, Oracle uses a
hashing and linked list / hash chain combination.
0
Input: 10,504
1
4
Hash Value
Creation 5
7
Hash Bucket
Determination 8
Hash chains
CBC Analysis
CBC Analysis
A block hashing example.
$ perl hash_block.pl 10 12 398!
Simple block hashing example with bucket assignment. !
!
Inputs!
buckets = 10 !
file number = 12 !
block number = 398 !
Outputs!
hash value = 66209790046 !
bucket assignment = 6 !
!
$ perl hash_block.pl 10 12 399!
Simple block hashing example with bucket assignment. !
!
Inputs!
buckets = 10 !
file number = 12 !
block number = 399 !
Outputs!
hash value = 66312740769 !
bucket assignment = 9 !
CBC Analysis
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
CBC Analysis
We want very short and
non popular chains!
CBC Analysis
CBC Analysis
CBC latch acquisition patterns.
• Acquisition patterns are typically either disperse and wide-
spread (i.e., singular).
• Disperse patterns are easy to eradicate by adding
additional CBC latches (Oracle centric solution).
• Singular pattern eradication requires additional analysis to
determine why the latch is so active.
http://shallahamer-orapub.blogspot.com/2011/11/cbc-latch-diagnosis-acquisition.html!
CBC Analysis
CBC Analysis
def latch=150!
More
def sleep=300!
drop table op_interim!
/!
create table op_interim as!
select addr,gets,sleeps!
scientific
from v$latch_children!
where latch# = &latch! ... more
/!
exec dbms_lock.sleep(&sleep);!
select t1.addr,!
data
t1.gets-t0.gets delta_gets,!
t1.sleeps-t0.sleeps delta_sleeps! during
problem
from op_interim t0,!
(!
select addr,gets,sleeps!
from v$latch_children!
where latch# = &latch!
times.
) t1!
where t0.addr = t1.addr!
order by 3,2!
/! script: latchchild.sql (OSM)
!
CBC Analysis
Disperse or Singular?
ADDR DELTA_GETS DELTA_SLEEPS!
-------- ------------ -------------!
ADDR DELTA_GETS DELTA_SLEEPS!
...! -------- ------------- ------------!
76D1ABC4 302,356 5! ...!
76D23210 309,631 5! 76C33818 198,038 3!
76C8413C 324,284 5! 76C644A8 81,535 4!
76C75428 232,780 6! 76C7759C 96,993 4!
76CFCFAC 247,324 6! 76C2D1CC 145,096 4!
76E03FEC 149,355 4!
76DB79B0 247,332 6!
76CDD394 160,718 4!
76BFE7A8 253,808 6! 76C68904 182,300 4!
76DB9C98 281,330 6! 76D69374 65,250 5!
76C534AC 323,395 6! 76D7800C 133,134 5!
76D0BCC0 337,938 6! 76DA2650 156,578 5!
76C17DF0 203,694 7! 76C02B88 158,293 5!
76C04DF4 240,050 7! 76CE59E0 145,169 7!
76C7B9F8 158,243 7!
76DE64CC 295,872 7!
76CFF120 65,228 9!
76BF5EF0 232,782 8! 76CFCF30 148,187 11!
76D05864 274,886 8! 76D38668 966,345 62!
! 76CDF508 981,384 96!
1024 rows selected.! 76DAF26C 1962,752 187!
!
1024 rows selected.!
CBC Analysis
Dispersed: More latches can reduce Rt.
http://shallahamer-orapub.blogspot.com/2011/07/cbc-latches-cpu-consumption-and-wait.html!
CBC Analysis
250!
512!
1024!
CBC Analysis
Two common “singular” situations.
• When there is a very active CBC latch, if the
concurrency gets high enough, eventually you'll see
CBC latch contention. Two common situations are:
– A single block contains reference information but it's not
being changed often. If the issue was lots of change
occurring, we'd likely see a buffer busy wait.
– A popular index's root block. Any time an index is
accessed its single root block must first be accessed,
which repeatedly forces the question, "Is this index root
block in the buffer cache?”.
• The diagnostic path is to determine which buffers are
covered by the busy CBC latch and then which
buffers are the busiest within that single latch.
CBC Analysis
CBC Analysis
Buffers related to busy CBC latches.
select hladdr, file#, block#,!
count(*), min(tch) min, median(tch) med,!
round(avg(tch)) avg, max(tch) max!
from op_interim!
group by hladdr, file#, block#!
order by 6!
/!
!
HLADDR FILE# BLOCK# MIN MED AVG MAX!
-------- ------ ---------- ---------- ---------- ---------- ----------!
...!
76BE93CC 1 39364 6 6 6 6!
76BE93CC 1 69730 13 14 14 14!
76CDF508 1 117329 1 36 64 181!
76DAF26C 1 117328 70 125 125 180!
76BE93CC 4 1552339 76 131 131 186!
!
42 rows selected.!
CBC Analysis
CBC Analysis
CBC Analysis
• Books
– Oracle Performance Firefighting (C. Shallahamer)
CBC Analysis
Thank You!
CBC Analysis
CBC Analysis