Contained Within
Find More Documentation
Featured Support Resources
| Scarica il manuale in formato PDF
Introduction to Performance
6
- Getting good performance from a computer or network is an important part of system administration. This chapter is an overview of some of the factors that contribute to maintaining and managing the performance of the computer systems in your care.
-
Note - The chapters on system performance in this book contain information about SunOS 5.3 system software with specific references to SunOS 5.4 system software noted.
About Performance
- The performance of a computer system depends on how the system uses and allocates its resources. It is important to monitor your system's performance on a regular basis so that you know how it behaves under normal conditions. You should have a good idea of what to expect, and be able to recognize a problem when it occurs.
- Several tools are available that gather and display important data about your system. The sadc and sar utilities sample and report on various system-wide activities. Chapter 8, "Monitoring Performance," describes how to use these commands and explains the information they provide.
- The performance of a network depends not only on the individual systems that make up the network, and on the interrelations among them. Any member of the network, or the physical components of the network itself, including the
- cables and connectors, can have an impact on the performance of the network as a whole. Discovering and isolating problems can sometimes involve a great deal of detective work. Chapter 9, "A Guide to Network Performance," describes some of the tools that you can use to track down and investigate the cause of a network slowdown.
Managing System Resources
- The performance of a computer system depends upon how the system uses and allocates its resources. System resources include:
-
-
Central processing unit (CPU) - The CPU processes instructions, fetching instructions from memory and executing them.
-
Input/output (I/O) devices - I/O devices transfer information into and out of the computer. Such a device could be a terminal and keyboard, a disk drive, or a printer.
-
Memory - Physical (or main) memory is the amount of memory (RAM) on the system.
-
Chapter 8, "Monitoring Performance," describes the tools that display statistics about the activity and the performance of the computer system.
Managing Processes
- You can use the timex command to report the amount of time it takes for a command to be executed, and which resources the command uses during its execution. For example, using timex on the sleep command produces:
-
% timex sleep 20
real 20.60
user 0.04
sys 0.37
|
- The sleep command suspends execution for a specified number of seconds. The example shows that it took a total of 20.60 seconds to execute the command. However, the actual CPU time was a total of 0.41 seconds--0.04 seconds devoted to executing the code, and 0.37 seconds used by the operating system on behalf of the program. The rest of the time was spent idle (sleeping).
- The timex command can also report the operating system activities that occurred while the command was being executed. If no other processes are running, timex can give you a good idea of which resources a specific command uses during its execution. You can collect a record of CPU consumption for each application program and then use this information to tune the heavily loaded resources.
- The kernel is responsible for allocating the CPU time, which it does according to a set of policies. The policies determine the order in which processes are executed and the amount of CPU time they are allotted. A large number of processes contending for the CPU can slow down the system to unacceptable performance.
- One way to help an overloaded CPU is to spread out the workload. You can, for example, run a CPU-intensive program at night, or at an hour when the system is not busy. Use the at command to submit a command or application for execution at a later time. See the reference page for at(1) for a description of this command.
- Using at, you can specify an hour, such as 0100 (which means 1 a.m.), when you want the commands to be executed.
- Use the -f option to specify a script that contains a list of commands to be executed. Or, you can list the commands, ending with Control-d.
- Use the -r option to cancel jobs that you previously scheduled with at. The -r option takes the job number as an argument. Type at -l to find the job number of a previously scheduled job.
- The following example submits three commands to be executed at 5:05 p.m.
-
mysys% at 1705
at> command1
at> command2
at> command3
at> Control-D
warning: commands will be executed using /usr/bin/sh
job 763689900.a at Mon Mar 14 17:05:00 1994
mysys%
|
Managing Disk I/O
- The disk is used to store data and instructions used by your computer system. You can examine how efficiently the system is accessing data on the disk by looking at the disk access activity and terminal activity. See Chapter 8, "Monitoring Performance," for a discussion of the iostat and sar commands, which report statistics on disk activity. Managing and allocating disk space and partitioning your disk, are discussed in File System Administration.
-
Improving and Controlling File-System Use One of the biggest problems you can encounter with your system is running out of disk space. To avoid file-system space problems, you should try to monitor the amount free disk space at the start of each week to determine whether the system has enough disk space for what your users and applications normally generate in a week.
- See File System Administration for a discussion of planning ufs file systems.
-
Checking for Disk Slowdowns If the CPU spends much of its time waiting for I/O completions, there is a problem with disk slowdown. Some ways to prevent disk slowdowns are:
-
- Keep disk space with 10% free so file systems are not full. If a disk becomes full, back up and restore the file systems to prevent disk fragmentation. Consider purchasing products that resolve disk fragmentation.
- Organize the file system to minimize disk activity. If you have two disks, distribute the file system for a more balanced load. Using Sun's Online: DiskSuite(TM) product provides more efficient disk usage.
- Add more memory. Additional memory reduces swapping and paging traffic, and allows an expanded buffer pool (reducing the number of user-level reads and writes that need to go out to disk).
- Add a disk and balance the most active file systems across the disks.
Managing Memory
- Performance suffers when the programs running on the system require more physical memory than is available. When this happens, the operating system begins paging and swapping.
-
Paging involves moving pages that have not been recently referenced to a free list of available memory pages. Most of the kernel resides in main memory and is not pageable.
-
Swapping occurs if the page daemon cannot keep up with the demand for memory. The swapper will attempt to swap out sleeping or stopped lightweight processes (LWPs). If there are no sleeping or stopped LWPs, the swapper will swap out a runnable process. The swapper will swap LWPs back in based on their priority. It will attempt to swap in processes that are runnable.
- Paging and swapping of pages is costly in both disk and CPU overhead.
- See Chapter 7, "Managing Processes," for a discussion of process terminology.
-
Adding Swap Space Swap areas are really file systems used for swapping. Swap areas should be sized based on the requirements of your applications. Check with your vendor to identify application requirements.
-
Table 6-1 describes the formula used to size default swap areas by the Solaris 2.x installation program. These default swap sizes are a good place to start if you are not sure how to size your swap areas.
-
Table 6-1
| If Your Physical Memory Size Is... | Your Default Swap Size Is... |
| 16-64 Mbytes |
| 32 Mbytes |
| 64-128 Mbytes |
| 64 Mbytes |
| 128-512 Mbytes |
| 128 Mbytes |
| greater than 512 Mbytes |
| 256 Mbytes |
- See File System Administration for information about managing swap space.
-
Buffer Resources The buffer cache for read(2) and write(2) system calls uses a range of virtual addresses in the kernel address space. A page of data is mapped into the kernel address space and the amount of data requested by the process is then physically copied to the process' address space. The page is then unmapped in the kernel. The physical page will remain in memory until the page is freed up by the page daemon.
- This means a few I/O-intensive processes can monopolize or force other processes out of main memory. To prevent monolopization of main memory, balance the running of I/O-intensive processes serially in a script or with the at(1) command. Programmers can use mmap(2) and madvise(3) to ensure that their programs free memory when they are not using it.
Monitoring Tools
- The Solaris 2.x system software provides several tools to help you keep track of how your system is performing. These include:
-
- The sar and sadc utilities, which collect and report on many aspects of system activity. Chapter 8, "Monitoring Performance," describes these utilities and the information that they provide.
- The ps command, which provides information about the active processes; Chapter 7, "Managing Processes," describes the ps command.
- The performance meter, which provides a graphical representation of the status of your system and other hosts on the network; Chapter 8, "Monitoring Performance," describes the performance meter.
- The vmstat and iostat commands, which summarize system activity, providing information about virtual memory activity, disk usage, and CPU activity; Chapter 8, "Monitoring Performance," describes these tools.
- The swap command, which can be used to display information about available swap space on your system. See File System Administration for information on using the swap command.
- The netstat and nfsstat commands, which display information about network performance. Chapter 9, "A Guide to Network Performance," describes these commands.
Kernel Parameters
- Many basic parameters (or tables) within the kernel are calculated from the value of the maxusers parameter. Tables are allocated space dynamically. However, you can set maximums for these tables to ensure that applications won't take up large amounts of memory.
- By default, maxusers is approximately set to the number of Mbytes of physical memory on the system. However, the system will never set maxusers higher than 1048.
- See Appendix A, "Tuning Kernel Parameters," and the reference page for system(4) for details on kernel parameters.
- In addition to maxusers, a number of kernel parameters are allocated dynamically based on the amount of physical memory on the system, as shown in Table 6-2 below.
-
Table 6-2
| Kernel Parameter Description |
| ufs_ninode...The maximum size of the inode table
ncsize.....The size of the directory name lookup cache
max_nprocs...The maximum size of the process
ndquot.....The number of disk quota structures
maxuprc....The maximum number of user processes per user-id
Table 6-3 lists the default settings for kernel parameters affected by the value assigned to maxusers.
Table 6-3 Default Settings for Kernel Parameters
|
-
| Kernel Table | Variable | Default Setting |
| Inode | ufs_ninode | max_nprocs + 16 + maxusers + 64 |
| Name cache | ncsize | max_nprocs + 16 + maxusers + 64 |
| Process | max_nprocs | 10 + 16 * maxusers |
| Quota table | ndquot | (maxusers * NMOUNT) / 4 + max_nprocs |
| User process | maxuprc | max_nprocs - 5 |
- See Appendix A, "Tuning Kernel Parameters," for a description of the kernel parameters and how to change the default values.
Sources of Information
- Performance is a broad subject that can't be adequately covered in these chapters. There are several books available that cover various aspects of improving performance and tuning your system or network. Three useful books are:
-
-
Sun Performance and Tuning: SPARC and Solaris, by Adrian Cockcroft, SunSoft Press/PRT Prentice Hall, ISBN 0-13-149642-3
-
System Performance Tuning, by Mike Loukides, O'Reilly & Associates, Inc.
-
Managing NFS and NIS, by Hal Stern, O'Reilly & Associates, Inc.
|
|