Here is the followup to my previous blog post Getting Latch holder info out of the state objects in SGA memory where i described how we can extract latch state objects directly from the SGA memory. So let’s begin !
Test env : oracle 12.2.0.1/OEL6/UEK4
Latch call graph :
Based on my previous finding and using only one hardware breakpoint on “KSLLALAQ” of X$KSUPR fixed table i was able to draw the latch call graph of a specific process using systemtap.
Extract from latch call graph after a commit was issued :
We have three level of indentation (3 latches acquired at the same time) that can be confirmed using v$latchholder :
Extract from latch call graph after a “select * from v$latcholder” was issued :
Finding “KSLLALAQ” address :
select (trim(to_char(to_number(addr,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')+ 568+16*18,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'))) addr from v$process where addr='0000000076D3DF78';
Download : latch_callgraph.stp
Dumping/Sampling latch state object from the SGA :
Here is a little c progam that will extract all the latch state objects from the SGA.The program will have to loop through X$KSUPR fixed table to extract the latch state objects of every process.It takes as parameters the shmid of the shared memory to attach to,the minimum process address as found in X$KSUPR which correspond the index 0 in the array and the process count.
select addr from x$ksupr where indx = 0 ; show parameter processes
Example :
This program can be enhanced to sample latch state object at high frequency and present a profile of latches held with extended info.
Download : latch_monitor.c
That’s it 😀