Oracle® Database Performance Tuning Guide 10g Release 2 (10.2) Part Number B14211-01 |
|
|
View PDF |
This chapter explains how to tune the operating system for optimal performance of the Oracle database server.
This chapter contains the following sections:
Finding System CPU Utilization
See Also:
Your Oracle platform-specific documentation contains tuning information specific to your platform. Your operating system vendor' s documentation should also be consulted.
"Operating System Statistics" for a discussion of the importance of operating system statistics
Operating system performance issues commonly involve process management, memory management, and scheduling. If you have tuned the Oracle instance and still need to improve performance, verify your work or try to reduce system time. Ensure that there is enough I/O bandwidth, CPU power, and swap space. Do not expect, however, that further tuning of the operating system will have a significant effect on application performance. Changes in the Oracle configuration or in the application are likely to result in a more significant difference in operating system efficiency than simply tuning the operating system.
For example, if an application experiences excessive buffer busy waits, then the number of system calls increases. If you reduce the buffer busy waits by tuning the application, then the number of system calls decreases.
This section covers the following topics related to operating system performance issues:
Operating systems and device controllers provide data caches that do not directly conflict with Oracle cache management. Nonetheless, these structures can consume resources while offering little or no benefit to performance. This is most noticeable on a UNIX system that has the database files in the UNIX file store; by default, all database I/O goes through the file system cache. On some UNIX systems, direct I/O is available to the filestore. This arrangement allows the database files to be accessed within the UNIX file system, bypassing the file system cache. It saves CPU resources and allows the file system cache to be dedicated to non-database activity, such as program texts and spool files.
This problem does not occur on Windows. All file requests by the database bypass the caches in the file system.
Although the operating system cache is often redundant because the Oracle buffer cache buffers blocks, there are a number of cases where Oracle does not use the Oracle buffer cache. In these cases, using direct I/O which bypasses the Unix or operating system cache, or using raw devices which do not use the operating system cache, may yield worse performance than using operating system buffering. Some examples include:
Reads or writes to the TEMPORARY
tablespace
Data stored in NOCACHE
LOBs
Parallel Query slaves reading data
You may want a mix with some files cached at the operating system level and others not.
With synchronous I/O, when an I/O request is submitted to the operating system, the writing process blocks until the write is confirmed as complete. It can then continue processing. With asynchronous I/O, processing continues while the I/O request is submitted and processed. Use asynchronous I/O when possible to avoid bottlenecks.
Some platforms support asynchronous I/O by default, others need special configuration, and some only support asynchronous I/O for certain underlying file system types.
You can use the FILESYSTEMIO_OPTIONS
initialization parameter to enable or disable asynchronous I/O or direct I/O on file system files. This parameter is platform-specific and has a default value that is best for a particular platform. It can be dynamically changed to update the default setting.
FILESYTEMIO_OPTIONS
can be set to one of the following values:
ASYNCH:
enable asynchronous I/O on file system files, which has no timing requirement for transmission.
DIRECTIO:
enable direct I/O on file system files, which bypasses the buffer cache.
SETALL:
enable both asynchronous and direct I/O on file system files.
NONE:
disable both asynchronous and direct I/O on file system files.
See Also:
Your platform-specific documentation for more detailsMemory usage is affected by both buffer cache limits and initialization parameters.
The UNIX buffer cache consumes operating system memory resources. Although in some versions of UNIX, the UNIX buffer cache may be allocated a set amount of memory, it is common today for more sophisticated memory management mechanisms to be used. Typically, these will allow free memory pages to be used to cache I/O. In such systems, it is common for operating system reporting tools to show that there is no free memory, which is not generally a problem. If processes require more memory, the memory caching I/O data is usually released to allow the process memory to be allocated.
The memory required by any one Oracle session depends on many factors. Typically the major contributing factors are:
Number of open cursors
Memory used by PL/SQL, such as PL/SQL tables
SORT_AREA_SIZE
initialization parameter
In Oracle, the PGA_AGGREGATE_TARGET
initialization parameter gives greater control over a session's memory usage.
Some platforms provide operating system resource managers. These are designed to reduce the impact of peak load use patterns by prioritizing access to system resources. They usually implement administrative policies that govern which resources users can access and how much of those resources each user is permitted to consume.
Operating system resource managers are different from domains or other similar facilities. Domains provide one or more completely separated environments within one system. Disk, CPU, memory, and all other resources are dedicated to each domain and cannot be accessed from any other domain. Other similar facilities completely separate just a portion of system resources into different areas, usually separate CPU or memory areas. Like domains, the separate resource areas are dedicated only to the processing assigned to that area; processes cannot migrate across boundaries. Unlike domains, all other resources (usually disk) are accessed by all partitions on a system.
Oracle runs within domains, as well as within these other less complete partitioning constructs, as long as the allocation of partitioned memory (RAM) resources is fixed, not dynamic.
Operating system resource managers prioritize resource allocation within a global pool of resources, usually a domain or an entire system. Processes are assigned to groups, which are in turn assigned resources anywhere within the resource pool.
Note:
Oracle is not supported for use with any UNIX operating system resource manager's memory management and allocation facility. Oracle Database Resource Manager, which provides resource allocation capabilities within an Oracle instance, cannot be used with any operating system resource manager.Caution:
When running under operating system resource managers, Oracle is supported only when each instance is assigned to a dedicated operating system resource manager group or managed entity. Also, the dedicated entity running all the instance's processes must run at one priority (or resource consumption) level. Management of individual Oracle processes at different priority levels is not supported. Severe consequences, including instance crashes, can result.See Also:
For a complete list of operating system resource management and resource allocation and deallocation features that work with Oracle and Oracle Database Resource Manager, see your systems vendor and your Oracle representative. Oracle does not certify these system features for compatibility with specific release levels.
Oracle Database Administrator's Guide for more information about Oracle Database Resource Manager
This section provides hints for tuning various systems by explaining the following topics:
Familiarize yourself with platform-specific issues so that you know what performance options the operating system provides.
See Also:
Your Oracle platform-specific documentation and your operating system vendor's documentationOn UNIX systems, try to establish a good ratio between the amount of time the operating system spends fulfilling system calls and doing process scheduling and the amount of time the application runs. The goal should be to run most of the time in application mode, also called user mode, rather than system mode.
The ratio of time spent in each mode is only a symptom of the underlying problem, which might involve the following:
Paging or swapping
Executing too many operating system calls
Running too many processes
If such conditions exist, then there is less time available for the application to run. The more time you can release from the operating system side, the more transactions an application can perform.
On Windows systems, as with UNIX-based systems, establish an appropriate ratio between time in application mode and time in system mode. You can easily monitor many factors with the Windows administrative performance tool: CPU, network, I/O, and memory are all displayed on the same graph to assist you in avoiding bottlenecks in any of these areas.
Consider the paging parameters on a mainframe, and remember that Oracle can exploit a very large working set.
Free memory in HP OpenVMS environments is actually memory that is not mapped to any operating system process. On a busy system, free memory likely contains a page belonging to one or more currently active process. When that access occurs, a soft page fault
takes place, and the page is included in the working set for the process. If the process cannot expand its working set, then one of the pages currently mapped by the process must be moved to the free set.
Any number of processes might have pages of shared memory within their working sets. The sum of the sizes of the working sets can thus markedly exceed the available memory. When the Oracle server is running, the SGA, the Oracle kernel code, and the Oracle Forms runtime executable are normally all sharable and account for perhaps 80% or 90% of the pages accessed.
To address CPU problems, first establish appropriate expectations for the amount of CPU resources your system should be using. Then, determine whether sufficient CPU resources are available and recognize when your system is consuming too many resources. Begin by determining the amount of CPU resources the Oracle instance utilizes with your system in the following three cases:
System is idle, when little Oracle and non-Oracle activity exists
System at average workloads
System at peak workloads
You can capture various workload snapshots using the Automatic Workload Repository, Statspack, or the UTLBSTAT
/UTLESTAT
utility. Operating system utilities—such as vmstat
, sar
, and iostat
on UNIX and the administrative performance monitoring tool on Windows—can be used along with the V$OSSTAT
or V$SYSMETRIC_HISTORY
view during the same time interval as Automatic Workload Repository, Statspack, or UTLBSTAT
/UTLESTAT
to provide a complimentary view of the overall statistics.
See Also:
Chapter 6, "Automatic Performance Diagnostics" for more information on Oracle tools
Workload is an important factor when evaluating your system's level of CPU utilization. During peak workload hours, 90% CPU utilization with 10% idle and waiting time can be acceptable. Even 30% utilization at a time of low workload can be understandable. However, if your system shows high utilization at normal workload, then there is no room for a peak workload. For example, Figure 9-1 illustrates workload over time for an application having peak periods at 10:00 AM and 2:00 PM.
This example application has 100 users working 8 hours a day. Each user entering one transaction every 5 minutes translates into 9,600 transactions daily. Over an 8-hour period, the system must support 1,200 transactions an hour, which is an average of 20 transactions a minute. If the demand rate were constant, then you could build a system to meet this average workload.
However, usage patterns are not constant and in this context, 20 transactions a minute can be understood as merely a minimum requirement. If the peak rate you need to achieve is 120 transactions a minute, then you must configure a system that can support this peak workload.
For this example, assume that at peak workload, Oracle uses 90% of the CPU resource. For a period of average workload, then, Oracle uses no more than about 15% of the available CPU resource, as illustrated in the following equation:
20 tpm / 120 tpm * 90% = 15% of available CPU resource
where tpm
is transactions a minute.
If the system requires 50% of the CPU resource to achieve 20 tpm, then a problem exists: the system cannot achieve 120 transactions a minute using 90% of the CPU. However, if you tuned this system so that it achieves 20 tpm using only 15% of the CPU, then, assuming linear scalability, the system might achieve 120 transactions a minute using 90% of the CPU resources.
As users are added to an application, the workload can rise to what had previously been peak levels. No further CPU capacity is then available for the new peak rate, which is actually higher than the previous.
CPU capacity issues can be addressed with the following:
Tuning, or the process of detecting and solving CPU problems from excessive consumption. See "Finding System CPU Utilization".
Increasing hardware capacity, including changing the system architecture
See Also:
"System Architecture" for information about improving your system architectureReducing the impact of peak load use patterns by prioritizing CPU resource allocation. Oracle Database Resource Manager does this by allocating and managing CPU resources among database users and applications in the following ways:
Limit number of active sessions for each Consumer Group
This feature is particularly important when a Consumer Group has a lot of parallel queries and you want to limit the total number of parallel queries.
CPU saturation
If the CPUs are running at 100%, Oracle Database Resource Manager can be used to allocate a minimum amount of CPU to sessions in each Consumer Group. This feature can lower the CPU consumption of low-priority sessions.
Runaway queries
Oracle Database Resource Manager can limit the damage from runaway queries by limiting the maximum execution time for a call, or by moving the long-running query to a lower priority Consumer Group.
See Also:
Oracle Database Administrator's Guide for more information about Oracle Database Resource ManagerEvery process running on your system affects the available CPU resources. Therefore, tuning non-Oracle factors can also improve Oracle performance.
Use the V$OSSTAT
or V$SYSMETRIC_HISTORY
view to monitor system utilization statistics from the operating system. Useful statistics contained in V$OSSTAT
and V$SYSMETRIC_HISTORY
include:
Number of CPUs
CPU utilization
Load
Paging
Physical memory
Operating system monitoring tools can be used to determine what processes are running on the system as a whole. If the system is too heavily loaded, check the memory, I/O, and process management areas described later in this section.
Tools such as sar
-u
on many UNIX-based systems allow you to examine the level of CPU utilization on your entire system. CPU utilization in UNIX is described in statistics that show user time, system time, idle time, and time waiting for I/O. A CPU problem exists if idle time and time waiting for I/O are both close to zero (less than 5%) at a normal or low workload.
On Windows, use the administrative performance tool to monitor CPU utilization. This utility provides statistics on processor time, user time, privileged time, interrupt time, and DPC time.
This section contains the following topics related to checking system CPU utilization:
Note:
This section describes how to check system CPU utilization on most UNIX-based and Windows systems. For other platforms, see your operating system documentation.Check the following memory management areas:
Thrashing is an I/O management issue. Ensure that your workload fits into memory, so the machine is not thrashing (swapping and paging processes in and out of memory). The operating system allocates fixed portions of time during which CPU resources are available to your process. If the process wastes a large portion of each time period checking to be sure that it can run and ensuring that all necessary components are in the machine, then the process might be using only 50% of the time allotted to actually perform work.
Check client/server round trips. There is an overhead in processing messages. When an application generates many messages that need to be sent through the network, the latency of sending a message can result in CPU overload. To alleviate this problem, bundle multiple messages together rather than perform lots of round trips. For example, you can use array inserts, array fetches, and so on.
Several process management issues discussed in this section should be checked.
The operating system can spend excessive time scheduling and switching processes. Examine the way in which you are using the operating system, because it is possible that too many processes are being used. On Windows systems, do not overload the server with too many non-Oracle processes.
Due to operating system specific characteristics, your system could be spending a lot of time in context switches. Context switching can be expensive, especially with a large SGA. Context switching is not an issue on Windows, which has only one process for each instance. All threads share the same page table.
Oracle has the several features for context switching, described in this section.
An Oracle process needs to be able to post another Oracle process (give it a message) and also needs to be able to wait to be posted.
For example, a foreground process may need to post LGWR to tell it to write out all blocks up to a given point so that it can acknowledge a commit.
Often this post-wait mechanism is implemented through UNIX Semaphores, but these can be resource intensive. Therefore, some platforms supply a post-wait driver, typically a kernel device driver that is a lightweight method of implementing a post-wait interface.
Oracle often needs to query the system time for timing information. This can involve an operating system call that incurs a relatively costly context switch. Some platforms implement a memory-mapped timer that uses an address within the processes virtual address space to contain the current time information. Reading the time from this memory-mapped timer is less expensive than the overhead of a context switch for a system call.
List I/O is an application programming interface that allows several asynchronous I/O requests to be submitted in a single system call, rather than submitting several I/O requests through separate system calls. The main benefit of this feature is to reduce the number of context switches required.
There is a high cost in starting new operating system processes. Programmers often create single-purpose processes, exit the process, and create a new one. Doing this re-creates and destroys the process each time. Such logic uses excessive amounts of CPU, especially with applications that have large SGAs. This is because you need to build the page tables each time. The problem is aggravated when you pin or lock shared memory, because you have to access every page.
For example, if you have a 1 gigabyte SGA, then you might have page table entries for every 4 KB, and a page table entry might be 8 bytes. You could end up with (1G / 4 KB) * 8 byte entries. This becomes expensive, because you need to continually make sure that the page table is loaded.