Performance counters (counter) are some data metrics that describe the performance of a server or operating system. Counter plays a key role in performance testing, especially in analyzing the scalability of the system and locating the performance bottleneck, the analysis of the counter value is very important. However, it must be stated that a single performance counter can only reflect one aspect of system performance, and analysis of performance test results must be based on a number of different counters.
Another term related to performance counters is resource utilization. This term refers to the use of various resources of the system. In order to facilitate comparison, the general use of "resources of actual use/total resources available" to form a resource utilization data for the use of various resources to compare.
Memory of performance test (Windows)
To monitor low-memory conditions, start with the following object counters:
· Memory\ Available Bytes
· Memory\ pages/sec
Available bytes The remaining available physical memory in megabytes (reference: >=10%). Indicates the current number of bytes of memory that the process can use. Pages/sec indicates the number of pages fetched from disk due to hardware page faults, or the number of pages written to disk due to a page fault to free [url=] work [/url] Set space.
If the value of Available Bytes is small (4 MB or less), the total memory on the computer may be insufficient, or a program does not release memory. If the value of PAGES/SEC is 20 or greater, you should study the page Exchange activity further. A large value of pages/sec does not necessarily indicate a memory problem, but may be caused by a program running a memory-mapped file.
The operating system often uses disk swapping to increase the amount of memory available to the system or improve the efficiency of memory usage. The following four metrics directly reflect the frequency of disk swapping by the operating system. Page FAULTS/SEC when the processor reads a page in memory, an error occurs, which is page Fault. If this page is located elsewhere in memory, this error is called a soft error, measured with transition fault/sec, and if the page is on a hard disk and must be re-read from the hard disk, this error becomes a hard error. A hard error can make the system run more efficiently and quickly. Page Faults/sec This counter represents the number of error pages processed per second, including hard and soft errors. Page Input/sec represents the number of pages written to the hard disk in order to resolve a hard error (reference value: >=page reads/sec) page Reads/sec represents the pages read from the hard disk in order to resolve a hard error. (Reference: <=5) pages/sec indicates the number of pages read from or written to the hard disk in order to resolve a hard error (reference value: 00~20)
The Available Bytes, Pages/sec, and Paging File% Usage must be monitored at the same time to determine if this happens. If you are reading a non-cached memory-mapped file, you should also see if the cache activity is healthy.
Cathe Bytes File system cache (default is 50% of available physical memory)
Memory leaks
· Memory\Available Bytes
· Memory\ Committed Bytes
If you suspect a memory leak, monitor the memory\available Bytes and memory\ Committed Bytes to observe the memory behavior and monitor the process\ Private Bytes of the process you think might be leaking memory, Process\ working Set and Process\ Handle Count. If you suspect that a kernel-mode process is causing the leak, you should also monitor Memory\ Pool Nonpaged Bytes, memory\ Pool Nonpaged Allocs and process (process_name) \ Pool Nonpaged Bytes.
The number of bytes that the private Bytes process could not share with other processes. When the value of this counter is large, there may be a memory leak signal
Check for excessively frequent page exchanges
Because excessive paging uses a large amount of hard disk space, it is possible that there will be insufficient paging memory, which is easily confused with the disk bottleneck that caused the page exchange. Therefore, you must track the following disk usage counters and memory counters when studying the reasons for a less-than-obvious page exchange:
· Physical Disk\% Disk time
· Physical Disk\ Avg.Disk Queue Length
For example, include Page reads/sec and% Disk time and Avg.Disk Queue Length. If the page read operation rate is low and the value of% Disk Time and Avg.Disk Queue length is high, there may be a disk bottle diameter. However, if the queue length increases at the same time that the page read rate is not reduced, there is insufficient memory.
To determine the impact of excessive page swapping on disk activity, increase the value of the physical disk\ Avg.Disk Sec/transfer and memory\ pages/sec counters by several times. If the count of these counters exceeds 0.1, paging will take more than 10% of the disk access time. If this happens for a long time, you may need more memory.
Activities of the research program
Next, check that the running program is causing too many page exchanges. If possible, stop the program with the highest working set value, and then see if the page exchange rate has changed significantly. If you suspect that there are too many page exchanges, check the Memory\ pages/sec counter. This counter shows the number of pages that need to be read from disk because the page is not in physical memory. (Note the difference between this counter and Page faults/sec, which only indicates that the data cannot be used immediately in the specified working set of memory.) )
Performance Test Processor chapter (Windows)
Monitoring the processor and system object counters can provide valuable information about the use of handlers to help you decide if there is a bottleneck. You need to include the following:
- Processor\% Total Processor time gets the overall processor usage.
The count value is used to represent the overall processor utilization of the server, which is the average utilization of all CPUs for multiprocessor systems. If the value continues to exceed 90%, the entire system faces a processor bottleneck and needs to increase performance by increasing the processor.
It should be noted that due to the characteristics of the operating system itself, in some multi-CPU systems, the data itself is not large, but at this time the load situation between the CPU is extremely uneven, it should also be seen as a system to produce a processor bottleneck.
- Monitor Processor\% Processor time, processor\% User time, and% Privileged time for more information.
Processor\% User time refers to the CPU times consumed by non-core operations of the system, and if the value is large, consider whether to reduce this value by means of an optimization algorithm. If the server is a database server, the reason why the processor\% User time is large is probably that the database is sorted or the function operation consumes too much CPU time, so you can consider optimizing the database system.
- System\ Processor Queue Length is used for bottleneck detection.
%total the percentage of time that all processors in the system are busy in the Processor times, and for multiprocessor systems, this value can reflect the average busy state of all processors, which is 100% if half of the processors are busy, and this value is 50%
File Data operations/sec the frequency with which the computer reads and writes to the filesystem, but does not include file control operations
The Process queue Length thread waits for a queue to allocate a CPU resource, which does not include the thread that is occupying the CPU resource. If the queue is longer than the number of processors +1, the processor may be in a blocked state (reference value: <= number of processors + 1)
%processor Time CPU utilization, this counter is most commonly used to see if the processor is saturated, if the value continues to exceed 95%, it means that the current system bottleneck is the CPU, you can consider adding a processor or replacing a better performance processor. (reference value: <80%)
%priviliaged the percentage of time that the CPU spends processing threads in privileged mode. General system services, city management, memory management and some other processes that are self-initiated by the operating system belong to this type of
%user time is the opposite of the%privileged times counter, which refers to the percentage of hours spent in User state mode (that is, non-privileged mode) operations. If the value is large, consider whether to reduce this value by means of algorithm optimization. If the server is a database server, the reason why this value is large is likely to be that the database is sorted or the function operation consumes too much CPU time, you can consider optimizing the database system at this time.
The%DPC time processor consumes on network processing, and the lower the value the better. In multiprocessor systems, if this value is greater than 50% and%processor time is very high, joining a network card may improve performance.
Observe the value of the processor usage
To measure the activity of the processor, see the processor\% Processor time counter. This counter shows the percentage of time that the processor is busy executing a non-idle thread.
When checking processor usage, consider the role of the computer and the type of [url=] work [/url] that is completed. Depending on the work of the computer, a higher processor value means that the system is effectively handling heavier workloads or is trying to maintain them. For example, if you are monitoring a user's computer and the computer is used for calculations, the calculation program may be easy to use 100% of the processor time. Even if this results in the performance of [url=] other [/url] Applications in this computer being affected, it can be resolved by changing the load.
On the other hand, in server computers that handle many customer requests, a value of around 100% indicates that these processes are in the queue, waiting for processor time, and causing bottlenecks. Such continuous high-level processor use is unacceptable to the server.
Investigating processor bottlenecks
Processor bottlenecks are progressively displayed when the process's threads require a processor cycle that exceeds the available cycles. A longer processor queue can be established and the system response is affected. Two common causes of processor bottlenecks are CPU throttling programs and drivers or subsystem components that produce excessive interrupts.
To determine if a processor bottleneck exists due to high processor time requirements, check the system\ Processor Queue Length counter. Having two or more items in the queue indicates a bottleneck. If more than one program process competes for most processor time, installing a faster processor increases throughput. Attaching a processor can be helpful if you are running a multithreaded process, but be aware that additional processors may have limited benefits.
Additionally, the server work queues\ Queue Length counter that tracks the current lengths of the servers working queues on the computer displays the processor bottleneck. A continuous queue length of more than 4 indicates processor congestion may occur. This counter is a value for a specific time, not an average over time.
To determine whether the interrupt activity is causing a bottleneck, observe the value of the Processor\ interrupts/sec counter, which measures the speed of service requests from input/output (I/O) devices. If the value of this counter increases significantly and system activity does not increase correspondingly, there is a hardware problem.
You can also monitor processor\% Interrupt time for indirect indicators that generate interrupted disk drives, network cards, and other device activity.
Attention
To detect hardware problems that may affect processor performance, such as IRQ conflicts, observe the value of system\ File Control Bytes/second.
Monitor multi-processor systems
To observe the efficiency of a multiprocessor computer, use the following additional counters.
Counter |
Description |
Process\% Processor Time |
The sum of the processor time on each processor for all threads of the process. |
Processor (_total) \% Processor time |
The measurement of processor activity for all processors in the computer. "N[{y8_0 the sum of the average non-idle time for all processors during this counter sampling interval, and divide the number of processors by that and. 51Testing Software Testing Network T#e_5i:[email protected] "a:x:y For example, if all processors are busy averaging half a sampling interval, 50% is displayed. If half of the processors are busy with the entire interval, and the other processors are idle, 50% is also displayed. |
Thread\% Processor Time |
Number of processor times for threads |
Performance test disk (Windows)
Monitoring object: PhysicalDisk If the analyzed counter metrics come from a database server, a file server, or a streaming media server, disk I/O is more likely to be a bottleneck for these systems.
The number of I/Os per disk can be used to compare the I/O capability of the disk, and if the number of per-disk I/Os computed exceeds the nominal I/O capability of the disk, there is a real disk performance bottleneck.
The following table shows the calculation formulas for I/O per disk:
RAID type p> |
calculation method |
raid0 |
(reads+writes)/number of Disks |
raid1 |
(reads+2*writes)/2 |
RAID5 |
[reads+ (4*writes)]/number of Disks |
raid10 |
[reads+ (2*writes)]/number of Disks |
%disk time represents the percentage of the disk drive that is used to service a read or write request, and the hard disk may be a bottleneck if only%disk times is large
The Average disk Queue Length indicates the percentage of time that is spent on disk read and write requests to service, and can be increased by increasing the disk fabric array to improve performance (twice times the number of <= disks)
Average Disk read Queue Length indicates the average number of requests
Average Disk Write Queue Length indicates the average number of drive write requests
Average disk Sec/read The average time to read the data in S
Disk BYTES/SEC provides the throughput rate of the drive system. Determine workload balance to balance the load on the network server, you need to know how busy the server disk drives are. Use the physical disk\% Disk Time counter, which displays the percentage of drive activity times. If the% Disk time is higher (more than 90%), check the physical disk\ Current disk Queue Length counter to see the number of system requests that are waiting for disk access. The number of wait I/O requests should remain at 1.5 to twice times greater than the number of spindles that make up the physical disk.
Average disk Sec/transfer The average time to write data in S
The counter reflects the time that the disk took to complete the request. A higher value indicates that the disk controller has repeatedly retried the disk because of a failure. These failures increase the average disk transfer time. In general, the definition of this value is less than 15ms is the best, between 15-30ms is good, between 30-60ms is acceptable, more than 60ms need to consider the replacement of hard disk or hard disk RAID mode
Average Disk Bytes/transfer
A value greater than KB indicates that the disk drive generally works well, and a lower value is generated if the application is accessing the disk. For example, an application that randomly accesses a disk increases the average disk Sec/transfer time because random transfers require additional search time.
Network chapter of performance Testing (Windows)
Monitoring object: Network Interface Networks analysis is a [url=] technology [/url] High content [url=] work [/url], in general organizations have dedicated network management personnel for network analysis, for test engineers, If you suspect that the network is the bottleneck of the system, you can ask the network to still have a photo for the network detection.
Network Interface\Bytes Total/sec is the rate at which bytes are sent and received (including frame characters). The value of this counter can be used to determine whether the network connection speed is a bottleneck, the method is to use the value of this counter and the current network bandwidth comparison.
The byte total/sec represents the speed at which bytes are accepted and sent in the network, which can be used to determine if the network has a bottleneck (reference value: Divide the counter and network bandwidth, <50%)
The process of performance testing (Windows)
To view the%processor time value of a process
The%processor time of each process reflects the processor times consumed by the process. Comparing the processor time consumed by different processes makes it easy to see which process consumes the most processor time in the [url=] performance test [/url] process, which can be optimized for the application.
View page failures generated by each process
The ratio of page invalidation (obtained by Process\Page failures/sec counter) and the system's page failure (available through the Memory\Page failures/sec counter) generated by each process can be used to determine which process produced the most invalid page, This process is either a process that requires a lot of memory, or it is a very active process that can be analyzed in its own right.
Understand the process\private of a process Bytes
Process\Private bytes refers to the current number of bytes allocated by the process that cannot be shared with other processes. This counter mainly uses the pull to determine the process during the performance test process has no memory leaks.
For example, for a Web application on top of IIS, we can focus on monitoring the private Bytes of the Inetinfo process, if the private Bytes counter value of the process is increasing during the performance test, or a period after the performance test is stopped, The private bytes of the process still continues at a high level, indicating that there is a memory leak in the application.
(Note: The counter used by process analysis method mainly includes: Process\%processor time, page failures/sec, page failures/sec, Private Bytes)
RELATED Links: ① Memory-mapped file mechanism memory-mapped files use virtual memory to map files to the address space of a process, after which the process operation files, like the address in the process space, eliminates the time to read and write I/O.
For example, a function that uses memory operations such as memcpy. This method can be used very well in situations where a file or a large file is required to be processed frequently, which is more efficient than normal IO in this way.
With a memory-mapped file you can assume that the operating system has loaded all the files into memory for you, and then you simply move the file pointer to read and write. This way you don't even need to invoke API functions that allocate, free memory blocks, and file input/output, and you can use this as a way to share data between different processes. The use of a memory-mapped file does not actually involve actual file operations, it is more like preserving a visible memory space for each process. As for using memory-mapped files as a way to share data between processes, be more careful because you have to deal with synchronization of data, or your application may well get outdated or wrong data or even crash.
The memory-mapped file itself has some limitations, such as once you generate a memory-mapped file, you cannot change its size during that session. Therefore, memory-mapped files are useful for read-only files and for file operations that do not affect their size. Of course, this does not mean that the file that will cause the change of its size must not be used in memory mapping file method, you can estimate the possible size of the file after the operation, and then generate such a size of a memory map file, and then the length of the file can grow to such a size. We have enough explanations, and then we'll look at the details of the implementation:
- Call CreateFile to open the file you want to map.
- Call CreateFileMapping, which asks for the handle returned by the previous CreateFile, which generates a memory-mapped object based on the file object created by the CreateFile function.
- Call the MapViewOfFile function to map an entire range of files or the entire file to memory. This function returns a pointer to the first byte mapped to memory.
- Use this pointer to read and write files.
- Call UnmapViewOfFile to dismiss the file mapping.
- Call CloseHandle to close the memory-mapped file. Note the handle to the memory-mapped file must be passed in.
- Call CloseHandle to close the file. Note You must pass in a handle to the file created by CreateFile.
Windows common performance counters for performance testing