Techniques for Optimizing Memory Usage
System Options
If memory is a critical resource, several techniques can reduce your dependence on
increased memory. However, most of them also increase I/O processing or CPU usage.
You can use the MEMSIZE= system option to increase the amount of memory available
to SAS and therefore decrease processing time. By increasing memory, you reduce
processing time because the amount of time spent on paging, or reading pages of data
into memory, is reduced.
The SORTSIZE= and SUMSIZE= system options enable you to limit the amount of
memory that is available to sorting and summarization procedures.
You can also make tradeoffs between memory and other resources, as discussed in
“Reducing CPU Time By Modifying Program Compilation Optimization” on page 205.
To use the I/O subsystem most effectively, you must use more and larger buffers.
However, these buffers share space with the other memory demands of your SAS
session.
Operating Environment Information
The MEMSIZE= system option is not available in some operating environments. If
MEMSIZE= is available in your operating environment, it might not increase
memory. See the documentation for your operating environment for more
information.
Using the BY Statement with PROC MEANS
When you use the CLASS statement and class variables in PROC MEANS, the memory
requirements can be substantial. SAS keeps a copy of unique values of each class
variable in memory. If PROC MEANS encounters insufficient memory for the
summarization of all class variables, you can save memory by using the CLASS and BY
statement together to analyze the data by classes.
For more information, see “Comparison of the BY and CLASS Statements” in Base SAS
Procedures Guide.
Techniques for Optimizing CPU Performance
Reducing CPU Time By Using More Memory or Reducing I/O
Executing a single stream of code takes approximately the same amount of CPU time
each time that code is executed. Optimizing CPU performance in these instances is
usually a tradeoff. For example, you can reduce CPU time by using more memory. This
allows more information to be read and stored in one operation. However, less memory
is available to other processes.
Also, because the CPU performs all the processing that is needed to perform an I/O
operation, an option or technique that reduces the number of I/O operations can also
have a positive effect on CPU usage.
204 Chapter 12 Optimizing System Performance
Storing a Compiled Program for Computation-Intensive DATA Steps
Another technique that can improve CPU performance is to store a DATA step that is
executed repeatedly as a compiled program rather than as SAS statements. This is
especially true for large DATA step jobs that are not I/O-intensive. For more information
about storing compiled DATA steps, see Chapter 28, “Stored Compiled DATA Step
Programs,” on page 679.
Reducing Search Time for SAS Executable Files
The PATH= system option specifies the list of directories (or libraries, in some operating
environments) that contain SAS executable files. Your default configuration file
specifies a certain order for these directories. You can rearrange the directory
specifications in the PATH= option so that the most commonly accessed directories are
listed first. Place the least commonly accessed directories last.
Operating Environment Information
The PATH= system option is not available in some operating environments. See the
documentation for your operating environment for more information.
Specifying Variable Lengths
When SAS processes the program data vector, it typically moves the data in one large
operation rather than by individual variables. When data is properly aligned (in 8-byte
boundaries), data movement can occur in as little as two clock cycles (a single load
followed by a single store). SAS moves unaligned data by more complex means, at
worst, a single byte at a time. This would be at least eight times slower for an 8-byte
variable.
Many high-performance RISC (Reduced Instruction Set Computer) processors pay a
very large performance penalty for movement of unaligned data. When possible, leave
numeric data at full width (eight bytes). Note that SAS must widen short numeric data
for any arithmetic operation. On the other hand, short numeric data can save both
memory and I/O. You must determine which method is most advantageous for your
operating environment and situation.
Note: Alignment can be especially important when you process a data set by selecting
only specific variables or when you use WHERE processing.
Using Parallel Processing
SAS System 9 supports a new wave of SAS functionality related to parallel processing.
Parallel processing means that processing is handled by multiple CPUs simultaneously.
This technology takes advantage of SMP computers and provides performance gains for
two types of SAS processes: threaded I/O and threaded application processing.
For information, see Chapter 13, “Support for Parallel Processing,” on page 207.
Reducing CPU Time By Modifying Program Compilation
Optimization
When SAS compiles a program, the code is optimized to remove redundant instructions,
missing value checks, and repetitive computations for array subscripts. The code detects
Techniques for Optimizing CPU Performance 205
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.171.212