A method for automatically optimizing operating system performance
By defining the operating status and indicators of the operating system and automatically adjusting the system configuration, it solves the problem that the operating system cannot be dynamically adjusted, realizes optimization in different usage scenarios, and improves system performance and user experience.
Patent Information
- Application Number
- CN202411061993.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-05
AI Technical Summary
After the existing operating system is deployed in user equipment, the system configuration is almost unchanged, which makes it impossible to dynamically adjust to adapt to different usage scenarios, affecting the full use of system performance.
By defining the operating status and related indicators of the operating system, it collects data in real time and automatically adjusts the system configuration to adapt to the current operating status, including CPU governor, process priority, ALPM, network card bandwidth, and kernel parameters.
It realizes the automatic optimization and adjustment of the operating system in different usage scenarios without manual intervention, improves the stability and adaptability of the system, and enhances the user experience.
Smart Images

Figure CN118585240B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of computer technology, and specifically provides a method for automatically optimizing operating system performance. Background Art
[0002] Currently, operating systems are all secondary developed based on GNU / Linux open source projects. Therefore, operating systems inherit the highly customizable and configurable features of Linux. Users can flexibly adjust the system configuration according to the needs of their own application scenarios when using the operating system. Typical application scenarios include document viewing and editing, web browsing, instant messaging, online video playback, file decompression, key search of file content, file copy / paste, virus and Trojan detection, large file upload and download, graphic image drawing and rendering, software development, etc. When the operating system supports the above scenarios, its operating characteristics are very different. Some are light-load tasks, some are CPU-intensive tasks, some are storage-intensive tasks, and some are network-intensive tasks.
[0003] The operating system developed based on Linux is highly configurable. In theory, users can adjust their systems at any time to suit the current usage scenario based on the various performance optimization and energy-saving mechanisms provided by the system. However, in actual deployment environments, once the operating system is deployed in the user's device, its system configuration is almost unchanged. The reason is that ordinary users do not have the relevant skills to adjust the system configuration and kernel configuration; another important reason is that the system status changes frequently. If the user manually configures the system every time the status changes, it will seriously affect the user experience.
[0004] In short, due to the complexity and immediacy of system configuration, users themselves rarely dynamically adjust system configuration according to their own usage scenarios, which affects the full performance of the system. Summary of the invention
[0005] In order to overcome the above defects, the present invention is proposed to solve the technical problem that the existing system configuration cannot be dynamically adjusted accordingly, thereby affecting user use.
[0006] The present invention provides a method for automatically optimizing operating system performance, comprising the following steps:
[0007] S1: define the operating system running state, running indicators and the corresponding relationship between the running state and the running indicators;
[0008] S2: Get the data of all operating indicators in the current state;
[0009] S3: judging the current operating state of the operating system according to the acquired operating indicator data;
[0010] S4: Execute corresponding system configuration optimization adjustment according to the current operating status;
[0011] S5: Repeat the above steps S2-S4 according to a preset cycle.
[0012] Furthermore, the operating state includes a light load state, a computing intensive state, a storage intensive state and a network intensive state.
[0013] Furthermore, the operating indicators include the average CPU utilization of a single process in the past minute P ldavg-1 , Average CPU load of the system in the past minute C ldavg-1 、The average memory utilization of a single process in the past minute PM ldavg-1 、The average system memory utilization in the past minute M ldavg-1 , Average utilization of SWAP space in the past minute S ldavg-1 , Average disk read speed DR in the past minute avg-1 、The average speed of writing to disk in the past minute DW avg-1 , Average disk I / O utilization in the past minute D %util , the average network uplink speed in the past minute N avg-1-txkB / s , the average network downlink speed in the past minute N avg-1-rxkB / s , the average network bandwidth utilization rate N in the past minute %ifutil .
[0014] Further, the step S2 comprises:
[0015] The average CPU utilization of a single process in the past minute, Pldavg-1, is obtained by calculating the top -d 1 command in the shell;
[0016] The system CPU average load Cldavg-1 in the past minute is obtained by using the top -d 1 command in the shell;
[0017] The average memory utilization of a single process in the past minute, PMldavg-1, is obtained by using the top -d 1 command and the capital M key in the shell.
[0018] The average system memory utilization rate Mldavg-1 in the past minute is obtained by calculating the top command in the shell;
[0019] The average utilization rate of the SWAP swap space in the past minute, Sldavg-1, is obtained by calculating the top command in the shell;
[0020] The average disk read speed DRavg-1 in the past minute is calculated and obtained by using the iostat -d -x -k -t 1 command in the shell;
[0021] The average disk writing speed DWavg-1 in the past minute is calculated and obtained by using the iostat -d -x -k -t 1 command in the shell;
[0022] The disk I / O average utilization rate D%util in the past minute is calculated and obtained by using the iostat -d -x -k -t 1 command in the shell;
[0023] The average network uplink speed Navg-1-txkB / s in the past minute can be directly obtained through the sar -n DEV 160 command in the shell;
[0024] The average downlink speed of the network in the past minute, Navg-1-rxkB / s, can be directly obtained by using the sar -n DEV 160 command in the shell;
[0025] The average network bandwidth utilization rate N%ifutil in the past minute can be directly obtained by using the sar -n DEV 1 60 command in the shell.
[0026] Further, the step S3 comprises:
[0027] When all satisfy P ldavg-1 ≤80%, C ldavg-1 ≤3, PM ldavg-1 ≤30%, M ldavg-1 ≤60%, S ldavg-1 ≤30%, DR avg-1 ≤20000, DW avg-1 ≤20000, D %util ≤30%, N avg-1-txkB / s ≤30000, N avg-1-rxkB / s ≤30000 and N %ifutil When the condition is ≤30%, the current operating state is judged to be light load state;
[0028] When at least P ldavg-1 >80%, C ldavg-1 >One of the conditions in 3 is met, the current running state is judged to be computationally intensive;
[0029] When at least PM ldavg-1 >30%, M ldavg-1 >60%, S ldavg-1 >30%, DR avg-1 >20000、DW avg-1 >20000、D %util >30% of the conditions, the current operation state is judged as storage-intensive state;
[0030] When at least N avg-1-txkB / s >30000、N avg-1-rxkB / s >30000、N %ifutil >30% when one of the following conditions is met, the current operating state is judged to be a network intensive state.
[0031] Further, the step S4 comprises:
[0032] When the current running state is light load, adjust the parameters of CPU governor to Conservative, adjust the process priority to 0, adjust the parameters of ALPM to med_power_with_dipm, adjust the network card bandwidth speed to 100 megabits, adjust the kernel parameters vm.nr_hugepages to 0, vm.swappiness to 0, vm.dirty_background_ratio to 35, vm.dirty_ratio to 60, vm.dirty_expire_centisecs to 3000, vm.dirty_writeback_centisecs to 500, net.core.rmem_default to 212992, net.core.rmem_max to 212992, net.core.wmem_default to 212992, net.core.wmem_max to 212992;
[0033] When the current running state is compute-intensive, adjust the CPU governor parameter to Performance, adjust the process priority to -20, adjust the ALPM parameter to med_power_with_dipm, adjust the network card bandwidth speed to 100 megabits, adjust the kernel parameters vm.nr_hugepages to 0, vm.swappiness to 0, vm.dirty_background_ratio to 35, vm.dirty_ratio to 60, vm.dirty_expire_centisecs to 3000, vm.dirty_writeback_centisecs to 500, net.core.rmem_default to 212992, net.core.rmem_max to 212992, net.core.wmem_default to 212992, net.core.wmem_max to 212992;
[0034] When the current running state is storage intensive, adjust the CPU governor parameter to Conservative, adjust the process priority to 0, adjust the ALPM parameter to max_performance, adjust the network card bandwidth speed to 100 megabits, adjust the kernel parameters vm.nr_hugepages to 500, vm.swappiness to 60, vm.dirty_background_ratio to 60, vm.dirty_ratio to 80, vm.dirty_expire_centisecs to 9000, vm.dirty_writeback_centisecs to 1000, net.core.rmem_default to 212992, net.core.rmem_max to 212992, net.core.wmem_default to 212992, net.core.wmem_max to 212992;
[0035] When the current running state is network intensive, the parameters of the CPU governor are adjusted to Conservative, the priority of the process is adjusted to 0, the parameters of ALPM are adjusted to med_power_with_dipm, the network card bandwidth speed is adjusted to 1000 megabits, and the kernel parameters vm.nr_hugepages, vm.swappiness, vm.dirty_background_ratio, vm.dirty_ratio, vm.dirty_ratio, vm.dirty_expire_centisecs, vm.dirty_writeback_centisecs, net.core.rmem_default, net.core.rmem_max, net.core.wmem_default, net.core.wmem_max, net.core.wmem_default, net.core.wmem_max, net.core.
[0036] Working principle and beneficial effects of the present invention:
[0037] In the technical solution of the present invention, firstly, the various operating states that may occur in the operating system are clarified, the key operating indicators that can reflect these operating states are determined, and the corresponding relationship between the operating state and the operating indicator is established. Then, by collecting the specific data of each operating indicator of the current operating system in real time, according to the pre-defined corresponding relationship between the operating state and the operating indicator, the current data is analyzed and compared, so as to judge the current operating state of the operating system. Thereby, the system will trigger the corresponding optimization strategy. By collecting and analyzing the operating indicator data in real time, the present invention can optimize and adjust the system in a targeted manner to ensure the stable operation of the system. The entire optimization process does not require manual intervention and is automatically adjusted, with strong flexibility and adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which:
[0039] Figure 1 It is a flow chart of the main steps of a method for automatically optimizing operating system performance according to the present invention. DETAILED DESCRIPTION
[0040] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention. Example 1
[0041] In this embodiment, in view of the problem that the domestic desktop operating system itself has various performance optimization mechanisms, but the ordinary users do not have the relevant optimization and adjustment knowledge, resulting in the operating system performance cannot be fully utilized, the present invention proposes an automatic operating system performance optimization method, which can detect the characteristics of the user's current application scenario in real time, automatically optimize the system configuration to suit the needs of the application scenario, give full play to the performance of the domestic desktop operating system, and maximize the user experience.
[0042] Figure 1 This is a schematic diagram of the main steps of a method for automatically optimizing operating system performance according to the present invention. Figure 1 As shown, in this embodiment, a method for automatically optimizing operating system performance mainly includes the following steps S1 to S5.
[0043] Step S1: define the operating system operating state, operating indicators, and the corresponding relationship between the operating state and the operating indicators.
[0044] In one implementation, the operating state of the operating system is divided into four states: light load state, computing intensive state, storage intensive state, and network intensive state, according to common operating scenarios of the operating system and configuration resources consumed during operation. Specifically:
[0045] Light load means that the user's current operation consumes only a small amount of CPU, memory, storage, and network resources. The corresponding operation scenarios include document viewing and editing, web browsing, instant messaging, small file copy / paste, small file decompression, network upload and download of small files, etc.
[0046] Computation-intensive state means that the user's current operation consumes a lot of CPU computing resources. The corresponding operation scenarios include large file decompression, file content keyword search, virus and Trojan detection, large-scale program code compilation and other operations.
[0047] Storage-intensive state means that the user's current operation performs a large number of storage read and write operations, consuming a large amount of memory or disk I / O resources. The corresponding operation scenarios include file copy / paste, database read and write, and other operations.
[0048] The network intensive state means that the user's current operation performs a large number of network transmission operations, consuming a large amount of network bandwidth resources. The corresponding operation scenarios include network large file downloads, online video playback, and large file uploads to emails / cloud disks.
[0049] In one implementation, according to the operating system configuration usage corresponding to different operating states, the defined operating indicators include the average CPU utilization rate P of a single process in the past minute. ldavg-1 , Average CPU load of the system in the past minute C ldavg-1 、The average memory utilization of a single process in the past minute PM ldavg-1 、The average system memory utilization in the past minute M ldavg-1 , Average utilization of SWAP space in the past minute S ldavg-1 , Average disk read speed DR in the past minute avg-1 、The average speed of writing to disk in the past minute DW avg-1 , Average disk I / O utilization in the past minute D %util , the average network uplink speed in the past minute N avg-1-txkB / s 、The average downlink speed of the network in the past minute N avg-1-rxkB / s , the average network bandwidth utilization rate N in the past minute %ifutil .
[0050] In one implementation, after defining the operating state and related operating indicators, the corresponding relationship between the operating state and the operating indicators is defined through historical data, as shown in Table 1.
[0051] Table 1 Correspondence between operating system running status and indicator system
[0052]
[0053] Step S2: Obtain data of all operating indicators in the current state.
[0054] In this embodiment, the specific methods for obtaining the 11 operating indicators are as follows:
[0055] Average CPU utilization of a single process in the past minute P ldavg-1 , calculated and obtained by using the top -d 1 command in the shell. The output of the top command is arranged in descending order according to the CPU utilization of the process by default. The first line of data displayed after the top command is the data corresponding to the process that consumes the most CPU resources. The parameter -d 1 is added after the top command, which means that the output of the top command is refreshed once a second, which means 60 outputs per minute. Specifically, the output value per second of the process that consumes the most CPU resources in the past minute obtained by this command can be used to calculate the average CPU utilization value of the process in the past minute.
[0056] Average CPU load of the system in the past minute C ldavg-1 , and obtain it through the top -d 1 command in the shell. Specifically, the first value of the load average field obtained through this command is the indicator data.
[0057] Average memory utilization PM of a single process in the past minute ldavg-1 , in the shell, use the top -d 1 command and the capital M key to calculate and obtain. Specifically, by obtaining the output value of the %MEM field of the process that consumes the most memory resources in the past minute, the average memory utilization value of the process in the past minute can be calculated. Among them, after the top command and the capital M key, the processes are arranged in descending order according to the size of memory utilization. The first line of data displayed after the top and M key commands is the data corresponding to the process that consumes the most memory resources.
[0058] Average system memory utilization in the past minute M ldavg-1 , use the top command in the shell to calculate and obtain. Specifically, use this command to obtain the memory utilization of the MiB Mem field in the past minute, and use the formula used / total to calculate the average system memory utilization in the past minute.
[0059] Average utilization of SWAP space in the past minute S ldavg-1, use the top command in the shell to calculate and obtain. Specifically, the MiB Swap field obtained by this command has a SWAP swap partition utilization rate in the past minute, and the average SWAP swap space utilization rate in the past minute is calculated by the formula used / total
[0060] Average disk read speed DR in the past minute avg-1 , you can use the iostat -d -x -k -t 1 command in the shell to calculate and obtain the value. Specifically, you can use the output value of the rkB / s field per second obtained by this command in the past minute to calculate the average value in the past minute. rkB / s indicates the amount of data read per second, in KB.
[0061] Average disk writing speed DW in the past minute avg-1 , calculated and obtained by using the iostat -d -x -k -t 1 command in the shell. Specifically, the output value of the wkB / s field per second obtained by the command in the past minute can be used to calculate the average value in the past minute. wkB / s represents the amount of data written per second, in KB.
[0062] Average disk I / O utilization in the past minute D %util , use the iostat -d -x -k -t 1 command in the shell to calculate and obtain. Specifically, the output value of the %util field per second obtained by this command in the past minute can be used to calculate the average value in the past minute.
[0063] Average network uplink speed in the past minute N avg-1-txkB / s , you can directly get it by using the sar -n DEV 1 60 command in the shell. Specifically, you can directly get the average value of the txkB / s field of the network card per second in the Average line obtained by this command, where txkB / s indicates the amount of data sent per second in KB.
[0064] Average network downlink speed in the past minute N avg-1-rxkB / s , you can directly get it by using the sar -n DEV 1 60 command in the shell. Specifically, you can directly get the average value of the past minute by using the output value of the rxkB / s field in the Average line of the command. rxkB / s indicates the amount of data received per second, in KB.
[0065] Average network bandwidth utilization rate N in the past minute %ifutil , you can directly get it by using the sar -n DEV 1 60 command in the shell. Specifically, you can directly get the network bandwidth utilization by using the value of the %ifutil field of the network card in the Average line obtained by this command.
[0066] Step S3: Determine the current running state of the operating system according to the acquired data.
[0067] In this embodiment, the operating state is judged according to the detected operating index data and the corresponding relationship (Table 1) defined in advance. During the judgment process, the following definitions are followed at the same time:
[0068] 1. For all the above operating indicators, if they meet the light-load threshold range at the same time, it means that the operating system is currently in a light-load state;
[0069] 2. For the operation index P ldavg-1 , C ldavg-1 , when at least one of them meets the threshold of computationally intensive state, the system is computationally intensive;
[0070] 3. For the operation indicator PM ldavg-1 、M ldavg-1 , S ldavg-1 ,DR avg-1 , DW avg-1 , D %util , when at least one of the thresholds of memory-intensive state is met, the operating state of the operating system is storage-intensive state;
[0071] 4. For the running index N avg-1-txkB / s 、N avg-1-rxkB / s 、N %ifutil , when at least one of the thresholds of network-intensive state is met, the operating state of the operating system is network-intensive state;
[0072] 5. At a certain moment, the operating system may be in one or more of the following states: computing-intensive, storage-intensive, and network-intensive.
[0073] Step S4: Perform corresponding system configuration optimization and adjustment according to the current operating state to improve the system's execution performance or reduce the system's energy consumption. The system configurations that can be optimized include CPU governor, renice, ALPM, network card bandwidth, and sysctl.
[0074] The CPU governor is a CPU frequency manager provided by the kernel. It can adjust the CPU operating frequency according to the current system load. The CPU governor's adjustment mechanism is implemented through different parameters. The adjustable parameters include:
[0075] 1) Performance: Indicates that the CPU always runs at the highest frequency without considering energy consumption.
[0076] 2) PowerSave: Indicates that the CPU always runs at the lowest non-idle frequency, ignoring performance considerations.
[0077] 3) Userspace: means that the system is controlled by userspace programs and the kernel does not make any decisions.
[0078] 4) Ondemand: Indicates that the CPU frequency increases when high performance is required and decreases when idle.
[0079] 5) Conservative: Similar to Ondemand, but more conservative, increasing the frequency only when it is clearly needed.
[0080] Renice indicates the priority of process execution. The priority range is -20 (highest priority) to 19 (lowest priority). The renice adjustment mechanism is implemented through the "renice -n priority - IDp process" command.
[0081] ALPM (Active Link Power Management) is a disk management tool that can adjust the performance and energy consumption of the disk. The adjustment mechanism of ALPM is through "echo "parameter" > / sys / class / scsi_host / host / link_power_management_policy" command. The parameters are:
[0082] 1) max_performance: maximum disk performance and highest energy consumption mode;
[0083] 2) min_power: minimum disk performance and minimum energy consumption mode;
[0084] 3) medium_power: a compromise between max_performance and min_power;
[0085] 4) med_power_with_dipm: It is the latest new mode with better performance and lower energy consumption.
[0086] The network card bandwidth is the network card bandwidth adjustment provided by the network subsystem. It can dynamically adjust the network card's operating frequency and network port speed according to the current network load. The default network port will always run at a high speed. By dynamically adjusting the network port speed, power consumption can be reduced. The speed adjustment mechanism of the network card bandwidth is set using the corresponding command through the ethtool tool. For example:
[0087] The following command can be used to adjust the speed of a 100 / 1000Mbs adaptive network card to 100M:
[0088] ethtool -s NIC name speed 100 duplex full autoneg off
[0089] The speed can be restored to the original speed, that is, 1000 Mbps, by using the following command:
[0090] ethtool -s NIC name speed 1000 duplex full autoneg on
[0091] Sysctl includes a variety of runtime kernel parameters. The adjustment mechanism of sysctl is set through the "sysctl -wname=value" command. Name is the kernel parameter and value is the corresponding value of the kernel parameter. The relevant kernel parameters involved are as follows:
[0092] 1) vm.nr_hugepages: transparent huge page mechanism
[0093] 2) vm.swappiness: memory swap partition mechanism
[0094] 3) vm.dirty_background_ratio: Control mechanism for dirty pages occupying memory size
[0095] 4) vm.dirty_ratio: Dirty page forced write-back mechanism
[0096] 5) vm.dirty_expire_centisecs: Dirty page expiration time control mechanism
[0097] 6) vm.dirty_writeback_centisecs: Dirty page writeback trigger mechanism
[0098] 7) net.core.rmem_default: Default socket read buffer memory size control mechanism
[0099] 8) net.core.rmem_max: Maximum socket read buffer memory size control mechanism
[0100] 9) net.core.wmem_default: default socket write buffer memory size control mechanism
[0101] 10) net.core.wmem_max: Maximum socket write buffer memory size control mechanism
[0102] Specifically, the corresponding system configuration optimization and adjustment in different operating states can be implemented by referring to Figure 2.
[0103] Table 2 Optimization configuration strategies corresponding to the operating status
[0104]
[0105] When the user turns on the system, the system adopts the light-load configuration strategy by default. When the system is in a computing, storage or network intensive state, the parameter values of the corresponding mechanism can be adjusted, and other parameters remain unchanged, consistent with the light-load state; if the system is in multiple intensive states at the same time, the parameter values of the corresponding mechanisms are adjusted at the same time.
[0106] It should be noted that when the system is in multiple intensive states at the same time, the configuration strategies for different optimization mechanisms are different. At this time, the configuration strategy different from that of the light-load state is mainly used: for example, if the system is in both the compute-intensive state and the storage-intensive state at the same time, for the ALPM mechanism, the configuration strategy of the storage-intensive state is executed (the configuration strategy of the ALPM mechanism corresponding to the compute-intensive state is the same as that of the light-load state, and its strategy is discarded).
[0107] Step S5: Repeat the above steps S2-S4 according to a preset cycle.
[0108] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order, and they can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention. Example 2
[0109] The following uses typical usage scenarios in different time periods as an example to explain the workflow of the entire automatic performance optimization method. The set usage scenario is that after the system is turned on, the user first uses the antivirus software to check for viruses; then, the user copies large files from the mobile storage to the computer; finally, the user starts editing and browsing documents.
[0110] After the system is turned on, the system defaults to a light-load system configuration, and the automatic performance optimization method automatically runs as a system daemon process, monitoring the values of the above 11 operating indicators in real time.
[0111] (1) When the user uses antivirus software to detect and kill viruses, the real-time detected operating index values are shown in the second column of Table 3:
[0112] Table 3 Example values of operating indicators
[0113]
[0114] According to the example values of the indicators in the second column of Table 3, and the corresponding relationship between the operating system running status and the running indicators in Table 1, it can be judged that the system is currently in a computing-intensive state and a storage-intensive state. At this time, the optimization configuration strategies corresponding to the computing-intensive state and the storage-intensive state are called according to Table 2 to configure the system.
[0115] When the user finishes virus detection and starts copying large files, the real-time detected system indicator values are shown in the third column of Table 3. According to the detected operating indicator values and the corresponding relationship between the operating system operating status and the operating indicator in Table 1, it can be determined that the system is currently in a write-storage intensive state. At this time, the system is configured by calling the optimization configuration strategy corresponding to the write-storage intensive state according to Table 2.
[0116] (3) When the user finishes copying the large file and starts editing and browsing the document, the detected system indicator values are shown in the fourth column of Table 3. Based on the detected system indicator values and the corresponding relationship between the operating system running state and the running indicator in Table 1, it can be determined that the system is currently in a light-load state. At this time, the optimization configuration strategy corresponding to the light-load state is called according to Table 2 to configure the system.
[0117] Those skilled in the art will appreciate that the modules in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.
[0118] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A method for automatically optimizing operating system performance, characterized in that: The following steps are involved: S1: define the operating system running state, running indicators and the corresponding relationship between the running state and the running indicators; S2: Get the data of all operating indicators in the current state; S3: judging the current operating state of the operating system according to the acquired operating indicator data; S4: Execute corresponding system configuration optimization adjustment according to the current operating status; S5: Repeat the above steps S2-S4 according to a preset cycle; The operating states include a light load state, a computing intensive state, a storage intensive state, and a network intensive state; The operating indicators include the average CPU utilization rate of a single process in the past minute P ldavg-1 , Average CPU load of the system in the past minute C ldavg-1 、The average memory utilization of a single process in the past minute PM ldavg-1 、The average system memory utilization in the past minute M ldavg-1 , Average utilization of SWAP space in the past minute S ldavg-1 , Average disk read speed DR in the past minute avg-1 、The average speed of writing to disk in the past minute DW avg-1 , Average disk I / O utilization in the past minute D %util , the average network uplink speed in the past minute N avg-1-txkB / s , the average network downlink speed in the past minute N avg-1-rxkB / s , the average network bandwidth utilization rate N in the past minute %ifutil ; The step S3 comprises: When all satisfy P ldavg-1 ≤80%, C ldavg-1 ≤3, PM ldavg-1 ≤30%, M ldavg-1 ≤60%, S ldavg-1 ≤30%, DR avg-1 ≤20000, DW avg-1 ≤20000, D %util ≤30%, N avg-1-txkB / s ≤30000, N avg-1-rxkB / s ≤30000 and N %ifutil When the condition is ≤30%, the current operating state is judged to be light load state; When at least P ldavg-1 >80%, C ldavg-1 >One of the conditions in 3 is met, the current running state is judged to be computationally intensive; When at least PM ldavg-1 >30%, M ldavg-1 >60%, S ldavg-1 >30%, DR avg-1 >20000、DW avg-1 >20000、D %util >30% of the conditions, the current operation state is judged as storage-intensive state; When at least N avg-1-txkB / s >30000、N avg-1-rxkB / s >30000、N %ifutil >30% of the conditions, the current operation state is judged as the network intensive state; The step S4 comprises: When the current running state is light load, adjust the parameters of CPU governor to Conservative, adjust the process priority to 0, adjust the parameters of ALPM to med_power_with_dipm, adjust the network card bandwidth speed to 100 megabits, adjust the kernel parameters vm.nr_hugepages to 0, vm.swappiness to 0, vm.dirty_background_ratio to 35, vm.dirty_ratio to 60, vm.dirty_expire_centisecs to 3000, vm.dirty_writeback_centisecs to 500, net.core.rmem_default to 212992, net.core.rmem_max to 212992, net.core.wmem_default to 212992, net.core.wmem_max to 212992; When the current running state is compute-intensive, adjust the CPU governor parameter to Performance, adjust the process priority to -20, adjust the ALPM parameter to med_power_with_dipm, adjust the network card bandwidth speed to 100 megabits, adjust the kernel parameters vm.nr_hugepages to 0, vm.swappiness to 0, vm.dirty_background_ratio to 35, vm.dirty_ratio to 60, vm.dirty_expire_centisecs to 3000, vm.dirty_writeback_centisecs to 500, net.core.rmem_default to 212992, net.core.rmem_max to 212992, net.core.wmem_default to 212992, net.core.wmem_max to 212992; When the current running state is storage intensive, adjust the CPU governor parameter to Conservative, adjust the process priority to 0, adjust the ALPM parameter to max_performance, adjust the network card bandwidth speed to 100 megabits, adjust the kernel parameters vm.nr_hugepages to 500, vm.swappiness to 60, vm.dirty_background_ratio to 60, vm.dirty_ratio to 80, vm.dirty_expire_centisecs to 9000, vm.dirty_writeback_centisecs to 1000, net.core.rmem_default to 212992, net.core.rmem_max to 212992, net.core.wmem_default to 212992, net.core.wmem_max to 212992; When the current running state is network intensive, the parameters of the CPU governor are adjusted to Conservative, the priority of the process is adjusted to 0, the parameters of ALPM are adjusted to med_power_with_dipm, the network card bandwidth speed is adjusted to 1000 megabits, and the kernel parameters vm.nr_hugepages, vm.swappiness, vm.dirty_background_ratio, vm.dirty_ratio, vm.dirty_ratio, vm.dirty_expire_centisecs, vm.dirty_writeback_centisecs, net.core.rmem_default, net.core.rmem_max, net.core.wmem_default, net.core.wmem_max, net.core.wmem_default, net.core.wmem_max, net.core.
2. The method for automatically optimizing operating system performance according to claim 1, characterized in that: The step S2 comprises: The average CPU utilization of a single process in the past minute, Pldavg-1, is obtained by calculating the top -d 1 command in the shell; The system CPU average load Cldavg-1 in the past minute is obtained by using the top -d 1 command in the shell; The average memory utilization of a single process in the past minute, PMldavg-1, is obtained by using the top -d 1 command and the capital M key in the shell. The average system memory utilization rate Mldavg-1 in the past minute is obtained by calculating the top command in the shell; The average utilization rate of the SWAP swap space in the past minute, Sldavg-1, is obtained by calculating the top command in the shell; The average disk read speed DRavg-1 in the past minute is calculated and obtained by using the iostat -d -x -k -t 1 command in the shell; The average disk writing speed DWavg-1 in the past minute is calculated and obtained by using the iostat -d -x -k -t 1 command in the shell; The disk I / O average utilization rate D%util in the past minute is calculated and obtained by using the iostat -d -x -k -t 1 command in the shell; The average network uplink speed Navg-1-txkB / s in the past minute can be directly obtained through the sar -n DEV 1 60 command in the shell; The average downstream network speed Navg-1-rxkB / s in the past minute can be directly obtained through the sar -n DEV 1 60 command in the shell; The average network bandwidth utilization rate N%ifutil in the past minute can be directly obtained by using the sar -n DEV 1 60 command in the shell.
