Consultor Eletrônico



Kbase P19568: Why and how to use a procedure library
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/30/2009
Status: Verified

GOAL:

Why and how to use a procedure library.

FACT(s) (Environment):

Progress 8.3x
Progress 9.x
OpenEdge 10.x
All Supported Operating Systems

FIX:

Using procedure library will improve the performance in accessing your compiled Progress programs.

PROLIB is the command to use for creating/maintaining Progress procedure libraries.
PROGRESS applications that use many compiled .r files cause the system to search the native file system for the .r files whenever these files are referenced. For large applications, this results in large directories, long search times for each R-code file, and many (expensive) open/close operations on each file as it is used. This can result in a heavy performance penalty for larger applications with many separate R-code files. PROLIB is a facility that groups many R-code files into a single file (called a library) where PROGRESS can look to find R-code files. Having a single place to look for R-code files eliminates the large directory and open/close issues, since the library can open once and allow for faster searches. There can be more than one active library, since libraries are specified in the PROPATH variable (discussed later). In addition, the temporary sort files that are used to hold R-code that has been "swapped-out" of memory can be reduced in size, since R-code read in from a library can easily be reread from the same library.

PROLIB COMPONENT
================
PROLIB is a stand-alone utility. The syntax is:

PROLIB <library-name>.pl <command> [<command>...]

where <library-name> is the name of the library and has a .pl extension, and <command> is any of the commands listed below.
Use the .pl extension on the library name so that PROGRESS can detect a library on the PROPATH by just examining its extension.
Commands that can be used with the PROLIB utility are:

1. -create
Creates a new library. It generates an error if the library already exists, unless -nowarn is specified (see below).

2. -add file [file...]
Adds the specified files to the library. A file may not appear in the library more than once. If an error occurs that causes the PROLIB command containing the -add to fail, the resulting library is still correct, but may seem larger than it should be. This is the result of the new file actually being added to the end of the library file, without the directory being updated. (So, even though the bytes of the new file are in the library, the library doesn't know it). Running PROLIB with the -compress option will fix this (see below).

3. -replace file [file...]
Replaces the specified file in the library. If you attempt to replace a file that isn't already in the library, you get an error (unless -nowarn is specified, see below).

4. -delete file [file...]
Deletes the specified files from the library.

5. -list [file...]
Lists the table of contents of the library, as well as some other information about the library. The listing is sorted by file name, and dates display in the format specified by the -date command.

6. -date date-format
Specifies the format of the date to use in displaying file time stamps in the -list command. The format of "date-format" is the same as that of the -d switch in PROGRESS. The default value is "mdy".

7. -extract file [file...]
Extracts the named files from the library. The files are copied from the library into files with the same names that they were entered with. If PROLIB tries to extract a file that would go in a directory that doesn't exist, it prompts for a name that the file should be extracted as. Files extracted retain the same modification time that they had when they were added to the library, and the access time is set to the time stamp of when the file was added to the library, on operating systems that support this functionality. If a file being extracted already exists outside of the library, it warns of this and prompts for an action (overwrite, rename, quit), unless you use -nowarn (see below).

8. -nowarn
This option, which takes effect fo.r all commands on the command line, causes the -add, -replace, -extract, -delete, and -create options to do their work silently as described above.

9. -yank
This option works exactly like -extract except that any leading pathname component is stripped off so that the resulting file is placed in the current working directory.

10. -compress
Compresses the library by making a copy of it. The -compress option creates a temp file named PLBXXXXXX (where the X's are replaced by some number) in the current directory to accomplish the compression.

11. -f file
This command allows you to supply command-line arguments in a file. The contents of the specified file are inserted in the command line replacing the"-f file" command. This allows you to specify commands that would normally overflow the system command line length limits. A file of command line arguments cannot itself contain a -f command.

12. -verbose
Normally, PROLIB does its work silently. This command directs PROLIB to tell you what's being done as it's happening. This is reassuring if you're doing multiple -add's (or -create's, or -extract's) and want to be sure something is actually
taking place.


PROGRESS COMPONENT
==================
PROGRESS has been modified to search for R-code files in a library.
PROGRESS will not look for source code in a library. So, the PROPATH variable can contain directory names, as well as library names.
Libraries can be named as fully qualified file names, partially qualified file names, or as simple file names.
All libraries must have a ".pl" extension.

For those of you using networks, and whose libraries are on the file servers, there is a PROGRESS switch (-pls) that directs PROGRESS to use the conventional sort file technique for library-based procedures. This way, if you have a local disk or a RAM-disk that holds the sort file, it is faster to use the sort file than to do the remote file server accesses to the library.

Since using a library consumes available memory by keeping the library available in memory, you may want to opt for reading the library directory in from disk as needed, trading off some speed for memory availability. The PROGRESS switch -plm causes
PROGRESS to use a 512 byte cache for the library directory, rather than reading the entire directory in from memory.

If the PROPATH environment variable is changed during a PROGRESS session, then any libraries that appeared on the old PROPATH but not on the new one are closed. Any libraries that were on the old PROPATH and the new one remain open.

Libraries are only opened as needed. If all requests for R-code files are satisfied by directories earlier on the PROPATH than any libraries, then no libraries are opened.


ISSUES
======
1. The PROGRESS "SEARCH" function returns the full path of a file that may be found in a directory on the PROPATH. The syntax is:
SEARCH("pgm-name").

The function: name = SEARCH("dict.r") sets 'name' equal to: "/usr/dlc/dictionary.pl<<dict.r>>" where 'dictionary.pl' is the library containing the dictionary procedures.

2. The PROGRESS "LIBRARY" function takes a character string argument and either return the library name that the string mentions, or the unknown value if the argument doesn't denote a library. In the above example, LIBRARY(name) would return "/usr/dlc/dictionary.pl".

3. The PROGRESS MEMBER function returns the member for a name.
In the above example, MEMBER(name) would return "dict.r".

4. In PROGRESS, do not change the PROPATH during program execution such that a library is removed form the PROPATH that contains a file that is currently active (i.e. contains a procedure that is currently running or is waiting for a subprocedure to return).

5. If a library is opened indirectly., that is via a SEARCH or RUN statement that generates a library name that is not on the PROPATH, then that library will stay open forever (or until the PROGRESS session is terminated).


MEMORY IMPACT
=============
Using the library requires memory for the library directories, which are dynamically allocated. The command line switch "-plm" allows you to opt for having the library directories cached in small chunks (rather than being read in in their entirety) in the event that PROGRESS fails due to memory shortage when a library is used. This cache incurs a 512 byte overhead..