Windows Features That Optimize Performance

Controlling SAS Responsiveness

Overview of Controlling SAS Responsiveness

You can control the relative responsiveness of your SAS session by altering the application performance level. Using Windows performance options, you can specify which type of programs, interactive or background, receive more processor time. Use these guidelines to determine the application performance level:
  • If you are running SAS interactively and you want your session to have the best response time, set the performance options for programs or applications.
  • If you are running SAS in batch mode and you want your batch jobs to execute more quickly, set the performance options for background services.
To analyze the performance of your SAS applications, you can specify SAS performance counters within the Windows performance monitor. For more information, see Performance Tools .

Optimizing Application Performance under Windows

Under Windows, follow these steps to optimize application performance:
  1. Open the Control Panel.
  2. Click System and Security.
  3. Select the System.
  4. Click Advanced system settings task.
  5. Select the Advanced tab.
  6. In the Performance box, click Settings and then select the Advanced tab.
  7. To optimize performance of an interactive SAS session, select Programs.
  8. To optimize performance of a batch SAS session, select Background services.
  9. Click OK.

I/O Enhancements for Multiple Processors

If your PC has multiple processors, SAS uses symmetric multiprocessing (SMP) using I/O enhancements. More read-ahead processing is done for procedures that have large amounts of sequential data access on data that is stored on a Windows server. This processing occurs more on systems that have extra processing power to serve Windows and its disk cache.
The following is generally true in multiprocessing SMP environments:
  • Machines that are used as servers for multiple applications perform best if they are SMP-based.
  • SAS/CONNECT remote computing environments perform best if they are SMP-based.

Memory-Based Libraries

Memory-Based Libraries Overview

Using the MEMLIB and MEMCACHE options, you can create memory-based SAS libraries. Depending on your operating environment, extended memory or conventional memory is used to support these memory-based libraries.
In Windows operating environments, 32-bit processing uses 2 gigabytes (GB) of physical memory for the operating environment, and the remaining 2 GB of physical memory is available for use by applications. When a PC or server has more than 4 GB of memory, extended memory is defined as the memory that is above 4 GB. Memory is available for use by applications. Extended memory can be used to support memory-based libraries.
Some Windows operating environments do not support extended memory. In operating environments where extended memory is not supported or installed, SAS uses conventional memory to support the MEMLIB and MEMCACHE options. Conventional memory is defined as the memory that is below 4 GB in 32-bit environments and all of the memory in 64-bit environments.
Using memory-based libraries reduces I/O to and from disk, therefore improving SAS performance. Memory-based libraries can be used in several ways:
  • as storage for the Work library
  • for processing SAS libraries that have a high volume of input and output
  • as a cache for very large SAS libraries
After you have completed the setup for your operating environment, use the MEMLIB and MEMCACHE system options and the MEMLIB option in the LIBNAME statement to access memory-based libraries.

Specifying the MEMLIB and MEMCACHE Options in 64-Bit Windows Environments

Sixty-four bit processing in Windows operating environments uses 16 terabytes (TB) of virtual address space, so in these environments, extended memory is not needed. SAS uses the conventional memory that is available to support the MEMLIB and MEMCACHE options.
It is possible to exhaust system memory and thus cause system failure.
You can use the MEMMAXSZ option to limit the amount of system memory that SAS allocates for the MEMLIB and MEMCACHE options.
To use the MEMLIB and MEMCACHE options, ensure that the operating environment meets the following requirements:
  • an Intel 64-bit processor or 64-bit processor that is compatible with Intel.
  • Any 64-bit version of Windows.
  • 4 GB of RAM or more; you might have better performance if you use more than 8 GB.
  • SAS 9.4 for Windows.
Then follow these steps:

Processing SAS Libraries as Memory-Based Libraries

SAS libraries that are well suited for memory-based processing have data that is referenced or updated multiple times within a SAS session.
Using a Work library that is memory-based is beneficial for procedures such as PROC SORT that write multiple times to large temporary files. To designate the Work library as memory-based, specify the MEMLIB system option when you start SAS.
You designate a library as memory-based by using the MEMLIB option in the LIBNAME statement. All librefs, including a libref to the Work directory, must have a valid disk directory.
After the library is designated as memory-based, your SAS program needs to copy the library from disk to memory. After processing the library in memory, the library must be copied back to disk.
Copy the library that is in memory to disk after processing is complete.
If you do not, you lose any changes that were made to the library. The changes are lost when the SAS session ends
The following example shows how to use the LIBNAME statement and the PROC COPY statement to copy a library to and from memory.
/* Set up two librefs, one to the library in memory
and the other to the SAS library on disk.  The library on 
disk contains dataset1, dataset2, dataset3 and dataset4. */

libname inmemory “g:\memlib” memlib;
libname ondisk “g:\disk”;

/* Copy dataset1, dataset2, dataset3, and dataset4 to memory   */

proc copy in=ondisk out=inmemory;

/* ...Assume dataset1 and dataset4 are updated   */

/* Save the updated datasets back to disk         */

proc copy in=inmemory out=ondisk;
   select dataset1 dataset4;
You can also copy a data set to memory by using a DATA statement, as shown in the following example:
data ondisk.dataset1;
   set inmemory.dataset1;
For more information, see MEMLIB System Option: Windows and the LIBNAME Statement: Windows .

Using a Memory-Based Library as a SAS File Cache

A SAS file cache is most useful in multiple references of data. For example, a SAS file cache improves performance in SAS programs that make multiple passes of the data. SAS file caching improves performance in the following situations:
  • Repeated Read operations of a file while other files are being written. Writing to a file clears the Windows file system (NTFS) cache.
  • Repeated Read operations of a file when Scatter Gather I/O is active. Scatter Gather I/O operates outside the NTFS cache. Without the SAS file cache, there is no data cache and all Read operations access the disk.
To use memory as a SAS file cache, specify the MEMCACHE system option when you start SAS or when you submit an OPTIONS statement. If you set MEMCACHE to 4, SAS uses the memory to cache all files. If you set MEMCACHE to 1, only files that are currently in memory are cached to memory. When you use the MEMCACHE system option in the OPTIONS statement, you can control which data sets use the SAS file cache, as shown in the following example.
/* Example of controlling cached files with the options statement   */

/* Assume cachelib contains 2 data sets, ds1 and ds2.               */
/* Also assume ds1 and ds2 are large enough that they cannot exist */
/* in the cache together. ds1 is read many times, so caching is     */
/* desired. ds2 is accessed only once, so caching is of no         */
/* benefit.  When you use the memcache option, ds1 is cached, and ds2   */
/* is not cached.                                                      */

libname cachelib "e:\tmp";

/* Turn on full caching */

options memcache = 4;

/* Read ds1 and place the data in the cache.  This read operation could be a  */
/* more useful read operation of the file in a real case.               */

data _null_;
  set cachelib.ds1;

/* Change memcache setting to use the cache only for files that   */
/* already exist in the cache.                                    */

options memcache = 1;

/* Data from ds1 will come from the cache and ds2 will not be     */
/* cached.                                                        */

proc sort data=cachelib.ds1 out=cachelib.ds2;
  by j;

/* Other access of ds1...                                         */

/* All use of the cache can be ended with a memcache system       */
/* option value of 0.                                             */

options memcache = 0;

/* Neither ds1 or ds2 will access the cache.                      */

proc sort data=cachelib.ds1 out=cachelib.ds2;
  by j;
For more information about the MEMCACHE system option, see MEMCACHE System Option: Windows . For more information about Scatter Gather I/O, see SAS Features That Optimize Performance and SGIO System Option: Windows .