From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 21-JAN-1989 09:29
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Thoughts On Page File Usage And How To Determine What Quota Is Enough..


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu,  5 JAN 89 08:26:34 PDT
Received: from central.cis.upenn.edu by KL.SRI.COM with TCP; Thu, 5 Jan 89 08:15:26 PST
Received: from LINC.CIS.UPENN.EDU by central.cis.upenn.edu
	id AA07306; Thu, 5 Jan 89 11:13:33 EST
Received: from XRT.UPENN.EDU by linc.cis.upenn.edu
	id AA27529; Thu, 5 Jan 89 11:17:05 EST
Posted-Date: Thu, 5 Jan 89 11:15 EDT
Message-Id: <8901051617.AA27529@linc.cis.upenn.edu>
Date: Thu, 5 Jan 89 11:15 EDT
From: "Clayton, Paul D." <CLAYTON@xrt.upenn.edu>
Subject: Thoughts On Page File Usage And How To Determine What Quota Is Enough..
To: INFO-VAX@KL.SRI.COM
X-Vms-To: @INFOVAX,CLAYTON


Bob Curley, from Univ. Of Penn, had asked me about some method to help in 
determining what PGFLQUOTA would be needed to run programs being created on 
his system. He kept bumping into the quota problem as simple program(s) were
'enhanced' into complex programs then into HUGE programs.

To this end, I have enclosed a command procedure which will examine the .EXE 
file for the amount of page file usage which MIGHT be used. The comment 
section of the procedure is listed below so you can read through it without 
having to uncompress it to see if you want to use it or not. There are a 
number of areas that cause problems in attempting to figure this out and 
they are listed below. If you want to use it, then cut between the lines as 
shown, then do an '@file' on what you have left.

********* Comment section from procedure. ****************************
$!
$! The following command procedure will generate a listing file from the 
$!	ANALYZE/IMAGE command and then examine this file looking for program
$!	sections that are 'writable'. A section that is marked as 'writable'
$!	could be a written out to the page file and thereby use part of the
$!	SYSUAF quota PGLFLQUOTA for that process. Data sections are marked as 
$!	writable, but code segments are not writable (in most cases), and are 
$!	'paged' back in from the .EXE file itself when needed. The number 
$!	generated from this process should be considered a 'best guess' at 
$!	what a specific program would consume in the way of page file space,
$!	given the exceptions listed the following paragraphs. Note that under 
$!	V4 of VMS the page file space was mapped out even if it was never used,
$!	whereas under V5 of VMS, 'over-mapping', sort of like overbooking on 
$!	airplanes, can take place. 
$!
$! The list of sharable images is also listed to the terminal so that you can 
$!	then run this procedure on them as well. The 'rough' total page file
$!	space would then be the total of the shareable images PLUS the main
$!	image itself. 
$!
$! There are two main areas remaining which could cause the number generated to
$!	be meaningless. The first is the 'current' pagefile space needed before
$!	running the image. This would typically be DCL level and the amount of
$!	pagefile space taken can be found by doing the following two commands.
$!
$!	$current = f$getjpi("","pgflquota") - f$getjpi("","pagfilcnt")
$!	$show symbol current
$!
$!	The second way this number is useless, is if the program expands its 
$!	own 'regions', or creates global sections to use for data areas and
$!	tells VMS to use a local file to the process as the backing store 
$!	instead of the pagefile. This method would typically not have a ISD 
$!	defined for it in the .EXE file, but would be created at run time.
$!
$! In order to run this procedure, the following is the command line syntax.
$!
$!	$@PAGEFILE file_spec
$!
$!	where:
$!		file_spec is the complete file specification of the .EXE image
$!				that you want to examine.
$!

Hope it helps for this problem. ;-)

pdc

Paul D. Clayton 
Address - CLAYTON%XRT@RELAY.UPENN.EDU

Disclaimer:  All thoughts and statements here are my own and NOT those of my 
employer, and are also not based on, or contain, restricted information.



$! ...................... Cut between dotted lines and save. .....................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.03 20-Oct-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user CLAYTON
$! on  5-JAN-1989 11:23:27.44.
$!
$! It contains the following 1 file:
$!        PAGEFILE.COM
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.03 20-Oct-1988 requires VMS V4.4 or higher."
$ EXIT 44 
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY

b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) );
s_file_spec := GET_INFO( COMMAND_LINE, "output_file" );SET( OUTPUT_FILE
, b_part, s_file_spec ); 
b_errors := CREATE_BUFFER( "{Errors}" );i_errors := 0; 
pat_beg_1 := ANCHOR & "-+-+-+ Beginning";
pat_beg_2 := LINE_BEGIN & "+-+-+-+ Beginning";
pat_end := ANCHOR & "+-+-+-+-+ End";
pat_trail := " " & LINE_END;POSITION( BEGINNING_OF( b_part ) ); LOOP b 
:= SEARCH( pat_trail, FORWARD); EXITIF b=0; POSITION( END_OF( b ) )
; LOOP MOVE_HORIZONTAL( -1 ); EXITIF CURRENT_CHARACTER <> ' '; ERASE_CHARACTER
( 1 ); EXITIF CURRENT_OFFSET=0; ENDLOOP; ENDLOOP; POSITION( BEGINNING_OF
( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE ) = END_OF( b_part )
; s_x := ERASE_CHARACTER( 1 ); 
  IF s_x = "+" THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF; 
  IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF; 
  IF s_x = "V" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x = "X" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x <> "" THEN i_errors := i_errors + 1; s_text := CURRENT_LINE; POSITION
( b_errors ); 
    COPY_TEXT( "The following line could not be unpacked properly:" )
; SPLIT_LINE; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part )
; MOVE_VERTICAL( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP 
  r_x := SEARCH( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x )
; ERASE_CHARACTER( 1 ); 
  IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) ); 
  COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE; 
  SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" );ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "PAGEFILE.COM"
$ CHECKSUM_IS = 1377293395
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$!
X$! The following command procedure will generate a listing file from the`032
X$!`009ANALYZE/IMAGE command and then examine this file looking for program
X$!`009sections that are 'writable'. A section that is marked as 'writable'
X$!`009could be a written out to the page file and thereby use part of the
X$!`009SYSUAF quota PGLFLQUOTA for that process. Data sections are marked as`032
X$!`009writable, but code segments are not writable (in most cases), and are`032
X$!`009'paged' back in from the .EXE file itself when needed. The number`032
X$!`009generated from this process should be considered a 'best guess' at`032
X$!`009what a specific program would consume in the way of page file space,
X$!`009given the exceptions listed the following paragraphs. Note that under`032
X$!`009V4 of VMS the page file space was mapped out even if it was never used,
X$!`009whereas under V5 of VMS, 'over-mapping', sort of like overbooking on`032
X$!`009airplanes, can take place.`032
X$!
V$! The list of sharable images is also listed to the terminal so that you can`0
X32
X$!`009then run this procedure on them as well. The 'rough' total page file
X$!`009space would then be the total of the shareable images PLUS the main
X$!`009image itself.`032
X$!
X$! There are two main areas remaining which could cause the number generated to
X$!`009be meaningless. The first is the 'current' pagefile space needed before
X$!`009running the image. This would typically be DCL level and the amount of
X$!`009pagefile space taken can be found by doing the following two commands.
X$!
X$!`009$current = f$getjpi("","pgflquota") - f$getjpi("","pagfilcnt")
X$!`009$show symbol current
X$!
X$!`009The second way this number is useless, is if the program expands its`032
X$!`009own 'regions', or creates global sections to use for data areas and
X$!`009tells VMS to use a local file to the process as the backing store`032
X$!`009instead of the pagefile. This method would typically not have a ISD`032
X$!`009defined for it in the .EXE file, but would be created at run time.
X$!
X$! In order to run this procedure, the following is the command line syntax.
X$!
X$!`009$@PAGEFILE file_spec
X$!
X$!`009where:
X$!`009`009file_spec is the complete file specification of the .EXE image
X$!`009`009`009`009that you want to examine.
X$!
X$!`009pdc - 1/4/89
X$!
V$if p1 .eqs. "" then $goto no_file_found !if user did not tell what .EXE - ABOR
XT
X$set noverify
X$on control_y then $goto abort`009`009!escape valve...
X$on warning then $goto no_file_found`009!first set for bad .EXE filespec...
X$page_total = 0`009`009`009`009!total number of writable pages...
X$form_feed[0,32] = %x0C`009`009`009!say what a form-feed character is
X$anal/image/out=sys$login:anal_file_output.lis 'p1 !generate a report listing
X$on warning then $goto abort`009`009!from here on, should be no problems...
X$!
X$! Now we will open the anal/image file to see what it holds...
X$!
X$open/read/error=no_file_found anal_file sys$login:anal_file_output.lis
X$!
X$! The first order of duty is to locate an ISD section in the listing. Once it
X$!`009is found, then we examine what follows for the page count and the`032
X$!`009presence of the 'writable' flag. Note that we will also look for the
X$!`009sharable image list to be able to print it out here.
X$!
X$search_1:
X$read/end=no_more_recs anal_file input
X$if f$locate("image section descriptor",input) .ne. f$len(input) -
X`009`009then $goto found_isd
X$!
X$if f$locate("Shareable Image List",input) .ne. f$len(input) -
X`009`009then $goto found_share_images
X$!
X$goto search_1
X$!
X$! Now we have an ISD loop for processing
X$!
X$found_isd:
X$read/end=no_more_recs anal_file input`009`009!next line is the page count of
X$page_col = f$locate ("page count:",input)`009! this section...
V$if page_col .eq. f$len(input) then $goto found_isd  !if report header is in wa
Xy
X$page_cnt = f$extract (page_col+12,5,input)`009!get straight ascii characters
X$isd_loop1:
X$read/end=no_more_recs anal_file input`009`009!now we search for the`032
V$if f$locate("ISD$V_WRT",input) .ne. f$len(input) -  !  'writable' flag setting
X.
X`009`009then $goto found_wrt_flag
X$goto isd_loop1`009`009`009`009`009!back till the wrt flag bit
X$!
X$found_wrt_flag:
X$input = f$edit(input,"TRIM")`009`009`009!make sure we have it as needed
X$flag = 'f$extract(f$len(input)-1,1,input)'`009!get the flag bit...
X$if flag .eqs. "1" then -`009`009`009!if 'writable' then add it in!!
X     $page_total = page_total + 'f$integer(f$edit(page_cnt,"COLLAPSE,TRIM"))'
X$goto search_1`009`009`009`009`009!back for more ISD's...
X$!
X$! This is were we will list out to the terminal the list of sharable images
X$!`009that are used by the .EXE file under examination.
X$!
X$found_share_images:`009`009`009`009!first list out banner...
X$write sys$output f$edit(input,"COMPRESS")`009!trim to only one space/tab
X$found_share_images_1:
X$read/end=no_more_recs anal_file input`009`009!read next record...
X$input = f$edit (input,"TRIM")`009`009`009!get input down to size
X$if input .nes. form_feed then $goto found_share_images_2
X$read/end=no_more_recs anal_file input`009`009!We have to skip over the top
X$read/end=no_more_recs anal_file input`009`009! of the report headings, then
X$goto found_share_images_1`009`009`009! continue processing for lines.
X$!
X$found_share_images_2:
X$if input .eqs. "" then $goto found_share_images_1 !if nothing on line, go back
X$if f$locate(")  ",input) .eq. f$len(input) -
X`009`009then $goto end_of_shared_list`009!thats all for now...
X$write sys$output input`009`009`009`009!otherwise show who else is used
X$goto found_share_images_1`009`009`009!go back for next line
X$!
X$end_of_shared_list:
X$gosub page_cleanup
X$write sys$output "Total number of writable pages for image is: ''page_total'"
X$exit %x1
X$!
X$no_file_found:
X$write sys$output "Error - No input file found to examine"
X$exit %x0
X$!
X$no_more_recs:
X$gosub page_cleanup
V$write sys$output "Error - Unexpected EOF on input file during analysis. Aborti
Xng"
X$exit %x0
X$!
X$page_cleanup:
X$close anal_file
X$delete/noconfirm/nolog sys$login:anal_file_output.lis;*
X$return
X$!
X$abort:
X$set noon`009`009`009!continue here at ALL costs!!!
X$gosub page_cleanup`009`009!just to make sure...
X$exit %x0`009`009`009!blast out with warning...
$ GOSUB UNPACK_FILE
$ EXIT

