v~ GBLHIT.BCK GBLHIT.BCK!BACK GBLHIT.* [TMP]GBLHIT.BCK/SAV SYSTEM @FV5.3 _RTODTO::  _$1$DUA7: V5.3 ~  *[TOOLSHED]GBLHIT.EXE;2+,5^ . / 4 -A0123 KPWO 56E7F89GHJ0DX0205(E h GBLHITV01-002E05-05  ?!  BASRTL_001! MTHRTL_001! LIBRTL_001!f SMGSHR_0014%GBLHIT-F-NOIFABS, IFAB not found for requested file8D%GBLHIT-I-NOGBLS, Global Buffers not found for this filePD File name: O*GLOBAL BUFFER STATISTICS* !Filename: 3No. Global Buffers: O000000]Total Accesses: u0000000000No. Accessors: 0000000000HIT: %HIT: MISS: %MISS: 000000000 000000000 000000000000= P@ЏRТRP3P<]ЏpT"UUReV0UR|Ɯs Pk#` PC PvfPWLuB8(P  8lP[88P? P,|rbPG4$P,hPW <a*P =zP g dVL7<P )& Po BP1 *p P 0|nd`TP A>>8. P ЏE)VPEߏߏ6PP903)PP.N('N FDC P&ePJNNFDCP OP},- ; Get access allowed SHR= ; allow updaters;3my_rab: $RAB FAB=my_fab ; FAB associated with RAB;.my_IFI: .BLKW 1 ; Internal File identifier$gbh_adr: .BLKL 1 ; Pointer to GBH#gbh_miss: .BLKL 1 ; Miss counter!gbh_hit: .BLKL 1 ; Hit counter'tot_access: .BLKL 1 ; Total Accesses*num_ifbs: .BLKW 1 ; Max number of IFABs4prompt: .ASCID /File name: / ; Prompt for filename+fildsc: .WORD 0 ; Descriptor to receive" .BYTE DSC$K_DTYPE_T ; file name .BYTE DSC$K_CLASS_D .LONG 0+outlen: .LONG 0 ; Length of input string)total: .LONG 0 ; Total Hits & Misses $Divisor: .BLKF 1 ; Work variables0Quotient: .BLKF 1 ; in Percentage CalculationHit_Cent: .BLKF 1 ; % Hits Miss_Cent: .BLKF 1 ; % Misses#Wait_time: .BLKF 1 ; Timing wait+Num_gbls: .BLKL 1 ; No of global buffers+Num_accs: .BLKL 1 ; No of File accessors; .SBTTL Screen data itemsP;-------------------------------------------------------------------------------$; Display Oriented data items followP;-------------------------------------------------------------------------------PNew_pid: .BLKL PDisplay_id: .BLKL n_row: .LONG 203n_col: .LONG 79 -header: .ASCID /*GLOBAL BUFFER STATISTICS*/ line_1: .ASCID /Filename: /&line_2: .ASCID /No. Global Buffers: /txt_gblbuf: .ASCID /000000/"line_3: .ASCID /Total Accesses: /txt_access: .ASCID /0000000000/!line_3a: .ASCID /No. Accessors: /txt_usrs: .ASCID /0000000000/line_4: .ASCID /HIT: /line_5: .ASCID /%HIT: /line_6: .ASCID /MISS: /line_7: .ASCID /%MISS: /txt_hit: .ASCID /000000000/txt_miss: .ASCID /000000000/txt_cent_hit: .ASCID /000000/txt_cent_miss: .ASCID /000000/Rend_set: .LONG SMG$M_BOLDDisp_attr: .LONG SMG$M_BORDER; .SBTTL Error messagesJ;------------------------------------------------------------------------- ; ERROR & INFORMATIONAL MESSAGESJ;-------------------------------------------------------------------------,.PSECT errmsg NOSHR,RD,NOWRT,NOEXE,PIC,LONGFnoifbs: .ASCID /%GBLHIT-F-NOIFABS, IFAB not found for requested file/Inogbh: .ASCID /%GBLHIT-I-NOGBLS, Global Buffers not found for this file/; .SBTTL Exec codeJ;-------------------------------------------------------------------------; Executable Code followsJ;-------------------------------------------------------------------------;.PSECT exec NOSHR,RD,EXE,PIC).ENTRY get_gbh ^M;.SBTTL GET and OPEN user fileJ;-------------------------------------------------------------------------; GET and OPEN FILE sectionJ;-------------------------------------------------------------------------;; Get filename from user.E; OPEN & CONNECT to file (allowing unrestricted access to all others)=; to initialize required global buffer areas in P0 & P1 space;;GETFIL:;$ PUSHAL outlen ; Get filename as$ PUSHAQ prompt ; foreign command! PUSHAQ fildsc ; or prompt if. CALLS #3, g^lib$get_foreign ; none supplied Check_statusSETFAB:7 MOVB fildsc, My_FAB+FAB$B_FNS ; length of filename MOVL #fildsc, R28 MOVL 4(R2), My_FAB+FAB$L_FNA ; address of file string CLRL R2 OPNFIL:  $OPEN FAB=my_fab check_status ;< MOVW my_fab+FAB$W_IFI, My_ifi ; Retrieve internal File id.6CONNCT: $CONNECT RAB=my_rab ; connect record stream2 check_status ; to initialize GLobal Buffer ; References.% MOVZWL My_fab+FAB$W_GBC, Num_gbls; ;; .SBTTL ACCESS IFAB structuresN;-----------------------------------------------------------------------------,; ACCESS IFAB & GLOBAL BUFFER HEADER SectionN;-----------------------------------------------------------------------------;F; This section of code will access the global buffer header associated0; with the opened file. This is done as follows:;7; Find IFAB table in the Image I/O area of the process.4; Search this table until the correct IFAB is found ; (IFAB$W_IFI = FAB$W_IFI)4; Locate GBH using IFAB global buffer header pointer>; Get the values of the GBH counters GBH$L_HIT and GBH$L_MISS.;9 MOVL #PIO$GW_IIOIMPA, R4 ; Address of Image I/O area in ; R4$ MOVW IMP$W_NUM_IFABS(R4),Num_IFBS;/ CMPW Num_IFBS, #0 ; Test to see if there are BNEQ 1$ ;+ JMP No_IFAB ; any IFABS (Error if none)91$: MOVL IMP$L_IFABTBL(R4),R5 ; Address of IFABTBL in R5 ADDL #4,R5 ; skip IFBTBLNK;$; Search IFAB table for correct IFAB;$ MOVL #1, R2 ; Initialize counter5IFBLST: MOVL (R5), R6 ; Address of first IFAB in R6< CMPW My_IFI, IFB$W_IFI(R6) ; Have we got the right IFAB?+ BEQL GBH_PTR ; Got it - now get the Gbh  ; ADDL #4,R5 ; next IFAB: AOBLEQ Num_IFBS, R2, IFBLST ; increment counter and loop JMP No_IFAB ; else error;; Get Global Buffer Counters; Gbh_ptr:? MOVL IFB$L_GBH_PTR(R6), GBH_ADR; Global Buffer ptr in Gbh_adr CMPL gbh_adr,#0 ;4 BGTR init_screen ; if not 0 then we've got global) JMP No_gbh ; buffers, otherwise error; !.SBTTL Initialize Screen DisplayP;-------------------------------------------------------------------------------; INITIALIZE SCREEN DISPLAYP;-------------------------------------------------------------------------------; init_screen:H PUSHAL new_pid ; pasteboard id is H CALLS #1,G^SMG$CREATE_PASTEBOARD ; returned in new_pid : check_status J; establish a virtual display region  PUSHAL Disp_attrG PUSHAL display_id B PUSHAL n_col ; starting in column 13 PUSHAL n_row ; row 27 CALLS #3,G^SMG$CREATE_VIRTUAL_DISPLAY > check_status  MOVL #14, n_col MOVL #2, n_row PUSHAL Rend_set PUSHL #0 PUSHAL n_col PUSHAL n_row PUSHAQ header PUSHAL display_id7 CALLS #6, G^SMG$PUT_CHARS_WIDE ; Put Header to screen check_status MOVL #5, n_col MOVL #4, n_row PUSHAL n_col PUSHAL n_row PUSHAQ line_1 PUSHAL display_id2 CALLS #4, G^SMG$PUT_CHARS ; Put Header to screen check_status MOVL #20, n_col MOVL #4, n_row PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ fildsc PUSHAL display_id5 CALLS #6, G^SMG$PUT_CHARS ; Put file name to screen check_status MOVL #6, n_row MOVL #12, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_2 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status PUSHAQ txt_gblbuf PUSHAL num_gbls CALLS #2, G^OTS$CVT_L_TI Check_status MOVL #6, n_row MOVL #32, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_gblbuf PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #6, n_row MOVL #44, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_3 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #6, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_access PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #7, n_row MOVL #44, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_3a PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #7, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_usrs PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #5, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_4 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #11, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #24, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_5 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #29, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #42, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_6 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #48, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_miss PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #62, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_7 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #69, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_miss PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status" PUSHAL #1 ; pasteboard column PUSHAL #1 ; pasteboard row# PUSHAL new_pid ; pasteboard id" PUSHAL Display_id ; display id' CALLS #4, G^SMG$PASTE_VIRTUAL_DISPLAY check_status; .SBTTL Call EXEC routineO;------------------------------------------------------------------------------; GET STATS Via EXEC modeO;------------------------------------------------------------------------------ @gbh_get: $CMEXEC_S ROUTIN=Hit_miss ; Go Get the Hit & MISS stats Check_status; .SBTTL Arithmetic routineP;-------------------------------------------------------------------------------; ARITHMETIC ROUTINESP;-------------------------------------------------------------------------------;,access: ADDL3 gbh_hit, gbh_miss, tot_access;chk_zero: CMPL gbh_hit, #0 BNEQ Percent MOVF #0,Hit_cent JMP Output_results;>Percent: ADDL3 Gbh_hit,Gbh_miss,Total ; get the total accesses1 CVTLF Total,Divisor ; Convert total to F_FLOAT2 CVTLF Gbh_Hit,Quotient ; Convert hits to F_FLOAT" DIVF2 divisor, quotient ; Divide3 MULF2 #100, quotient ; Calculate percentage hits- MOVF Quotient,Hit_cent ; result in Hit_cent; Convert to string PUSHL Hit_cent PUSHAQ txt_cent_hit1 CALLS #2, G^BAS$NUM_F ; convert to ASCII string; Check_status; CMPL gbh_miss, #0  BNEQ Calc_miss MOVF #0,Miss_cent JMP Output_results;:calc_miss: CVTLF Total,Divisor ; Convert total to F_FLOAT5 CVTLF Gbh_Miss,Quotient ; Convert misses to F_FLOAT" DIVF2 divisor, quotient ; Divide5 MULF2 #100, quotient ; Calculate percentage Misses/ MOVF Quotient,Miss_cent ; result in Miss_cent; convert to string PUSHL Miss_cent PUSHAQ txt_cent_miss1 CALLS #2, G^BAS$NUM_F ; convert to ASCII string; ;; !.SBTTL Display results on screenM;----------------------------------------------------------------------------; OUTPUT RESULTS SectionM;----------------------------------------------------------------------------;>; Dump the values of the Global buffer counters to the screen.;output_results:- PUSHAQ txt_access ; display total accesses PUSHAL tot_access CALLS #2, G^OTS$CVT_L_TI Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #6, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_access PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status+ PUSHAQ txt_usrs ; display total accesses PUSHAL num_accs CALLS #2, G^OTS$CVT_L_TI Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #7, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_usrs PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #11, n_col PUSHAQ txt_hit ; display hits PUSHAL gbh_hit CALLS #2, G^OTS$CVT_L_TI Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #29, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status# PUSHAQ txt_miss ; display misses PUSHAL gbh_miss CALLS #2, G^OTS$CVT_L_TI Check_status MOVL #9, n_row MOVL #48, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_miss PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #69, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_miss PUSHAL display_ido CALLS #6, G^SMG$PUT_CHARS0 Check_status6do_loop: MOVF #5,wait_time ; Initialise sample window PUSHAL wait_time CALLS #1, G^LIB$WAIT) JMP gbh_get ; collect latest counters*; &.SBTTL Error and end program routinesO;------------------------------------------------------------------------------*; ERROR and END Program SECTIONRO;------------------------------------------------------------------------------RNo_IFAB: PUSHAQ noifbs  CALLS #1, G^LIB$PUT_OUTPUT BRB end_allRNo_GBH:C PUSHAQ nogbh CALLS #1, G^LIB$PUT_OUTPUT end_all: RETerror: $exit_s R0;W; ).SBTTL EXEC mode code to obtain countersNO;------------------------------------------------------------------------------ .; EXEC CODE to Return GBH$L_HIT and GBH$L_MISSO;------------------------------------------------------------------------------N; .ENTRY Hit_miss ^M;T ; ABSTRACT:QD; This subroutine is executed in EXEC mode to read the global bufferI; header block and save the contents of the global buffer header counters*;O MOVL gbh_adr, R7- MOVL GBH$L_HIT(R7), gbh_hit ; Get hit value / MOVL GBH$L_MISS(R7), gbh_miss; Get miss value*= MOVL GBH$L_USECNT(R7),num_accs; Get number of global buffer ; usersU MOVL #1, R0 ; Return Success RETi.END get_gbh N;-----------------------------------------------------------------------------; * END PROGRAM GBLHIT * N;-----------------------------------------------------------------------------N;=============================================================================*[TOOLSHED]GBLHIT.USER;1+,A./ 4IB-A0123KPWO56䧏7E8?`9`eБGHJ PROGRAM: GBLHIT.MAR% PURPOSE: GLOBAL BUFFER HIT MONITOR. VERSION: V1.0-2 AUTHOR: Thom Park, UK Country Support, BASINGSTOKE! DATE Released: 24 DECEMBER 1986! DATE Reviewed: 30 DECEMBER 1986  PROGRAM: GBLHIT.MAR VERSION: V1.0-2 DOCUMENT: USER GUIDE DATE: 30 DECEMBER 1986 'GLOBAL BUFFER HIT MONITOR. Page 1.1.0 Overview of GBLHIT.1.1 Introduction.F GBLHIT is a prototype utility which displays the Hit & Miss rates of  RMS GLOBAL Buffers. ? GBLHIT has been developed as a tool to assist in the tuning of: RMS Global Buffers on the INTASUN airline booking system.< GBLHIT will display the following information about a file: o Filename. o Number of Global Buffers. o Number of File users.- o Number of File accesses since first user. o Number of Buffer "Hits". o Number of Buffer "Misses".) o Percentage of accesses that are HITs.+ o Percentage of accesses that are MISSes. 2.0 GBLHIT Environment.E GBLHIT should be run from an account which has CMEXEC privilege and ) read access to the file to be monitored.B If the file to be monitored has a large number of global buffers,E then this account should have enough working-set to map the required( data structures, (At least 2000 pages).3.0 Using GBLHIT. B GBLHIT may be activated using the DCL RUN command or as a foreign command. ,3.1 Setting up GBLHIT as a Foreign Command.B In order to use GBLHIT as a foreign command the following command should be supplied to DCL:' $GBLHIT :== $Disk:[Dirname]GBLHIT.EXE6 Where Disk = Device on which GBLHIT image resides,+ Dirname = Directory containing GBLHIT.EXE< Once this has been done GBLHIT may be used as a command eg:% $GBLHIT x.dat ! monitors file x.dat $GBLHIT ; Filename: y.dat ! Monitors file y.dat after prompting for ! filename. 'GLOBAL BUFFER HIT MONITOR. Page 2.3.0 Using GBLHIT (Cont).3.2 Halting GBLHIT.A To stop GBLHIT, the user simply types ^Y to the running program.= As ^Y is currently the only method of stopping GBLHIT, it isA not recommended that it be run from an account with ^Y disabled.2.0 GBLHIT TECHNICAL DATA.2.1 Theory of Operation.D As already mentioned the intended use of this program is to collect@ the HIT and MISS rates of access to a file with Global Buffers.= This information will allow the file designers to decide how? effective the current size and number of Global buffers is for the application's file usage.F GBLHIT works by collecting the contents of two counters maintained byE RMS in the Global Buffer Header (GBH). The GBH provides information B concerning the read/write usage of the global buffers as well as E pointers to the Global Buffer Descriptor list (GBD) which describes 8 the use of each global buffer associated with the file.E Each time RMS performs a read or write operation on the file, one ofE two counters in the GBH will be incremented depending on whether theD record requested is found in the Global buffer in memory, or in the actual file on disk. I If the record is found in a global buffer then GBH$L_HIT is incremented,' if not then GBH$L_MISS is incremented.D Bear in mind that this does not apply to data records alone. Index A records are also buffered. This will explain why, even though ifD a user supplies an invalid key, the HIT counter may be incremented.H The reason for this is that the relevent portion of the index containedE in one of the global buffers to allow RMS to decide that the record % for the specified key did not exist.%2.2 Access to the HIT/MISS Counters.F GBLHIT accesses these counters via certain data structures maintainedC in memory. A diagram of the relationships between these structures is supplied in Figure 1.A The first structure to be accessed is the IFAB table. This is a F structure which lists all the IFAB's currently mapped by the process.E Each file opened by an image will have an IFAB. As GBLHIT only opensF one file (the file selected for monitoring), GBLHIT will only need to" find the first IFAB in this list. 'GLOBAL BUFFER HIT MONITOR. Page 3.,2.2 Access to the HIT/MISS Counters (Cont).A After obtaining the address of the IFAB, GBLHIT then ensures it 1 has the correct IFAB, purely as a sanity check. B This is done by comparing the Internal File Identifier contained > in the IFAB (IFB$W_IFI), with that already obtained from the  FAB (FAB$W_IFI). 6 If these are equal then GBLHIT has the correct IFAB, @ if not then an error is signalled, after searching through the * processes IFAB table for any other IFABs.9 The IFAB is then used to obtain the address of the GBH. 2 This is obtained from the pointer GBH$L_GBH_PTR. @ If this pointer is zero then Global Buffers are not active for $ this file and an error is returned.C Once the address of the GBH is obtained, it is sampled at 5 secondD intervals by an EXEC mode routine which returns the contents of the' two counters GBH$L_HIT and GBH$L_MISS.2.3 Data displayed to terminal.? Some calculations are performed to obtain the following stats:* o Total Accesses (Sum of Hits & Misses).' o Total Hits (contents of GBH$L_HIT).* o Total Misses (contents of GBH$L_MISS).# o % of Hits ( hits/accesses*100).' o % of Misses ( misses/accesses*100).= And this information is diplayed upon the terminal using the# VAX/VMS Screen Management Utility. 'GLOBAL BUFFER HIT MONITOR. Page 4.+Fig. 1. Data structures accessed by GBLHIT. Image I/O Area. PIO$GW_IIOMPA --------------- | | : |<----- | : | |---------------|= | x | IMP$L_NUM_IFABS (Number of IFABs accessed for process) |---------------| | : | | : | |---------------|= --| IFBTBL Adr | IMP$L_IFABTBL (pointer to IFAB Table) | |---------------| | | : | | | : | | |---------------|= ->| 0 | IMP$L_IFBTBLNK (IFAB table LINK, always zero as3 |---------------| far as GBLHIT is concerned) | IFAB address |------- |---------------| | | Next IFAB Adr | |< |---------------| | IFAB (Internal File Access Block) | : | -> ------------ |---------------| | : |$ | Last IFAB Adr | | : |$ |---------------| |------------|" | : | | | IFI | IFB$W_IFI |------------| | : |&~ GBLHIT.BCKAA[TOOLSHED]GBLHIT.USER;1I-e |------------| --| GBH Adr | IFB$L_GBH_PTR | |------------| | | : | | |------------| |$ ------------------------------- |& GBH (Global Buffer Header) | --------------- | | : |<---------------------- | : | |---------------| | User counter | GBH$L_USECNT |---------------| | : | | : | |---------------| | HIT counter | GBH$L_HIT |---------------| | MISS counter | GBH$L_MISS |---------------| | : | | : | --------------- xPPAA[TOOLSHED]GBLHIT.USER;1IĤ ! g>aedyonf -/->AcK)NKEhdyR gm95K0hlfh \TVSPZ]L1\ )-(-)-,-%|@ Oܴ ~ ' :$$ ( * .: |r(biyb)-'-)-|  V-M$`UH>3 !-{)- --S--/-#-'-/-"-$------ |& !!QBb s# .2$e(!$):iK$< I |<  -s$-,-)--!-- S )|=:|4$P,hPW <a*P =zP g dVL7<P )& Po BP1 *p P 0|nd`TP A>>8. P ЏE)VPEߏߏ6PP903)PP.N('N FDC P&ePJNNFDCP OP},- ; Get access allowed SHR= ; allow updaters;3my_rab: $RAB FAB=my_fab ; FAB associated with RAB;.my_IFI: .BLKW 1 ; Internal File identifier$gbh_adr: .BLKL 1 ; Pointer to GBH#gbh_miss: .BLKL 1 ; Miss counter!gbh_hit: .BLKL 1 ; Hit counter'tot_access: .BLKL 1 ; Total Accesses*num_ifbs: .BLKW 1 ; Max number of IFABs4prompt: .ASCID /File name: / ; Prompt for filename+fildsc: .WORD 0 ; Descriptor to receive" .BYTE DSC$K_DTYPE_T ; file name .BYTE DSC$K_CLASS_D .LONG 0+outlen: .LONG 0 ; Length of input string)total: .LONG 0 ; Total Hits & Misses $Divisor: .BLKF 1 ; Work variables0Quotient: .BLKF 1 ; in Percentage CalculationHit_Cent: .BLKF 1 ; % Hits Miss_Cent: .BLKF 1 ; % Misses#Wait_time: .BLKF 1 ; Timing wait+Num_gbls: .BLKL 1 ; No of global buffers+Num_accs: .BLKL 1 ; No of File accessors; .SBTTL Screen data itemsP;-------------------------------------------------------------------------------$; Display Oriented data items followP;-------------------------------------------------------------------------------PNew_pid: .BLKL PDisplay_id: .BLKL n_row: .LONG 203n_col: .LONG 79 -header: .ASCID /*GLOBAL BUFFER STATISTICS*/ line_1: .ASCID /Filename: /&line_2: .ASCID /No. Global Buffers: /txt_gblbuf: .ASCID /000000/"line_3: .ASCID /Total Accesses: /txt_access: .ASCID /0000000000/!line_3a: .ASCID /No. Accessors: /txt_usrs: .ASCID /0000000000/line_4: .ASCID /HIT: /line_5: .ASCID /%HIT: /line_6: .ASCID /MISS: /line_7: .ASCID /%MISS: /txt_hit: .ASCID /000000000/txt_miss: .ASCID /000000000/txt_cent_hit: .ASCID /000000/txt_cent_miss: .ASCID /000000/Rend_set: .LONG SMG$M_BOLDDisp_attr: .LONG SMG$M_BORDER; .SBTTL Error messagesJ;------------------------------------------------------------------------- ; ERROR & INFORMATIONAL MESSAGESJ;-------------------------------------------------------------------------,.PSECT errmsg NOSHR,RD,NOWRT,NOEXE,PIC,LONGFnoifbs: .ASCID /%GBLHIT-F-NOIFABS, IFAB not found for requested file/Inogbh: .ASCID /%GBLHIT-I-NOGBLS, Global Buffers not found for this file/; .SBTTL Exec codeJ;-------------------------------------------------------------------------; Executable Code followsJ;-------------------------------------------------------------------------;.PSECT exec NOSHR,RD,EXE,PIC).ENTRY get_gbh ^M;.SBTTL GET and OPEN user fileJ;-------------------------------------------------------------------------; GET and OPEN FILE sectionJ;-------------------------------------------------------------------------;; Get filename from user.E; OPEN & CONNECT to file (allowing unrestricted access to all others)=; to initialize required global buffer areas in P0 & P1 space;;GETFIL:;$ PUSHAL outlen ; Get filename as$ PUSHAQ prompt ; foreign command! PUSHAQ fildsc ; or prompt if. CALLS #3, g^lib$get_foreign ; none supplied Check_statusSETFAB:7 MOVB fildsc, My_FAB+FAB$B_FNS ; length of filename MOVL #fildsc, R28 MOVL 4(R2), My_FAB+FAB$L_FNA ; address of file string CLRL R2 OPNFIL:  $OPEN FAB=my_fab check_status ;< MOVW my_fab+FAB$W_IFI, My_ifi ; Retrieve internal File id.6CONNCT: $CONNECT RAB=my_rab ; connect record stream2 check_status ; to initialize GLobal Buffer ; References.% MOVZWL My_fab+FAB$W_GBC, Num_gbls; ;; .SBTTL ACCESS IFAB structuresN;-----------------------------------------------------------------------------,; ACCESS IFAB & GLOBAL BUFFER HEADER SectionN;-----------------------------------------------------------------------------;F; This section of code will access the global buffer header associated0; with the opened file. This is done as follows:;7; Find IFAB table in the Image I/O area of the process.4; Search this table until the correct IFAB is found ; (IFAB$W_IFI = FAB$W_IFI)4; Locate GBH using IFAB global buffer header pointer>; Get the values of the GBH counters GBH$L_HIT and GBH$L_MISS.;9 MOVL #PIO$GW_IIOIMPA, R4 ; Address of Image I/O area in ; R4$ MOVW IMP$W_NUM_IFABS(R4),Num_IFBS;/ CMPW Num_IFBS, #0 ; Test to see if there are BNEQ 1$ ;+ JMP No_IFAB ; any IFABS (Error if none)91$: MOVL IMP$L_IFABTBL(R4),R5 ; Address of IFABTBL in R5 ADDL #4,R5 ; skip IFBTBLNK;$; Search IFAB table for correct IFAB;$ MOVL #1, R2 ; Initialize counter5IFBLST: MOVL (R5), R6 ; Address of first IFAB in R6< CMPW My_IFI, IFB$W_IFI(R6) ; Have we got the right IFAB?+ BEQL GBH_PTR ; Got it - now get the Gbh  ; ADDL #4,R5 ; next IFAB: AOBLEQ Num_IFBS, R2, IFBLST ; increment counter and loop JMP No_IFAB ; else error;; Get Global Buffer Counters; Gbh_ptr:? MOVL IFB$L_GBH_PTR(R6), GBH_ADR; Global Buffer ptr in Gbh_adr CMPL gbh_adr,#0 ;4 BGTR init_screen ; if not 0 then we've got global) JMP No_gbh ; buffers, otherwise error; !.SBTTL Initialize Screen DisplayP;-------------------------------------------------------------------------------; INITIALIZE SCREEN DISPLAYP;-------------------------------------------------------------------------------; init_screen:H PUSHAL new_pid ; pasteboard id is H CALLS #1,G^SMG$CREATE_PASTEBOARD ; returned in new_pid : check_status J; establish a virtual display region  PUSHAL Disp_attrG PUSHAL display_id B PUSHAL n_col ; starting in column 13 PUSHAL n_row ; row 27 CALLS #3,G^SMG$CREATE_VIRTUAL_DISPLAY > check_status  MOVL #14, n_col MOVL #2, n_row PUSHAL Rend_set PUSHL #0 PUSHAL n_col PUSHAL n_row PUSHAQ header PUSHAL display_id7 CALLS #6, G^SMG$PUT_CHARS_WIDE ; Put Header to screen check_status MOVL #5, n_col MOVL #4, n_row PUSHAL n_col PUSHAL n_row PUSHAQ line_1 PUSHAL display_id2 CALLS #4, G^SMG$PUT_CHARS ; Put Header to screen check_status MOVL #20, n_col MOVL #4, n_row PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ fildsc PUSHAL display_id5 CALLS #6, G^SMG$PUT_CHARS ; Put file name to screen check_status MOVL #6, n_row MOVL #12, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_2 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status PUSHAQ txt_gblbuf PUSHAL num_gbls CALLS #2, G^OTS$CVT_L_TI Check_status MOVL #6, n_row MOVL #32, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_gblbuf PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #6, n_row MOVL #44, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_3 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #6, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_access PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #7, n_row MOVL #44, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_3a PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #7, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_usrs PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #5, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_4 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #11, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #24, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_5 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #29, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #42, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_6 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #48, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_miss PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #62, n_col PUSHAL n_col PUSHAL n_row PUSHAQ line_7 PUSHAL display_id CALLS #4, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #69, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_miss PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status" PUSHAL #1 ; pasteboard column PUSHAL #1 ; pasteboard row# PUSHAL new_pid ; pasteboard id" PUSHAL Display_id ; display id' CALLS #4, G^SMG$PASTE_VIRTUAL_DISPLAY check_status; .SBTTL Call EXEC routineO;------------------------------------------------------------------------------; GET STATS Via EXEC modeO;------------------------------------------------------------------------------ @gbh_get: $CMEXEC_S ROUTIN=Hit_miss ; Go Get the Hit & MISS stats Check_status; .SBTTL Arithmetic routineP;-------------------------------------------------------------------------------; ARITHMETIC ROUTINESP;-------------------------------------------------------------------------------;,access: ADDL3 gbh_hit, gbh_miss, tot_access;chk_zero: CMPL gbh_hit, #0 BNEQ Percent MOVF #0,Hit_cent JMP Output_results;>Percent: ADDL3 Gbh_hit,Gbh_miss,Total ; get the total accesses1 CVTLF Total,Divisor ; Convert total to F_FLOAT2 CVTLF Gbh_Hit,Quotient ; Convert hits to F_FLOAT" DIVF2 divisor, quotient ; Divide3 MULF2 #100, quotient ; Calculate percentage hits- MOVF Quotient,Hit_cent ; result in Hit_cent; Convert to string PUSHL Hit_cent PUSHAQ txt_cent_hit1 CALLS #2, G^BAS$NUM_F ; convert to ASCII string; Check_status; CMPL gbh_miss, #0  BNEQ Calc_miss MOVF #0,Miss_cent JMP Output_results;:calc_miss: CVTLF Total,Divisor ; Convert total to F_FLOAT5 CVTLF Gbh_Miss,Quotient ; Convert misses to F_FLOAT" DIVF2 divisor, quotient ; Divide5 MULF2 #100, quotient ; Calculate percentage Misses/ MOVF Quotient,Miss_cent ; result in Miss_cent; convert to string PUSHL Miss_cent PUSHAQ txt_cent_miss1 CALLS #2, G^BAS$NUM_F ; convert to ASCII string; ;; !.SBTTL Display results on screenM;----------------------------------------------------------------------------; OUTPUT RESULTS SectionM;----------------------------------------------------------------------------;>; Dump the values of the Global buffer counters to the screen.;output_results:- PUSHAQ txt_access ; display total accesses PUSHAL tot_access CALLS #2, G^OTS$CVT_L_TI Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #6, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_access PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status+ PUSHAQ txt_usrs ; display total accesses PUSHAL num_accs CALLS #2, G^OTS$CVT_L_TI Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag MOVL #7, n_row MOVL #60, n_col PUSHAL n_col PUSHAL n_row PUSHAQ txt_usrs PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #11, n_col PUSHAQ txt_hit ; display hits PUSHAL gbh_hit CALLS #2, G^OTS$CVT_L_TI Check_status PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #29, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_hit PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status# PUSHAQ txt_miss ; display misses PUSHAL gbh_miss CALLS #2, G^OTS$CVT_L_TI Check_status MOVL #9, n_row MOVL #48, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_miss PUSHAL display_id CALLS #6, G^SMG$PUT_CHARS Check_status MOVL #9, n_row MOVL #69, n_col PUSHAL Rend_set PUSHL #0 ; Omit erase flag PUSHAL n_col PUSHAL n_row PUSHAQ txt_cent_miss PUSHAL display_ido CALLS #6, G^SMG$PUT_CHARS0 Check_status6do_loop: MOVF #5,wait_time ; Initialise sample window PUSHAL wait_time CALLS #1, G^LIB$WAIT) JMP gbh_get ; collect latest counters*; &.SBTTL Error and end program routinesO;------------------------------------------------------------------------------*; ERROR and END Program SECTIONRO;------------------------------------------------------------------------------RNo_IFAB: PUSHAQ noifbs  CALLS #1, G^LIB$PUT_OUTPUT BRB end_allRNo_GBH:C PUSHAQ nogbh CALLS #1, G^LIB$PUT_OUTPUT end_all: RETerror: $exit_s R0;W; ).SBTTL EXEC mode code to obtain countersNO;------------------------------------------------------------------------------ .; EXEC CODE to Return GBH$L_HIT and GBH$L_MISSO;------------------------------------------------------------------------------N; .ENTRY Hit_miss ^M;T ; ABSTRACT:QD; This subroutine is executed in EXEC mode to read the global bufferI; header block and save the contents of the global buffer header counters*;O MOVL gbh_adr, R7- MOVL GBH$L_HIT(R7), gbh_hit ; Get hit value / MOVL GBH$L_MISS(R7), gbh_miss; Get miss value*= MOVL GBH$L_USECNT(R7),num_accs; Get number of global buffer ; usersU MOVL #1, R0 ; Return Success RETi.END get_gbh N;-----------------------------------------------------------------------------; * END PROGRAM GBLHIT * N;-----------------------------------------------------------------------------N;=============================================================================*[TOOLSHED]GBLHIT.USER;1+,A./ 4IB-A0123KPWO56䧏7E8?`9`eБGHJ PROGRAM: GBLHIT.MAR% PURPOSE: GLOBAL BUFFER HIT MONITOR. VERSION: V1.0-2 AUTHOR: Thom Park, UK Country Support, BASINGSTOKE! DATE Released: 24 DECEMBER 1986! DATE Reviewed: 30 DECEMBER 1986  PROGRAM: GBLHIT.MAR VERSION: V1.0-2 DOCUMENT: USER GUIDE DATE: 30 DECEMBER 1986 'GLOBAL BUFFER HIT MONITOR. Page 1.1.0 Overview of GBLHIT.1.1 Introduction.F GBLHIT is a prototype utility which displays the Hit & Miss rates of  RMS GLOBAL Buffers. ? GBLHIT has been developed as a tool to assist in the tuning of: RMS Global Buffers on the INTASUN airline booking system.< GBLHIT will display the following information about a file: o Filename. o Number of Global Buffers. o Number of File users.- o Number of File accesses since first user. o Number of Buffer "Hits". o Number of Buffer "Misses".) o Percentage of accesses that are HITs.+ o Percentage of accesses that are MISSes. 2.0 GBLHIT Environment.E GBLHIT should be run from an account which has CMEXEC privilege and ) read access to the file to be monitored.B If the file to be monitored has a large number of global buffers,E then this account should have enough working-set to map the required( data structures, (At least 2000 pages).3.0 Using GBLHIT. B GBLHIT may be activated using the DCL RUN command or as a foreign command. ,3.1 Setting up GBLHIT as a Foreign Command.B In order to use GBLHIT as a foreign command the following command should be supplied to DCL:' $GBLHIT :== $Disk:[Dirname]GBLHIT.EXE6 Where Disk = Device on which GBLHIT image resides,+ Dirname = Directory containing GBLHIT.EXE< Once this has been done GBLHIT may be used as a command eg:% $GBLHIT x.dat ! monitors file x.dat $GBLHIT ; Filename: y.dat ! Monitors file y.dat after prompting for ! filename. 'GLOBAL BUFFER HIT MONITOR. Page 2.3.0 Using GBLHIT (Cont).3.2 Halting GBLHIT.A To stop GBLHIT, the user simply types ^Y to the running program.= As ^Y is currently the only method of stopping GBLHIT, it isA not recommended that it be run from an account with ^Y disabled.2.0 GBLHIT TECHNICAL DATA.2.1 Theory of Operation.D As already mentioned the intended use of this program is to collect@ the HIT and MISS rates of access to a file with Global Buffers.= This information will allow the file designers to decide how? effective the current size and number of Global buffers is for the application's file usage.F GBLHIT works by collecting the contents of two counters maintained byE RMS in the Global Buffer Header (GBH). The GBH provides information B concerning the read/write usage of the global buffers as well as E pointers to the Global Buffer Descriptor list (GBD) which describes 8 the use of each global buffer associated with the file.E Each time RMS performs a read or write operation on the file, one ofE two counters in the GBH will be incremented depending on whether theD record requested is found in the Global buffer in memory, or in the actual file on disk. I If the record is found in a global buffer then GBH$L_HIT is incremented,' if not then GBH$L_MISS is incremented.D Bear in mind that this does not apply to data records alone. Index A records are also buffered. This will explain why, even though ifD a user supplies an invalid key, the HIT counter may be incremented.H The reason for this is that the relevent portion of the index containedE in one of the global buffers to allow RMS to decide that the record % for the specified key did not exist.%2.2 Access to the HIT/MISS Counters.F GBLHIT accesses these counters via certain data structures maintainedC in memory. A diagram of the relationships between these structures is supplied in Figure 1.A The first structure to be accessed is the IFAB table. This is a F structure which lists all the IFAB's currently mapped by the process.E Each file opened by an image will have an IFAB. As GBLHIT only opensF one file (the file selected for monitoring), GBLHIT will only need to" find the first IFAB in this list. 'GLOBAL BUFFER HIT MONITOR. Page 3.,2.2 Access to the HIT/MISS Counters (Cont).A After obtaining the address of the IFAB, GBLHIT then ensures it 1 has the correct IFAB, purely as a sanity check. B This is done by comparing the Internal File Identifier contained > in the IFAB (IFB$W_IFI), with that already obtained from the  FAB (FAB$W_IFI). 6 If these are equal then GBLHIT has the correct IFAB, @ if not then an error is signalled, after searching through the * processes IFAB table for any other IFABs.9 The IFAB is then used to obtain the address of the GBH. 2 This is obtained from the pointer GBH$L_GBH_PTR. @ If this pointer is zero then Global Buffers are not active for $ this file and an error is returned.C Once the address of the GBH is obtained, it is sampled at 5 secondD intervals by an EXEC mode routine which returns the contents of the' two counters GBH$L_HIT and GBH$L_MISS.2.3 Data displayed to terminal.? Some calculations are performed to obtain the following stats:* o Total Accesses (Sum of Hits & Misses).' o Total Hits (contents of GBH$L_HIT).* o Total Misses (contents of GBH$L_MISS).# o % of Hits ( hits/accesses*100).' o % of Misses ( misses/accesses*100).= And this information is diplayed upon the terminal using the# VAX/VMS Screen Management Utility. 'GLOBAL BUFFER HIT MONITOR. Page 4.+Fig. 1. Data structures accessed by GBLHIT. Image I/O Area. PIO$GW_IIOMPA --------------- | | : |<----- | : | |---------------|= | x | IMP$L_NUM_IFABS (Number of IFABs accessed for process) |---------------| | : | | : | |---------------|= --| IFBTBL Adr | IMP$L_IFABTBL (pointer to IFAB Table) | |---------------| | | : | | | : | | |---------------|= ->| 0 | IMP$L_IFBTBLNK (IFAB table LINK, always zero as3 |---------------| far as GBLHIT is concerned) | IFAB address |------- |---------------| | | Next IFAB Adr | |< |---------------| | IFAB (Internal File Access Block) | : | -> ------------ |---------------| | : |$ | Last IFAB Adr | | : |$ |---------------| |------------|" | : | | | IFI | IFB$W_IFI |------------| | : |