The Windows performance monitors are useful for tuning and diagnosing problems in your application or computer system. These include Performance Monitor under Windows NT and System Monitor under Windows 2000, Windows XP, and Windows Server 2003. By correlating the information from SAS counters with other operating environment counters, you can more easily troubleshoot performance problems.
For example, suppose that your SAS job appears not to be running. Perhaps the job is performing a long and complicated DATA step that generates a very large data set on a network drive. You can be certain that the job is still running by monitoring the Disk WriteFile Bytes Written/Sec and Disk WriteFile Bytes Written Total counters.
When you type perfmon in the Run dialog box, you open the Performance Monitor when you use Windows NT, and the Performance window when you use Windows 2000 and Windows XP.
You can also access the Performance Monitor and the Performance window from the Administrative Tools folder.
A counter is a piece of information that the system monitors. Performance objects represent individual processes, sections of shared memory, and physical devices, such as Memory and LogicalDisk. Counters are grouped by objects. For example, the Memory object contains counters such as Available Bytes, Committed Bytes, and Page Faults/ sec. The Processor object has counters such as %Processor Time and % User Time.
By observing various system counters and application-defined counters, you can determine performance problems. You can search for problems in your system and isolate them to areas such as hardware, system software, or your application. For more information about the Performance Monitor, see the Windows NT Resource Kit. For more information about the System Monitor, see the Windows 2000 Resource Kit and the Windows XP Resource Kit.
SAS includes the following application-defined counters in the SAS object:
Virtual Alloc ed Memory
specifies the amount of committed virtual memory that SAS allocates through the VirtualAlloc() API.
Disk ReadFile Bytes Read Total
specifies the total number of bytes that SAS reads from disk files through the ReadFile() API.
Disk ReadFile Bytes Read/Sec
specifies the number of bytes that SAS reads per second from disk files through the ReadFile() API.
Disk WriteFile Bytes Written Total
specifies the total number of bytes that SAS writes to disk files through the WriteFile() API.
Disk WriteFile Bytes Written/Sec
specifies the number of bytes that SAS writes per second to disk files through the WriteFile() API.
Disk SetFilePointer/Sec
specifies the number of times per second that SAS successfully calls the SetFilePointer() API on disk files.
Memlib/Memcache Current Usage K
specifies in bytes the amount of Extended Server Memory that is currently in use.
Memlib/Memcache Peak Usage K
specifies in bytes the maximum amount of Extended Server Memory that is used in the current SAS session.
Use the following procedures to monitor SAS counters in your respective operating environment:
Using Windows NT | Using Windows 2000 and Windows XP |
---|---|
|
|
The performance monitor immediately collects and displays information about the counters that you selected.
Multiple SAS counters may be monitored. You may see multiple instances monitored , where each instance is a separate SAS process. SAS instances are listed in the form SAS PID number . The PID number is the process identifier of the SAS session. You can see a list of all processes by using the Task Manager.
Configure the Performance Monitor and the System Monitor for all examples as follows :
Invoke SAS and the Performance Monitor or the System Monitor.
Open the Add Chart window or the Add Counters window and select the SAS object.
Add these SAS counters:
Disk ReadFile Bytes Read/Sec
Disk WriteFile Bytes Written/Sec
Disk SetFilePointer/Sec
Select the Process object.
Add these Process counters:
%Processor Time
%User Time
%Privileged Time
Click Done or Close .
To see the difference in performance between the DATA step and the PROC step, submit this code:
options fullstimer; /* Create a test data set with some random data. */ DATA a (drop=s); do i = 1 to 500000; x = ranuni(i); y = x*2; z = exp(x*y); output; end; /* The sleep helps to delineate the subsequent */ /* sort in the Performance Monitor graph */ s = sleep(15); run; PROC sort data = a noduplicates; by z y x i; run;
After you submit this code, the Performance Monitor or System Monitor will generate results similar to those in Display 9.2 on page 229. You might have to adjust the scale factor of the different counters.
The DATA step in the display shows that there is very little activity from Disk ReadFile Bytes Read/Sec or Disk SetFilePointer/Sec. Notice that in the subsequent PROC SORT output there is much more activity from these two counters. This indicates that the data set is being read (Disk Readfile Bytes Read/Sec) in order to be sorted, and that a certain amount of random I/O is performed by the sort (Disk SetFilePointer/Sec).
The pause in the activity is caused by the SLEEP function that follows the DATA step. The Disk WriteFile Bytes Written/Sec counter is active in both the DATA step and in the PROC SORT step.
Finally, you can correlate the counters from the Process object with the user and system CPU times in your SAS log.
To examine the performance of a PROC SQL query with an index, submit this following code:
Submit the code in Step 1 and Step 2. Step 2 creates an index.
/* Step 1 */ /* Create a test data set with some random data. */ /* Do this twice - once with Step 2 and once */ /* without Step 2. */ libname sample 'c:\'; DATA sample.a; do i = 1 to 500000; x = ranuni(i); y = x*ranuni(i); z = exp(y); output; end; run; /* Step 2 */ /* Create a simple index on variable x. */ /* Submit this step once. */ PROC DATASETS library = sample; modify a; index create x; quit;
Clear the graph by selecting Clear Display from the Edit menu or the Clear Display toolbar button.
Submit the code in Step 3 to see a graph such as Display 9.3 on page 231.
/* Step 3 */ /* Perform a query on the data. Do this twice - */ /* once with an index and once without an index */ /* The query should select about 50% of the */ /* observations in the data set. */ PROC SQL; create table sample.yz as select y,z from sample.a where x > 0.5; quit;
Display 9.3: Performance of PROC SQL Query with an Index
To perform a PROC SQL query without an index:
Resubmit Step 1.
Clear the graph.
Resubmit Step 3 to see a graph such as Display 9.4 on page 231.
Display 9.4: Performance of PROC SQL Query without an Index
In Display 9.4 on page 231, the counters averaged under 10% on the scale, whereas in Display 9.3 on page 231, several of the counters averaged more than 10%, and the Disk WriteFile Bytes Written/Sec counter rose more than 25%. A higher value for these counters implies good overall throughput for the operation.
Note that to make a valid comparison like this with the Performance Monitor graph or with the System Monitor graph, you must ensure that the counters are using the same scale. You can confirm this by observing the absolute values. The Average value for Disk WriteFile Bytes Written/Sec in Display 9.3 on page 231 was 92528.953. Contrast this with the same counter in Display 9.4 on page 231, in which the Average value was 47350.902. For this operation, bytes were written almost twice as fast when the data set was indexed.