Latch, mutex and beyond

latch_CPU_load.sql

/*
     This file is part of demos for "Contemporary Latch Internals" seminar v.24.08.2010
     Andrey S. Nikolaev (Andrey.Nikolaev@rdtex.ru) 

     Compute the average number of CPUs busy for latch acquisition
     Only for Oracle 10g and below
     Discussion of latch get interface behind this script in

http://andreynikolaev.wordpress.com/2010/07/11/latch-get-instrumentation/

*/
SET SERVEROUTPUT ON
DECLARE
   i          BINARY_INTEGER;
   Samples    BINARY_INTEGER;
   SampleFreq      NUMBER;
   lavg   NUMBER;
BEGIN
   SampleFreq := 1 / 10;   -- Hz
   Samples := 100;
   lavg := 0;
   FOR i IN 1 .. Samples
   LOOP
	for lload in (SELECT COUNT(1) laq FROM x$ksupr
                   WHERE ksllalaq != HEXTORAW ('00'))
        LOOP
          lavg := lavg + lload.laq;
        END LOOP;
        DBMS_LOCK.sleep (SampleFreq);
   END LOOP;
   lavg := lavg / Samples;
   DBMS_OUTPUT.put_LINE ('Average lath acquisition load=' || lavg);
END;
/

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 68 other followers

%d bloggers like this: