5.1 LinuxMemory Subsystem
when diagnosing memory performance problems, it may be necessary to observe how the application executes at different levels of the memory subsystem. At the top level, the operating system determines how to utilize swap memory and physical memory. It determines which piece of the application's address space will be placed in physical memory, the so-called resident set. Other memory that is not part of the resident set but used by the application will be swapped to disk. The application determines how much memory is requested from the operating system, the so-called virtual set.
when the application uses physical memory, it first The CPU's cache subsystem is switched. Modern CPUs have multi-level caches. the fastest cache is closest to the CPU (L1), and its capacity is minimal. For example, assume that the CPU has only a level two cache:L1 and L2. when when the CPU requests a piece of memory, the processor checks to see if the memory already exists in the L1 cache. If it is, theCPU can be used directly. If it is not in the L1 cache , the processor produces a L1 cache Miss. It then checks the L2 advanced cache, and if the data is in the L2 cache, it can be used directly, otherwise it is processed as above, and then the information is retrieved in physical memory. Use caching wisely to reduce the number of cache misses, which can improve performance.
5.2Memory Performance Tools5.2.1 PS
PS Memory Parameter Description
Vsz |
The virtual set size refers to the capacity of the virtual memory used by the application. Because Linux allocates it only when an application attempts to use physical memory, the value of the item may be much larger than the amount of physical memory used by the application. |
RSS |
resident set size refers to the amount of physical memory that the application is currently using |
tsiz |
text size refers to the virtual size of the program code |
dsiz |
data size refers to the virtual size of program usage |
Majflt |
The main fault is the means of making Linux represents the number of page faults that the process reads from disk. |
5.2.2/proc/<pid>
The Linux kernel provides a virtual file system that allows you to extract process information that runs on the system. the/proc interface is very simple and the virtual files inside can be read by Cat . Each PID on the system has a folder under the/proc directory that contains a series of files. Where status is the process information for the PID of the process , its retrieval command is:cat/proc/<pid> Status
The Memory Statistics section of the status file shows the following resolution
vmsize |
The only remaining virtual set size is the amount of virtual memory used by the application, same as ps vsz |
vmlck |
The amount of memory locked by the process cannot be swapped to disk |
vmrss |
resident set size or the amount of physical memory currently in use by the application. |
vmdata |
data size or program uses a virtual size of the amount of data, without stack information |
vmstk |
process stack size |
vmexe |
The virtual size of the executable memory of the program. It does not contain libraries used by processes |
Vmlib |
The size of the library used by the process |
Example: Viewing The situation of the WebLogic process
java The program code for the process is only 36k 96k 2712776k 92608 90 M vmlck indicates that no memory is locked, making it impossible to swap memory. vmrss size is 1.1g means that the current process uses the 1.1g 2.8g vmrss vmsize
as described above, the application's the size of the vmlib is nonzero, so using a library, you can view the maps file to see which libraries it uses.
Linux performance Optimization Chapter fifth performance tools: specific process memory