Latch state objects from SGA memory : The fun part !

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 :

Capture

We have three level of indentation (3 latches acquired at the same time) that can be confirmed using v$latchholder :

Capture 25

Extract from latch call graph after a “select * from v$latcholder”  was issued :

Capture 26

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.

Capture 28


select addr   from x$ksupr where indx = 0 ;

show parameter processes

Example :

Capture 29

Capture 30

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 😀

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s