.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 2000-2005 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VBD73$
.tt 2 $$$
.tt 3 $JuergenP$ref_statistic$2000-08-31$
***********************************************************
.nf
 
 .nf

    ========== licence begin  GPL
    Copyright (c) 2000-2005 SAP AG

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
.fo

 
.fo
.nf
.sp
Module  : ref_statistic
=========
.sp
Purpose : primitives for monitoring of kernel operations
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              b73cmd_count (statement_kind : tgg00_RefInfoIndex);
 
        PROCEDURE
              b73cmds_count (statement_kind : tgg00_RefInfoIndex;
                    count : tsp00_Int4);
 
        PROCEDURE
              b73directory_ref_statistic
                    (op_code : tgg00_DirectoryMonitorOp);
 
        PROCEDURE
              b73init_ref_statistic (part : tgg00_MonitorPart);
 
        PROCEDURE
              bd73DataIOStatisticForVirtualWrite (
                    level      : integer;
                    bIsPerm    : boolean;
                    bIsBlob    : boolean;
                    bIsCatalog : boolean );
 
        PROCEDURE
              bd73DataIOStatisticForVirtualRead (
                    level      : integer;
                    bIsPerm    : boolean;
                    bIsBlob    : boolean;
                    bIsCatalog : boolean );
 
        PROCEDURE
              bd73DataIOStatisticForPhysicalWrite (
                    level      : integer;
                    bIsPerm    : boolean;
                    bIsBlob    : boolean;
                    bIsCatalog : boolean );
 
        PROCEDURE
              bd73DataIOStatisticForPhysicalRead (
                    level      : integer;
                    bIsPerm    : boolean;
                    bIsBlob    : boolean;
                    bIsCatalog : boolean );
 
        PROCEDURE
              bd73LogIOStatistic( bForRead : boolean );
 
        PROCEDURE
              bd73ConverterIOStatistic( bForRead : boolean );
 
        PROCEDURE
              b73show_ref_statistic (
                    TaskId   : tsp00_TaskId;
                    VAR info : tgg00_ReferenceInfo);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              systembufferinterface : VBD20;
 
        PROCEDURE
              bd20ClearAccessStatistic(
                    TaskId : tsp00_TaskId );
 
        PROCEDURE
              bd20GetAccessStatistic(
                    TaskId               : tsp00_TaskId;
                    VAR HistoryTotal     : tsp00_8ByteCounter;
                    VAR HistoryHit       : tsp00_8ByteCounter;
                    VAR HistoryMiss      : tsp00_8ByteCounter;
                    VAR OmsDataTotal     : tsp00_8ByteCounter;
                    VAR OmsDataHit       : tsp00_8ByteCounter;
                    VAR OmsDataMiss      : tsp00_8ByteCounter;
                    VAR SqlDataTotal     : tsp00_8ByteCounter;
                    VAR SqlDataHit       : tsp00_8ByteCounter;
                    VAR SqlDataMiss      : tsp00_8ByteCounter);
 
      ------------------------------ 
 
        FROM
              RTE_kernel : ven101;
 
        PROCEDURE
              vgetpid (VAR pid : tsp00_TaskId);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : JuergenP
.sp
.cp 3
Created : 1981-10-20
.sp
.cp 3
.sp
.cp 3
Release :      Date : 2000-08-31
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
bd_call_count (bd_op_code)
.sp
bd_op_code stands for:
.sp
.nf
1  : create file
2  : create invfile
3  : destroy file
4  : rename file
5  : checkpoint
11 : add record
12 : repl record
13 : del record
14 : get record
15 : prev record
16 : next record
21 : add inv
22 : del inv
23 : get inv
.CM *-END-* specification -------------------------------
.fo
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
TYPE
      tbd73_monitor_op = (
            m_virt_schema_read,
            m_virt_schema_write,
            m_phys_schema_read,
            m_phys_schema_write,
            m_virt_perm_read,
            m_virt_perm_write,
            m_phys_perm_read,
            m_phys_perm_write,
            m_virt_temp_read,
            m_virt_temp_write,
            m_phys_temp_read,
            m_phys_temp_write,
            m_virt_bstr_read,
            m_virt_bstr_write,
            m_phys_bstr_read,
            m_phys_bstr_write,
            m_virt_level0_read,
            m_virt_level0_write,
            m_phys_level0_read,
            m_phys_level0_write,
            m_virt_level1_read,
            m_virt_level1_write,
            m_phys_level1_read,
            m_phys_level1_write,
            m_virt_level2_read,
            m_virt_level2_write,
            m_phys_level2_read,
            m_phys_level2_write,
            m_virt_level3_read,
            m_virt_level3_write,
            m_phys_level3_read,
            m_phys_level3_write,
            m_virt_level4_read,
            m_virt_level4_write,
            m_phys_level4_read,
            m_phys_level4_write,
            m_virt_level5_read,
            m_virt_level5_write,
            m_phys_level5_read,
            m_phys_level5_write);
 
VAR
      b73monitor_info : tgg00_ReferenceInfo;
 
 
(*------------------------------*) 
 
PROCEDURE
      b73cmd_count (statement_kind : tgg00_RefInfoIndex);
 
BEGIN
WITH b73monitor_info DO
    reference_array[ statement_kind ] :=
          reference_array[ statement_kind ] + 1;
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b73cmds_count (statement_kind : tgg00_RefInfoIndex;
            count : tsp00_Int4);
 
BEGIN
WITH b73monitor_info DO
    reference_array[ statement_kind ] :=
          reference_array[ statement_kind ] + count;
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b73directory_ref_statistic
            (op_code : tgg00_DirectoryMonitorOp);
 
BEGIN
WITH b73monitor_info DO
    BEGIN
    CASE op_code OF
        dir_hit :
            BEGIN
            ak_cache_total := ak_cache_total + 1;
            ak_cache_hit := ak_cache_hit + 1
            END;
        dir_miss :
            BEGIN
            ak_cache_total := ak_cache_total + 1;
            ak_cache_miss := ak_cache_miss + 1
            END;
        func_count :
            BEGIN
            funccount := funccount + 1;
            sql_commands := sql_commands + 1
            END;
        (* PTS 1003033 E.Z. *)
        END
    (*ENDCASE*) 
    END
(*ENDWITH*) 
END;
 
(* PTS 1105315 E.Z. *)
(*------------------------------*) 
 
PROCEDURE
      b73init_ref_statistic (part : tgg00_MonitorPart);
 
VAR
      ind    : tgg00_RefInfoIndex;
      TaskId : tsp00_TaskId;
 
BEGIN (* h.b. PTS 1105314 *)
vgetpid( TaskId );
CASE part OF
    mpAll_egg00 :
        BEGIN
        FOR ind := idata_cache_total TO ikb_calls DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
        bd20ClearAccessStatistic( TaskId );
        END;
    mpCaches_egg00 :
        BEGIN
        (* PTS 1111572 E.Z. *)
        FOR ind := idata_cache_total TO idata_history_cache_percent DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
        bd20ClearAccessStatistic( TaskId );
        END;
    mpLoad_egg00 :
        FOR ind := isql_commands TO iins_sorts_rows_ins DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
    mpLog_egg00 :
        FOR ind := iread_log TO iavg_sum_pagewaits DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
    mpLong_egg00 :
        (* PTS 1003033 E.Z. *)
        FOR ind := iread_string TO iwrite_string DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
    mpPages_egg00 :
        (* PTS 1115043 E.Z. *)
        FOR ind := ir_v_acc TO ipsm_w_p DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
    mpRow_egg00 :
        FOR ind := iadd_rec TO icget_inv DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
    mpTransaction_egg00 :
        FOR ind := ifunccount TO ikb_calls DO
            b73monitor_info.reference_array [ ind ] := 0;
        (*ENDFOR*) 
    OTHERWISE;
        BEGIN
        END;
    END;
(*ENDCASE*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd73DataIOStatisticForVirtualWrite (
            level      : integer;
            bIsPerm    : boolean;
            bIsBlob    : boolean;
            bIsCatalog : boolean );
 
BEGIN
CASE level OF
    0 :
        bd73_DataRefStatistic(m_virt_level0_write);
    1 :
        bd73_DataRefStatistic(m_virt_level1_write);
    2 :
        bd73_DataRefStatistic(m_virt_level2_write);
    3 :
        bd73_DataRefStatistic(m_virt_level3_write);
    4 :
        bd73_DataRefStatistic(m_virt_level4_write);
    5 :
        bd73_DataRefStatistic(m_virt_level5_write);
    OTHERWISE
        BEGIN
        END
    END;
(*ENDCASE*) 
IF  NOT bIsPerm
THEN
    bd73_DataRefStatistic(m_virt_temp_write)
ELSE
    IF  bIsBlob
    THEN
        bd73_DataRefStatistic(m_virt_bstr_write)
    ELSE
        IF  bIsCatalog
        THEN
            bd73_DataRefStatistic( m_virt_schema_write)
        ELSE
            bd73_DataRefStatistic(m_virt_perm_write);
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd73DataIOStatisticForVirtualRead (
            level      : integer;
            bIsPerm    : boolean;
            bIsBlob    : boolean;
            bIsCatalog : boolean );
 
BEGIN
CASE level OF
    0 :
        bd73_DataRefStatistic(m_virt_level0_read);
    1 :
        bd73_DataRefStatistic(m_virt_level1_read);
    2 :
        bd73_DataRefStatistic(m_virt_level2_read);
    3 :
        bd73_DataRefStatistic(m_virt_level3_read);
    4 :
        bd73_DataRefStatistic(m_virt_level4_read);
    5 :
        bd73_DataRefStatistic(m_virt_level5_read);
    OTHERWISE
        BEGIN
        END
    END;
(*ENDCASE*) 
IF  NOT bIsPerm
THEN
    bd73_DataRefStatistic(m_virt_temp_read)
ELSE
    IF  bIsBlob
    THEN
        bd73_DataRefStatistic(m_virt_bstr_read)
    ELSE
        IF  bIsCatalog
        THEN
            bd73_DataRefStatistic( m_virt_schema_read)
        ELSE
            bd73_DataRefStatistic(m_virt_perm_read);
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd73DataIOStatisticForPhysicalWrite (
            level      : integer;
            bIsPerm    : boolean;
            bIsBlob    : boolean;
            bIsCatalog : boolean );
 
BEGIN
CASE level OF
    0 :
        bd73_DataRefStatistic(m_phys_level0_write);
    1 :
        bd73_DataRefStatistic(m_phys_level1_write);
    2 :
        bd73_DataRefStatistic(m_phys_level2_write);
    3 :
        bd73_DataRefStatistic(m_phys_level3_write);
    4 :
        bd73_DataRefStatistic(m_phys_level4_write);
    5 :
        bd73_DataRefStatistic(m_phys_level5_write);
    OTHERWISE
        BEGIN
        END
    END;
(*ENDCASE*) 
IF  NOT bIsPerm
THEN
    bd73_DataRefStatistic(m_phys_temp_write)
ELSE
    IF  bIsBlob
    THEN
        bd73_DataRefStatistic(m_phys_bstr_write)
    ELSE
        IF  bIsCatalog
        THEN
            bd73_DataRefStatistic( m_phys_schema_write)
        ELSE
            bd73_DataRefStatistic(m_phys_perm_write);
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd73DataIOStatisticForPhysicalRead (
            level      : integer;
            bIsPerm    : boolean;
            bIsBlob    : boolean;
            bIsCatalog : boolean );
 
BEGIN
CASE level OF
    0 :
        bd73_DataRefStatistic(m_phys_level0_read);
    1 :
        bd73_DataRefStatistic(m_phys_level1_read);
    2 :
        bd73_DataRefStatistic(m_phys_level2_read);
    3 :
        bd73_DataRefStatistic(m_phys_level3_read);
    4 :
        bd73_DataRefStatistic(m_phys_level4_read);
    5 :
        bd73_DataRefStatistic(m_phys_level5_read);
    OTHERWISE
        BEGIN
        END
    END;
(*ENDCASE*) 
IF  NOT bIsPerm
THEN
    bd73_DataRefStatistic(m_phys_temp_read)
ELSE
    IF  bIsBlob
    THEN
        bd73_DataRefStatistic(m_phys_bstr_read)
    ELSE
        IF  bIsCatalog
        THEN
            bd73_DataRefStatistic( m_phys_schema_read)
        ELSE
            bd73_DataRefStatistic(m_phys_perm_read);
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd73LogIOStatistic( bForRead : boolean );
 
BEGIN
WITH b73monitor_info DO
    BEGIN
    IF  bForRead
    THEN
        read_log := read_log + 1
    ELSE
        write_log := write_log + 1
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd73ConverterIOStatistic( bForRead : boolean );
 
BEGIN
WITH b73monitor_info DO
    BEGIN
    IF  bForRead
    THEN
        psm_r_p := psm_r_p + 1
    ELSE
        psm_w_p := psm_w_p + 1;
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      b73show_ref_statistic (
            TaskId   : tsp00_TaskId;
            VAR info : tgg00_ReferenceInfo);
 
BEGIN
info := b73monitor_info;
(* *)
(* PTS 1111572 E.Z. *)
WITH info DO
    bd20GetAccessStatistic(
          TaskId,
          data_history_cache_total,
          data_history_cache_hit,
          data_history_cache_miss,
          data_obj_cache_total,
          data_obj_cache_hit,
          data_obj_cache_miss,
          data_cache_total,
          data_cache_hit,
          data_cache_miss)
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      bd73_DataRefStatistic (op_code : tbd73_monitor_op);
 
BEGIN
WITH b73monitor_info DO
    BEGIN
    CASE op_code OF
        m_virt_schema_read :
            BEGIN
            r_v_acc := r_v_acc + 1;
            catalog_r_v := catalog_r_v + 1
            END;
        m_virt_schema_write :
            BEGIN
            w_v_acc := w_v_acc + 1;
            catalog_w_v := catalog_w_v + 1
            END;
        m_phys_schema_read :
            BEGIN
            r_p_acc := r_p_acc + 1;
            catalog_r_p := catalog_r_p + 1
            END;
        m_phys_schema_write :
            BEGIN
            w_p_acc := w_p_acc + 1;
            catalog_w_p := catalog_w_p + 1
            END;
        m_virt_perm_read :
            BEGIN
            r_v_acc := r_v_acc + 1;
            perm_r_v := perm_r_v + 1
            END;
        m_virt_perm_write :
            BEGIN
            w_v_acc := w_v_acc + 1;
            perm_w_v := perm_w_v + 1
            END;
        m_phys_perm_read :
            BEGIN
            r_p_acc := r_p_acc + 1;
            perm_r_p := perm_r_p + 1
            END;
        m_phys_perm_write :
            BEGIN
            w_p_acc := w_p_acc + 1;
            perm_w_p := perm_w_p + 1
            END;
        m_virt_temp_read :
            BEGIN
            r_v_acc := r_v_acc + 1;
            temp_r_v := temp_r_v + 1
            END;
        m_virt_temp_write :
            BEGIN
            w_v_acc := w_v_acc + 1;
            temp_w_v := temp_w_v + 1
            END;
        m_phys_temp_read :
            BEGIN
            r_p_acc := r_p_acc + 1;
            temp_r_p := temp_r_p + 1
            END;
        m_phys_temp_write :
            BEGIN
            w_p_acc := w_p_acc + 1;
            temp_w_p := temp_w_p + 1
            END;
        m_virt_bstr_read :
            BEGIN
            r_v_acc := r_v_acc + 1;
            bstr_r_v := bstr_r_v + 1
            END;
        m_virt_bstr_write :
            BEGIN
            w_v_acc := w_v_acc + 1;
            bstr_w_v := bstr_w_v + 1
            END;
        m_phys_bstr_read :
            BEGIN
            r_p_acc := r_p_acc + 1;
            bstr_r_p := bstr_r_p + 1
            END;
        m_phys_bstr_write :
            BEGIN
            w_p_acc := w_p_acc + 1;
            bstr_w_p := bstr_w_p + 1
            END;
        (* PTS 1003033 E.Z. *)
        m_virt_level0_read :
            BEGIN
            level0_r_v := level0_r_v + 1
            END;
        m_virt_level0_write :
            BEGIN
            level0_w_v := level0_w_v + 1
            END;
        m_phys_level0_read :
            BEGIN
            level0_r_p := level0_r_p + 1
            END;
        m_phys_level0_write :
            BEGIN
            level0_w_p := level0_w_p + 1
            END;
        m_virt_level1_read :
            BEGIN
            level1_r_v := level1_r_v + 1
            END;
        m_virt_level1_write :
            BEGIN
            level1_w_v := level1_w_v + 1
            END;
        m_phys_level1_read :
            BEGIN
            level1_r_p := level1_r_p + 1
            END;
        m_phys_level1_write :
            BEGIN
            level1_w_p := level1_w_p + 1
            END;
        m_virt_level2_read :
            BEGIN
            level2_r_v := level2_r_v + 1
            END;
        m_virt_level2_write :
            BEGIN
            level2_w_v := level2_w_v + 1
            END;
        m_phys_level2_read :
            BEGIN
            level2_r_p := level2_r_p + 1
            END;
        m_phys_level2_write :
            BEGIN
            level2_w_p := level2_w_p + 1
            END;
        m_virt_level3_read :
            BEGIN
            level3_r_v := level3_r_v + 1
            END;
        m_virt_level3_write :
            BEGIN
            level3_w_v := level3_w_v + 1
            END;
        m_phys_level3_read :
            BEGIN
            level3_r_p := level3_r_p + 1
            END;
        m_phys_level3_write :
            BEGIN
            level3_w_p := level3_w_p + 1
            END;
        m_virt_level4_read :
            BEGIN
            level4_r_v := level4_r_v + 1
            END;
        m_virt_level4_write :
            BEGIN
            level4_w_v := level4_w_v + 1
            END;
        m_phys_level4_read :
            BEGIN
            level4_r_p := level4_r_p + 1
            END;
        m_phys_level4_write :
            BEGIN
            level4_w_p := level4_w_p + 1
            END;
        m_virt_level5_read :
            BEGIN
            level5_r_v := level5_r_v + 1
            END;
        m_virt_level5_write :
            BEGIN
            level5_w_v := level5_w_v + 1
            END;
        m_phys_level5_read :
            BEGIN
            level5_r_p := level5_r_p + 1
            END;
        m_phys_level5_write :
            BEGIN
            level5_w_p := level5_w_p + 1
            END;
        OTHERWISE:
            BEGIN
            END;
        END
    (*ENDCASE*) 
    END
(*ENDWITH*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
.PA 
