A method, device, medium and electronic equipment for dynamically adjusting read-write performance
By calculating real-time load values and adjusting the buffer size using a PID control algorithm, the problem of excessive CPU I/O waiting time during multi-threaded read/write operations was solved, achieving efficient utilization of system resources and reducing business impact.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIVIEW TECH CO LTD
- Filing Date
- 2021-12-15
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, during multi-threaded data read and write processes, hardware performance limitations lead to excessively long CPU I/O wait times, affecting the normal operation of other services. Furthermore, setting read and write service priorities cannot fully utilize system resources, resulting in resource waste and the risk of business disruption.
By acquiring the number of CPU cores, utilization rate, and initial average load of the system, the real-time load value is calculated, and the buffer size is dynamically adjusted to optimize read and write performance. The read and write parameters are then optimized in conjunction with a PID control algorithm.
While ensuring the normal operation of other services, make full use of system resources, dynamically adjust read and write rates, reduce resource waste, and improve read and write efficiency.
Smart Images

Figure CN116263706B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, medium and electronic device for dynamically adjusting read and write performance. Background Technology
[0002] In development, it's common to need to read and write data to files or block devices, and multithreading is often used to improve efficiency. Therefore, the `pread()` and `pwrite()` methods are frequently employed. The `pread()` and `pwrite()` system calls are particularly advantageous in multithreaded applications, allowing multiple threads to perform I / O operations on the same file descriptor, unaffected by changes to file offsets by other threads. In actual production environments, multiple threads may repeatedly read data from block device A and write it to block device B. Due to hardware performance limitations, during read / write operations, `pwrite()` may continuously wait for I / O returns, resulting in high CPU (Central Processing Unit) I / O wait times, which can severely impact the normal operation of other functions. Therefore, considering system load is essential when reading and writing data.
[0003] The commonly used technical approach is to first set the priority of read and write operations before reading and writing data, distinguishing them from the priority of other production operations, reducing the rate of read and write operations, and minimizing the impact on other operations.
[0004] However, prioritizing tasks based on business logic cannot fully utilize system resources and inevitably leads to resource waste. Setting priorities increases the difficulty for software users, and improper settings may still not prevent interference between business processes. Summary of the Invention
[0005] This application provides a method, apparatus, medium, and electronic device for dynamically adjusting read and write performance. When reading and writing data, the read and write rate is adjusted in a timely manner based on the real-time system load, which makes full use of system resources without affecting the normal operation of other services.
[0006] In a first aspect, embodiments of this application provide a method for dynamically adjusting read / write performance, the method comprising: Get the current number of CPU cores, CPU utilization, and initial average load of the system within a preset time period; The real-time load value of the current system is calculated based on the number of CPU cores, CPU utilization, and initial average load. The buffer size is adjusted using the real-time load value to dynamically adjust the read and write performance of the current system.
[0007] Secondly, embodiments of this application provide a device for dynamically adjusting read / write performance, the device comprising: The current system parameter acquisition unit is used to acquire the number of CPU cores, CPU utilization, and initial average load of the system within a preset time period. The real-time load value obtaining unit is used to calculate the real-time load value of the current system based on the number of CPU cores, CPU utilization, and initial average load. The buffer size adjustment unit is used to adjust the buffer size using the real-time load value in order to dynamically adjust the read and write performance of the current system.
[0008] Thirdly, embodiments of this application provide a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method for dynamically adjusting read and write performance as described in embodiments of this application.
[0009] Fourthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method for dynamically adjusting read and write performance as described in embodiments of this application.
[0010] The technical solution provided in this application obtains the number of CPU cores, CPU utilization, and initial average load of the system within a preset time period. Then, based on these parameters, the real-time load value of the current system is calculated. This real-time load value is then used to adjust the buffer size, thereby dynamically adjusting the read / write performance of the current system. This technical solution allows for timely adjustment of read / write rates based on the real-time system load during data read / write operations, thus fully utilizing system resources without affecting the normal operation of other services. Attached Figure Description
[0011] Figure 1 This is a flowchart of the method for dynamically adjusting read / write performance provided in Embodiment 1 of this application; Figure 2 This is a schematic diagram of the current system operating parameters provided in Embodiment 1 of this application; Figure 3 This is a schematic diagram of the process of dynamically adjusting read and write performance provided in Embodiment 2 of this application; Figure 4 This is a flowchart of dynamically adjusting read / write service performance provided in Embodiment 2 of this application; Figure 5 This is a flowchart of the system load analysis service provided in Embodiment 2 of this application; Figure 6This is a schematic diagram of the data read / write task provided in Example 2 of this application; Figure 7 This is a schematic diagram of the device for dynamically adjusting read / write performance provided in Embodiment 3 of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of this application. Detailed Implementation
[0012] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present application, not the entire structure.
[0013] Before discussing the exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. The process can be terminated when its operation is complete, but may also have additional steps not included in the figures. The process can correspond to a method, function, procedure, subroutine, subroutine, etc.
[0014] Example 1 Figure 1 This is a flowchart of a method for dynamically adjusting read and write performance provided in Embodiment 1 of this application. This embodiment can be applied to situations where the system read and write performance is adjusted in conjunction with the real-time system load. This method can be executed by the device for dynamically adjusting read and write performance provided in this embodiment of the application. The device can be implemented by software and / or hardware and can be integrated into devices such as smart terminals used for adjusting system read and write performance.
[0015] like Figure 1 As shown, the method for dynamically adjusting read / write performance includes: S110: Obtain the current number of CPU cores, CPU utilization, and initial average load of the system within a preset time period; The number of CPU cores indicates how many cores a CPU has. More cores mean a faster CPU and better performance. The number of CPU cores can be determined based on the hardware performance of the system; for example, it can have 2 cores or 4 cores.
[0016] In this embodiment, CPU utilization is used to characterize the CPU resources used by programs running on the system per unit of time. CPU utilization can be calculated based on the percentage of CPU idle time per second.
[0017] In this embodiment, the initial average load can refer to the average load over a period of time. The initial average load of the system within the preset time period can be one or more values. For example, the initial average load of the system within the preset time period can be the average load over the first minute of system operation, or it can be the average load over the first 10 minutes.
[0018] In this scheme, when a read / write task starts, a command can be sent to the current system to read the number of CPU cores, CPU utilization, and the initial average load of the system within a preset time period.
[0019] S120. Calculate the real-time load value of the current system based on the number of CPU cores, CPU utilization, and initial average load. Real-time load can refer to the total number of processes currently being executed by the CPU and those waiting to be executed by the CPU.
[0020] In this approach, for multi-core CPUs, theoretically, a load value equal to the number of CPU cores indicates that all CPUs are in use and no processes are waiting to be processed, meaning the system is fully utilized. A load value greater than the number of CPU cores indicates that processes are queuing and waiting for CPU processing, meaning insufficient system resources will affect program performance. A load value less than the number of CPU cores indicates that CPUs are idle, resulting in resource waste. However, in reality, CPU utilization and average load do not necessarily correspond perfectly. For example, CPU-intensive processes using a large amount of CPU will lead to an increase in average load, in which case the two values are consistent; I / O-intensive processes waiting for I / O will also lead to an increase in average load, but CPU utilization may not be very high; a large number of processes waiting for CPU scheduling will also lead to an increase in average load, and CPU utilization will also be relatively high. Therefore, to more accurately represent the current system operating state, it is necessary to analyze both average load and CPU utilization.
[0021] Specifically, the system average load can be calculated based on the number of CPU cores and the initial average load, and the real-time load of the current system can be calculated based on the system average load and the CPU utilization.
[0022] In this technical solution, optionally, the real-time load value of the current system is calculated based on the number of CPU cores, CPU utilization, and initial average load, including: Divide the initial average load by the number of CPU cores to obtain three ratios; The target average load value is obtained by weighting the three ratios. The real-time load value of the current system is calculated using the target average load value and the CPU utilization rate.
[0023] The target average load value can refer to the system average load value, which can be calculated based on the initial average load of the system in different time periods.
[0024] Preferably, the initial average load can be the average load value within the first minute of the current system operation, the average load value within the first 10 minutes, or the average load value within the first 15 minutes.
[0025] In this scheme, the initial average load is divided sequentially by the number of CPU cores, and the results of the division are weighted and combined according to different weight ratios to obtain the target average load value. The weight ratios can be set based on the average load time.
[0026] For example, the weighting of the average load value in the first minute can be set to 70%, the weighting of the average load value in the first 10 minutes to 20%, and the weighting of the average load value in the first 15 minutes to 10%. The target average load value can then be calculated using the following formula: ; in, The target average load value, This is the average load value over the previous minute. This is the average load value over the previous 10 minutes. This is the average load value over the previous 15 minutes. Number of central processing unit cores , , This represents the weighting ratio.
[0027] In this embodiment, the real-time load value of the current system is related to the average load value and the CPU utilization rate. Therefore, the real-time load value of the current system can be calculated based on the calculated target average load value and the number of CPU cores.
[0028] By calculating the real-time load value of the current system, the system's read and write performance can be adjusted based on the real-time load value, which makes full use of system resources without affecting the normal operation of other services.
[0029] In this technical solution, optionally, the real-time load value of the current system is calculated using the target average load value and the CPU utilization rate, including: The target average load value and the CPU utilization rate are weighted and combined to calculate the real-time load value of the current system.
[0030] The weighting coefficients can be set based on the correlation between the target average load value and the CPU utilization rate and the real-time load.
[0031] For example, the weighting factor for the target average load value can be set to 30%, and the weighting factor for the CPU utilization can be set to 70%.
[0032] By setting different weighting coefficients to combine the target average load value and the CPU utilization rate, the real-time load value of the current system is calculated. This takes into account both the hardware foundation and the system's business operation, thus improving the accuracy of the real-time load value calculation.
[0033] In this technical solution, optionally, the target average load value and the central processing unit utilization are weighted and combined to calculate the real-time load value of the current system, including: The real-time load value is calculated using the following formula: ; in, This is the real-time load value. The target average load value, For central processing unit utilization, and These are the weighting coefficients.
[0034] For example, Figure 2 This is a schematic diagram of the current system operating parameters provided in Embodiment 1 of this application, as shown below. Figure 2 As shown, the actual parameter settings are as follows: CCN is 4 cores; 1LA is 4.21, 10LA is 4.19, and 15LA is 4.18; CPU idle percentages are 96, 98, 98, 89, 99, 97, 98, 96, 99, and 97%. Therefore, the target average load value is: Central processing unit utilization rate: Real-time load value: The CPU utilization rate was calculated by removing the maximum and minimum values of CPU idle time during the calculation process.
[0035] By setting different weighting coefficients to combine the target average load value and the CPU utilization rate, the real-time load value of the current system is calculated. This takes into account both the hardware foundation and the system's business operation, thus improving the accuracy of the real-time load value calculation.
[0036] S130. Using the real-time load value, adjust the buffer size to dynamically adjust the read and write performance of the current system.
[0037] In this context, a buffer can refer to a specified amount of storage space reserved in memory for temporary storage of I / O data.
[0038] In this solution, as can be seen from the interface implementation of `pread` and `pwrite`, the performance of read and write operations, as well as their impact on the system, are mainly determined by two factors: the size of the buffer in each loop during read and write operations, and the interval between each loop. A larger buffer means a larger amount of data copied each time, resulting in longer read and write times, higher efficiency, but also higher system resource consumption. Conversely, a longer interval means a lower frequency of read and write operations, lower efficiency, but lower system resource consumption. Therefore, to balance read and write performance with system load, it is necessary to focus on these two key parameters.
[0039] In this embodiment, the buffer can be increased or decreased according to the real-time load value, and the interval time can adopt the preset system default value.
[0040] In this technical solution, optionally, adjusting the buffer size using the real-time load value includes: If the real-time load value meets the preset standard load value condition, the buffer is increased according to the predetermined current system controller parameters; wherein, the preset standard load value condition is determined based on the initial average load and the number of CPU cores; the current system controller parameters include proportional parameters, integral parameters and derivative parameters; If the real-time load value does not meet the preset standard load value condition, the buffer is reduced according to the predetermined current system controller parameters.
[0041] In this solution, a standard load value can be calculated according to a preset load value calculation formula, provided that the initial average load is equal to the number of CPU cores. Standard load value conditions are then set based on this standard load value. If the real-time load value is less than or equal to the standard load value, the real-time load value meets the preset standard load value conditions; if the real-time load value is greater than the standard load value, the real-time load value does not meet the preset standard load value conditions.
[0042] For example, if the initial average load value is equal to the number of CPU cores, the calculated target average load value is 100%. Assuming the CPU utilization rate is 70%, the calculated standard load value is 79%, and 79% can be set as the standard load value condition.
[0043] In this embodiment, the current system controller can be a PID controller. PID is an abbreviation for Proportional, Integral, and Differential. The PID control algorithm combines proportional, integral, and derivative components into one control algorithm. It is the most mature and widely used control algorithm in continuous systems. This control algorithm emerged in the 1930s and 40s and is suitable for situations where the model of the controlled object is not clearly understood. Practical experience and theoretical analysis both show that using this control law to control many industrial processes can achieve satisfactory results. The essence of PID control is to calculate the input deviation value according to the proportional, integral, and derivative functional relationship, and use the calculation result to control the output.
[0044] The control law of the PID controller is as follows: ; in, This refers to the proportional parameter of the controller. The deviation signal of a proportional control system. Once a deviation occurs, the controller immediately takes control action to reduce the deviation; The integral parameter of the controller is mainly used to eliminate steady-state error. The strength of the integral action depends on the integral time constant. The larger the integral time constant, the weaker the integral action, and vice versa. The differential parameter of the controller reflects the changing trend of the deviation signal and can introduce an effective early correction signal into the system before the deviation signal becomes too large, thereby speeding up the system's response and reducing the settling time.
[0045] In the process of performing calculus operations, it is necessary to discretize the data. The resulting PID discretization formula is as follows: .
[0046] in, These are the system operating values calculated by the system.
[0047] First, data fitting and model building are performed. Then, the optimal PID parameters for the current hardware environment are trained, mainly using the formulas mentioned above. , and The system operating value is calculated based on the optimal PID parameters, and the buffer is adjusted based on the system operating value. The matching relationship between the calculated system operating value and the buffer size is predetermined.
[0048] By employing the PID algorithm, the optimal read and write parameters can be calculated quickly and stably, overcoming the problems of untimely adjustment and over-adjustment of the simple proportional adjustment algorithm.
[0049] In this technical solution, optionally, the process of determining the current system controller parameters includes: By performing data fitting on the pre-obtained buffer values and the corresponding real-time load values, at least one current system controller parameter can be obtained.
[0050] In this solution, the system load under different read / write parameters is tested based on the current hardware environment, and the key parameters in the PID formula are calculated. , and The calculation method is as follows: For intervals of 1ms, 10ms, and 100ms, calculate the system load corresponding to buffer sizes of 2Kb, 4Kb, 8Kb, 16Kb, 32Kb, 64Kb, 128Kb, 256Kb, 512Kb, and 1024KB, respectively. Then, perform data fitting, and based on the fitting results, adjust the PID formula accordingly. , and The calculations yielded the results. Multiple controller parameters can be calculated as different adjustment templates, and these templates can be switched. For example, three adjustment templates—high, medium, and low—can be calculated, with different templates adjusting the buffer speeds differently.
[0051] By employing the PID algorithm, the optimal read and write parameters can be calculated quickly and stably, overcoming the problems of untimely adjustment and over-adjustment of the simple proportional adjustment algorithm.
[0052] The technical solution provided in this application obtains the number of CPU cores, CPU utilization, and initial average load of the system within a preset time period. Then, based on these parameters, the real-time load value of the current system is calculated. Using this real-time load value, the buffer size is adjusted to dynamically adjust the read / write performance of the current system. By implementing this technical solution, the read / write rate can be improved by considering the real-time system load during data read / write operations. This fully utilizes system resources without affecting the normal operation of other services, and the dynamic, real-time adjustment reduces errors caused by human intervention.
[0053] Example 2 Figure 3This is a schematic diagram illustrating the process of dynamically adjusting read / write performance provided in Embodiment 2 of this application. Embodiment 2 further optimizes Embodiment 1. Specifically, the optimization includes: obtaining the current number of CPU cores, CPU utilization, and the initial average load of the system within a preset time period, including: if a start command is received from the thread business read / write module, then based on the system load analysis module, periodically obtaining the current number of CPU cores, CPU utilization, and the initial average load of the system within a preset time period; correspondingly, using the real-time load value, adjusting the buffer size to dynamically adjust the read / write performance of the current system, including: using the real-time load value to adjust the buffer size, and saving the adjusted buffer size to the shared memory module for the thread business read / write module to read the buffer size and dynamically adjust the read / write performance of the current system. For details not described in this embodiment, please refer to Embodiment 1. Figure 3 As shown, the method includes the following steps: S310. If a start command is received from the thread business read / write module, the current number of CPU cores, CPU utilization, and initial average load of the system within a preset time period are periodically obtained based on the system load analysis module.
[0054] In this solution, the system load analysis module, shared memory module, and thread-based business read / write module jointly adjust the system's read / write performance. Specifically, the system load analysis module periodically calculates the current load during read / write operations using a defined algorithm and considering the hardware infrastructure. Based on the load, it adjusts the buffer and updates the buffer size and pre-obtained waiting time in the shared memory module. The shared memory module stores the buffer size and waiting time. The thread-based business read / write module reads the buffer size and waiting time from the shared memory module and performs data read / write tasks.
[0055] For example, Figure 4 This is a flowchart of dynamically adjusting read / write service performance provided in Embodiment 2 of this application, as follows: Figure 4 As shown, the system load analysis module sets the buffer size and waiting time, and saves the buffer size and waiting time to the shared memory module. The thread business read and write module reads the buffer size and waiting time from the shared memory module and performs data read and write tasks.
[0056] Shared memory allows multiple processes to access the same memory space (usually called a segment). Since a shared memory segment is part of a process's user space memory, this IPC mechanism does not require kernel intervention. This technology was also designed to address the lower efficiency of other communication mechanisms. Its main working principle is that processes can "link" the same shared memory segment into their own address spaces, allowing all processes to access addresses within the shared memory. If a process writes data to this shared memory segment, the changes are immediately visible to other processes accessing the same shared memory segment. The use of shared memory significantly reduces memory consumption during large-scale data processing and is commonly used in production environments.
[0057] In this embodiment, during the development process, it is often necessary to read and write file or block device data, and multi-threading is used to improve efficiency.
[0058] The startup command can be composed of letters, numbers, or strings.
[0059] In this solution, during the read and write task, the thread business read and write module creates multiple threads and sends a start command to the system load analysis module. If the system analysis module receives the start command, it periodically obtains the current number of CPU cores, CPU utilization, and the initial average load of the system within a preset time period.
[0060] S320. Calculate the real-time load value of the current system based on the number of CPU cores, CPU utilization, and initial average load. S330. Using the real-time load value, adjust the buffer size and save the adjusted buffer size to the shared memory module so that the thread business read / write module can read the buffer size and dynamically adjust the current system's read / write performance.
[0061] In this embodiment, the system load analysis module adjusts the buffer size based on the calculated real-time load value and saves the adjusted buffer size to the shared memory module. The thread business read / write module reads and writes data based on the buffer size and waiting time, ensuring that the read / write business works normally. The read / write business no longer uses fixed parameters, but performs read / write based on the optimal parameters in the shared memory, thus improving the efficiency of read / write.
[0062] For example, Figure 5 This is a flowchart of the system load analysis service provided in Embodiment 2 of this application, as follows: Figure 5As shown, if the system analysis module does not receive a stop signal, it acquires the number of CPU cores, CPU utilization, and the initial average load of the system within a preset time period. Based on the number of CPU cores, CPU utilization, and the initial average load of the system within the preset time period, it calculates the real-time load value and determines whether the real-time load value meets the preset standard value condition, i.e., whether the current system is in a business peak. If so, the buffer is increased based on the PID parameter; if not, the buffer is decreased based on the PID parameter, and the adjusted parameters are updated in the shared memory module for dynamically adjusting the system read and write performance.
[0063] For example, Figure 6 This is a schematic diagram of the data read / write task provided in Example 2 of this application, as shown below. Figure 6 As shown, the thread-based business read / write module creates read / write tasks at the start of each task, divides these tasks into multiple threads, and initiates the system load service by sending a start command to the system load analysis module. The system load analysis module then saves the adjusted buffer size and pre-determined waiting time to the shared memory module. Next, it checks if all tasks are complete. If so, it sends a stop signal to the system load analysis module; otherwise, it reads the buffer size and waiting time from the shared memory module and begins the read / write task. Specifically, when creating a read / write task, the thread-based business read / write module retrieves the default buffer value and waiting time from the shared memory module to begin work and immediately notifies the system load analysis service to start.
[0064] The technical solution provided in this application, upon receiving a start command from the thread business read / write module, periodically acquires the current number of CPU cores, CPU utilization, and initial average load of the system within a preset time period based on the system load analysis module. It then calculates the real-time load value of the current system based on these parameters. Using this real-time load value, the buffer size is adjusted, and the adjusted buffer size is saved to the shared memory module for the thread business read / write module to read and dynamically adjust the system's read / write performance. By implementing this technical solution, the read / write rate can be improved by considering the real-time system load during data read / write operations. This fully utilizes system resources without affecting the normal operation of other services. Furthermore, the dynamic, real-time adjustment reduces errors caused by human intervention. Read / write operations no longer use fixed parameters but instead utilize the optimal parameters in the shared memory, thus improving read / write efficiency.
[0065] Example 3 Figure 7 This is a schematic diagram of the device for dynamically adjusting read / write performance provided in Embodiment 3 of this application, as shown below. Figure 7As shown, the device for dynamically adjusting read / write performance includes: The current system parameter acquisition unit 710 is used to acquire the number of CPU cores, CPU utilization, and initial average load of the system within a preset time period. The real-time load value obtaining unit 720 is used to calculate the real-time load value of the current system based on the number of CPU cores, CPU utilization, and initial average load. The buffer size adjustment unit 730 is used to adjust the buffer size using the real-time load value in order to dynamically adjust the read and write performance of the current system.
[0066] In this technical solution, optionally, the real-time load value acquisition unit 720 includes: The ratio calculation subunit is used to divide the initial average load and the number of CPU cores to obtain three ratios; The target average load value is obtained by sub-units, which are used to weight the three ratios to obtain the target average load value. The real-time load value calculation subunit is used to calculate the real-time load value of the current system using the target average load value and the CPU utilization rate.
[0067] In this technical solution, the optional real-time load value calculation subunit is specifically used for: The target average load value and the CPU utilization rate are weighted and combined to calculate the real-time load value of the current system.
[0068] In this technical solution, the optional real-time load value calculation subunit is specifically used for: The real-time load value is calculated using the following formula: ; in, This is the real-time load value. The target average load value, For central processing unit utilization, and These are the weighting coefficients.
[0069] In this technical solution, optionally, the buffer size adjustment unit 730 includes: The buffer enlargement subunit is used to enlarge the buffer according to the predetermined current system controller parameters when the real-time load value meets the preset standard load value condition; wherein, the preset standard load value condition is determined based on the initial average load and the number of CPU cores; the current system controller parameters include proportional parameters, integral parameters and derivative parameters; The buffer reduction subunit is used to reduce the buffer according to the predetermined current system controller parameters when the real-time load value does not meet the preset standard load value condition.
[0070] In this technical solution, optionally, the buffer enlargement subunit is specifically used for: By performing data fitting on the pre-obtained buffer values and the corresponding real-time load values, at least one current system controller parameter can be obtained.
[0071] In this technical solution, optionally, the current system parameter acquisition unit 710 is specifically used for: If a start command is received from the thread business read / write module, the system load analysis module will periodically obtain the current number of CPU cores, CPU utilization, and the initial average load of the system within a preset time period. Correspondingly, the buffer size adjustment unit 730 is specifically used for: Using the real-time load value, the buffer size is adjusted, and the adjusted buffer size is saved to the shared memory module so that the thread business read and write module can read the buffer size and dynamically adjust the current system's read and write performance.
[0072] The above-mentioned products can perform the methods provided in the embodiments of this application, and have the corresponding functional modules and beneficial effects of performing the methods.
[0073] Example 4 This application also provides a medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a method for dynamically adjusting read / write performance, the method comprising: Get the current number of CPU cores, CPU utilization, and initial average load of the system within a preset time period; The real-time load value of the current system is calculated based on the number of CPU cores, CPU utilization, and initial average load. The buffer size is adjusted using the real-time load value to dynamically adjust the read and write performance of the current system.
[0074] Media – any type of memory device or storage device. The term “media” is intended to include: mounting media, such as CD-ROMs, floppy disks, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDRRAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (e.g., hard disks or optical storage); registers or other similar types of memory elements, etc. Media may also include other types of memory or combinations thereof. Additionally, media may reside in the computer system in which the program is executed, or may reside in a different second computer system connected to the computer system via a network (such as the Internet). The second computer system may provide program instructions to the computer for execution. The term “media” may include two or more media that may reside in different locations (e.g., in different computer systems connected via a network). Media may store program instructions (e.g., specifically implemented as a computer program) that can be executed by one or more processors.
[0075] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the operation of dynamically adjusting read and write performance as described above, but can also perform related operations in the method of dynamically adjusting read and write performance provided in any embodiment of this application.
[0076] Example 5 This application provides an electronic device that can integrate the device for dynamically adjusting read and write performance provided in this application. Figure 8 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of this application. Figure 8 As shown, this embodiment provides an electronic device 800, which includes: one or more processors 820; and a storage device 810 for storing one or more programs. When the one or more programs are executed by the one or more processors 820, the one or more processors 820 implement the method for dynamically adjusting read and write performance provided in this embodiment, the method including: Get the current number of CPU cores, CPU utilization, and initial average load of the system within a preset time period; The real-time load value of the current system is calculated based on the number of CPU cores, CPU utilization, and initial average load. The buffer size is adjusted using the real-time load value to dynamically adjust the read and write performance of the current system.
[0077] Of course, those skilled in the art will understand that the processor 820 also implements the technical solution of the method for dynamically adjusting read and write performance provided in any embodiment of this application.
[0078] Figure 8 The electronic device 800 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0079] like Figure 8 As shown, the electronic device 800 includes a processor 820, a storage device 810, an input device 830, and an output device 840; the number of processors 820 in the electronic device can be one or more. Figure 4 Taking a processor 820 as an example; the processor 820, storage device 810, input device 830, and output device 840 in an electronic device can be connected via a bus or other means. Figure 8 Taking the connection between China and Israel via bus 850 as an example.
[0080] The storage device 810, as a computer-readable medium, can be used to store software programs, computer-executable programs, and module units, such as the program instructions corresponding to the method for dynamically adjusting read and write performance in the embodiments of this application.
[0081] Storage device 810 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on terminal usage. Furthermore, storage device 810 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, storage device 810 may further include memory remotely located relative to processor 420, and these remote memories can be connected via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0082] Input device 830 can be used to receive input digital, character, or voice information, and to generate key signal inputs related to user settings and function control of the electronic device. Output device 840 may include electronic devices such as a display screen and a speaker.
[0083] The electronic device provided in this application embodiment can adjust the read and write rate in a timely manner according to the real-time system load when performing data read and write, so as to make full use of system resources without affecting the normal operation of other services.
[0084] The apparatus, medium, and electronic device for dynamically adjusting read / write performance provided in the above embodiments can execute the method for dynamically adjusting read / write performance provided in any embodiment of this application, and have the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the method for dynamically adjusting read / write performance provided in any embodiment of this application.
[0085] Note that the above are merely preferred embodiments and the technical principles employed in this application. Those skilled in the art will understand that this application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the appended claims.
Claims
1. A method for dynamically adjusting read / write performance, characterized in that, include: Get the current number of CPU cores, CPU utilization, and initial average load of the system within a preset time period; The real-time load value of the current system is calculated based on the number of CPU cores, CPU utilization, and initial average load. The buffer size is adjusted using the real-time load value to dynamically adjust the read and write performance of the current system. The real-time load value of the current system is calculated based on the number of CPU cores, CPU utilization, and initial average load, including: Divide the initial average load by the number of CPU cores to obtain three ratios; wherein, the initial average load refers to the average load in the first minute, the average load in the first 10 minutes, and the average load in the first 15 minutes of the current system operation; The three ratios are weighted according to different weight ratios to obtain the target average load value; the real-time load value of the current system is calculated using the target average load value and the CPU utilization rate. The real-time load value of the current system is calculated using the target average load value and the CPU utilization rate, including: The target average load value and the CPU utilization rate are weighted and combined to calculate the real-time load value of the current system.
2. The method according to claim 1, characterized in that, The target average load value and the CPU utilization rate are weighted and combined to calculate the real-time load value of the current system, including: The real-time load value is calculated using the following formula: ; in, This is the real-time load value. The target average load value, For central processing unit utilization, and These are the weighting coefficients.
3. The method according to claim 1, characterized in that, Adjusting the buffer size using the real-time load value includes: If the real-time load value meets the preset standard load value condition, the buffer is increased according to the predetermined current system controller parameters; wherein, the preset standard load value condition is determined based on the initial average load and the number of CPU cores; the current system controller parameters include proportional parameters, integral parameters and derivative parameters; If the real-time load value does not meet the preset standard load value condition, the buffer is reduced according to the predetermined current system controller parameters.
4. The method according to claim 3, characterized in that, The process of determining the current system controller parameters includes: By performing data fitting on the pre-obtained buffer values and the corresponding real-time load values, at least one current system controller parameter can be obtained.
5. The method according to claim 1, characterized in that, Obtain the current number of CPU cores, CPU utilization, and the initial average load of the system over a preset time period, including: If a start command is received from the thread business read / write module, the system load analysis module will periodically obtain the current number of CPU cores, CPU utilization, and the initial average load of the system within a preset time period. Accordingly, the buffer size is adjusted using the real-time load value to dynamically adjust the read and write performance of the current system, including: Using the real-time load value, the buffer size is adjusted, and the adjusted buffer size is saved to the shared memory module so that the thread business read and write module can read the buffer size and dynamically adjust the current system's read and write performance.
6. A device for dynamically adjusting read / write performance, characterized in that, include: The current system parameter acquisition unit is used to acquire the number of CPU cores, CPU utilization, and initial average load of the system within a preset time period. The real-time load value obtaining unit is used to calculate the real-time load value of the current system based on the number of CPU cores, CPU utilization, and initial average load. A buffer size adjustment unit is used to adjust the buffer size using the real-time load value in order to dynamically adjust the read and write performance of the current system. The unit for obtaining real-time load value includes: The ratio calculation subunit is used to divide the initial average load and the number of CPU cores to obtain three ratios; wherein, the initial average load refers to the average load in the first minute, the average load in the first 10 minutes, and the average load in the first 15 minutes of the current system operation. The target average load value is obtained by sub-units, which are used to weight the three ratios according to different weight ratios to obtain the target average load value. The real-time load value calculation subunit is used to calculate the real-time load value of the current system using the target average load value and the CPU utilization rate. The real-time load value calculation subunit is specifically used for: The target average load value and the CPU utilization rate are weighted and combined to calculate the real-time load value of the current system.
7. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method for dynamically adjusting read and write performance as described in any one of claims 1-5.
8. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for dynamically adjusting read and write performance as described in any one of claims 1-5.