A thread pool tuning method, apparatus, device, and storage medium
By dynamically adjusting the number of threads in the thread pool using a multiple linear regression model, the problems of low resource utilization and poor stability in existing thread pool technologies are solved, achieving more efficient resource utilization and response speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-29
- Publication Date
- 2026-03-10
AI Technical Summary
Existing thread pool technology suffers from low resource utilization, inability to dynamically adjust and adapt to system changes, resulting in fixed resources, poor stability, and an inability to flexibly respond to sudden events or load fluctuations.
By using a multiple linear regression model to monitor system load, weight coefficients and load intercepts are calculated, and the number of threads in the thread pool is dynamically adjusted to adapt to system changes.
It enables the thread pool to adapt to system changes, reduces manual intervention, improves system resource utilization and response speed, and reduces maintenance costs.
Smart Images

Figure CN118012624B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a thread pool adjustment method and apparatus, an electronic device, and a storage medium. Background Technology
[0002] To improve business response speed or processing efficiency under limited resource conditions, most existing business systems use thread pool technology. However, to achieve high performance with existing thread pool technology, performance testing based on business load is required to find suitable thread pool parameters, which adds complexity to efficient and simple use.
[0003] Existing thread pool tuning techniques have the following shortcomings: they are complex to use, requiring business performance testing to find suitable thread pool quantity metrics; they require manual intervention for thread pool configuration and optimization; they have low resource utilization, as resources are fixed after initialization, making it impossible to effectively utilize system resources; they cannot guarantee stability, as they cannot dynamically adjust according to system load, which can easily lead to business anomalies; and they do not support adaptive system change adjustment, cannot dynamically adjust the number of thread pools according to system load, and cannot flexibly respond to sudden events or load fluctuations.
[0004] Therefore, the problem of how thread pools can adapt to system changes and be dynamically configured and optimized to effectively utilize system resources urgently needs to be solved. Summary of the Invention
[0005] This application provides a thread pool adjustment method to address the problem of how a thread pool can adapt to system changes and be dynamically configured and optimized to effectively utilize system resources.
[0006] Accordingly, embodiments of this application also provide a thread pool adjustment device, an electronic device, and a storage medium to ensure the implementation and application of the above methods.
[0007] To address the aforementioned problems, this application discloses a thread pool adjustment method, the method comprising:
[0008] The system load of the electronic device is monitored to obtain the monitoring index data corresponding to the system load within a first preset time range;
[0009] If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into the preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data.
[0010] The system load value corresponding to the system load is obtained based on the weighting coefficients corresponding to the monitoring indicator data.
[0011] Obtain the thread pool task type and load intercept of the thread pool of the electronic device; the load intercept is preset or calculated based on the multiple linear regression model;
[0012] Calculate the first total system load value based on the system load value, the thread pool task type, and the load intercept;
[0013] The number of threads in the thread pool is adjusted based on the first total system load value.
[0014] Optionally, the system load includes a central processing unit, a disk, memory, and a network interface card.
[0015] Optionally, after the monitoring electronic device obtains the monitoring index data corresponding to the system load within a first preset time range, the method further includes:
[0016] If the monitoring indicator data is not within the preset indicator range, then the monitoring indicator data with the largest value among the monitoring indicator data of the system load is obtained as the maximum monitoring indicator data.
[0017] The ratio of the monitoring index data of the system load to the maximum monitoring index data is used as the standardized monitoring index data of the system load.
[0018] The standardized monitoring index data of the system load is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the system load.
[0019] Optionally, calculating the total system load value based on the system load value, the thread pool task type, and the load intercept includes:
[0020] Calculate the intermediate system load value based on the system load value of the system load described above;
[0021] Set task weight coefficients according to the thread pool task types, and calculate the intermediate system load value by weighting according to the task weight coefficients;
[0022] The first total system load value is obtained by adding the weighted intermediate system load value to the load intercept.
[0023] Optionally, adjusting the number of threads in the thread pool based on the first total system load value includes:
[0024] Obtain the second total system load value within a second preset time range; wherein the second preset time range is earlier than the first preset time range;
[0025] The total system load value with the largest value in the second preset time range is taken as the maximum threshold, and the total system load value with the smallest value in the second preset time range is taken as the minimum threshold.
[0026] The number of threads in the thread pool is adjusted based on the first total system load value, the maximum threshold, and the minimum threshold.
[0027] Optionally, adjusting the number of threads in the thread pool based on the first total system load value, the maximum threshold, and the minimum threshold includes:
[0028] If the first total system load value is greater than or equal to the maximum threshold, the number of threads in the thread pool will be gradually reduced according to preset rules.
[0029] If the first total system load value is less than the minimum threshold, the number of threads in the thread pool will be gradually increased according to the preset rules.
[0030] Optionally, the formula for the multiple linear regression model is:
[0031] y = a + b1x1 + b2x2 + b3x3 + ... + b n *x n
[0032] Where y is the average task waiting time of the thread pool, a is the load intercept, and b1, b2, b3, ..., b n The weighting coefficients corresponding to the monitoring indicator data are x1, x2, x3, ..., x. n The monitoring indicator data.
[0033] This application also discloses a thread pool adjustment device, the device comprising:
[0034] The data monitoring module is used to monitor the system load of electronic devices and obtain monitoring index data corresponding to the system load within a first preset time range;
[0035] The multiple linear regression model module is used to input the monitoring indicator data into a preset multiple linear regression model and calculate the weight coefficients corresponding to the monitoring indicator data if the monitoring indicator data is within a preset indicator range.
[0036] The system load value calculation module is used to obtain the system load value corresponding to the system load based on the weight coefficients corresponding to the monitoring indicator data.
[0037] The parameter acquisition module is used to acquire the thread pool task type and load intercept of the thread pool of the electronic device; the load intercept is preset or calculated based on the multiple linear regression model.
[0038] The first total system load value calculation module is used to calculate the first total system load value based on the system load value of the system load, the thread pool task type and the load intercept.
[0039] The thread count adjustment module is used to adjust the number of threads in the thread pool according to the first total system load value.
[0040] This application also discloses an electronic device, including: a processor; and a memory storing executable code thereon, which, when executed, causes the processor to perform one or more thread pool adjustment methods as described in this application.
[0041] This application also discloses one or more machine-readable media storing executable code, which, when executed, causes a processor to perform one or more thread pool adjustment methods as described in this application.
[0042] Compared with the prior art, the embodiments of this application have the following advantages:
[0043] In this embodiment, the system load of the monitored electronic device is obtained by acquiring monitoring indicator data corresponding to the system load within a first preset time range. If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data. Based on the weight coefficients corresponding to the monitoring indicator data, the system load value corresponding to the system load is obtained, and the thread pool task type and load intercept of the electronic device's thread pool are acquired. The load intercept is preset or calculated based on the multiple linear regression model. A first total system load value is calculated based on the system load value, thread pool task type, and load intercept. The number of threads in the thread pool is adjusted based on the first total system load value. Dynamically and flexibly adjusting the number of threads in the thread pool according to the system load reduces the need for administrators or developers to manually intervene and optimize the thread pool, lowers maintenance costs, improves system response speed and processing capacity, and optimizes system resource utilization. Attached Figure Description
[0044] Figure 1 This is a flowchart illustrating the steps of an embodiment of a thread pool adjustment method according to this application;
[0045] Figure 2 This is a flowchart of the steps in an embodiment of the thread pool initialization S0 subprocess of this application;
[0046] Figure 3 This is a flowchart of the steps in an embodiment of the initialization monitoring task S1 sub-process of this application;
[0047] Figure 4This is a flowchart of the steps in an embodiment of the initialization monitoring manager S2 sub-process of this application;
[0048] Figure 5 This is a flowchart of the steps in an embodiment of the weight coefficient calculation S3 sub-process of this application;
[0049] Figure 6 This is a flowchart illustrating the steps of the weighted calculation of the total load weight S4 sub-process embodiment of this application;
[0050] Figure 7 This is a system architecture design diagram of another embodiment of the thread pool adjustment method of this application;
[0051] Figure 8 This is a class design diagram of another embodiment of the thread pool adjustment method of this application;
[0052] Figure 9 This is a flowchart illustrating a specific implementation of a thread pool adjustment method according to this application;
[0053] Figure 10 This is a structural block diagram of an embodiment of a thread pool adjustment device according to this application;
[0054] Figure 11 This is a schematic diagram of the structure of a device provided in an embodiment of this application. Detailed Implementation
[0055] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0056] Reference Figure 1 This is a flowchart illustrating the steps of an embodiment of a thread pool adjustment method according to this application, including the following steps:
[0057] Step 101: Monitor the system load of the electronic device to obtain the monitoring index data corresponding to the system load within a first preset time range;
[0058] Step 102: If the monitoring indicator data is within the preset indicator range, then input the monitoring indicator data into the preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data.
[0059] Step 103: Obtain the system load value corresponding to the system load based on the weighting coefficients corresponding to the monitoring indicator data;
[0060] Step 104: Obtain the thread pool task type and load intercept of the thread pool of the electronic device; the load intercept is preset or calculated based on the multiple linear regression model.
[0061] Step 105: Calculate the first total system load value based on the system load value, the thread pool task type, and the load intercept;
[0062] Step 106: Adjust the number of threads in the thread pool according to the first total system load value.
[0063] In step 101, the system load of the monitoring electronic device is obtained by obtaining the monitoring index data corresponding to the system load within a first preset time range.
[0064] This application sets up a system indicator monitoring task to monitor and collect business indicator data of electronic devices within a first preset time range. In one embodiment of this application, the first preset time range can be set to 30 minutes, and monitoring indicator data corresponding to system load is collected every 5 minutes.
[0065] The monitoring metrics data may include the following parameters:
[0066] CPU (Central Processing Unit) load value: Statistics on the sum of the number of processes that the CPU is processing and the number of processes waiting for the CPU to process over a period of time.
[0067] CPU utilization: The amount of CPU time slices used by a program.
[0068] Average disk read rate: The average ratio of the disk read rate to the maximum disk read rate within a specified time range.
[0069] Average disk write percentage: The average ratio of the disk write rate to the maximum disk write rate within a specified time range.
[0070] Operating system memory usage: The ratio of total memory used by the operating system within a specified time range.
[0071] JVM (Java Virtual Machine) memory usage: JVM is the virtual runtime environment for Java (an object-oriented programming language); JVM memory usage is the ratio of JVM memory usage to the maximum JVM memory size within a specified time range.
[0072] Average network bandwidth percentage: The average ratio of the network's average receiving rate to the sum of the receiving rates within a specified time range, representing the maximum network bandwidth usage.
[0073] Average completion rate of thread pool tasks: The average ratio of the number of completed tasks to the total number of submitted tasks within a specified time range.
[0074] Thread pool average utilization: The average ratio of the number of threads running in the thread pool to the total number of threads in the thread pool within a specified time range.
[0075] Average task execution time: The average execution time of thread pool tasks within a specified time range.
[0076] The parameters mentioned above are for illustrative purposes only. The monitoring indicator data described in this application can be set according to actual needs, and this application embodiment does not limit this.
[0077] Optionally, refer to Figure 2 Before step 101, the thread pool initialization S0 sub-process is executed.
[0078] In the embodiments of this application, the thread pool initialization S0 sub-process can specifically include the following steps:
[0079] Obtain the number of CPUs. In this embodiment, it is assumed that the number of CPUs obtained is N.
[0080] Set the core thread count of the thread pool to N; set the maximum thread count of the thread pool to 2*N. This value is a required parameter for the thread pool, that is, the initial default maximum value. When the thread pool is adjusted according to the load, this value will always be twice the core thread count after the adjustment.
[0081] Determine if a task queue size has been specified. If not, create an unbounded task queue first, then execute the following steps; if yes, execute the following steps directly.
[0082] The thread pool object is instantiated based on the core thread count, maximum thread count, and task queue; that is, objects are created using classes in object-oriented programming. The `execute` method (a function or procedure for executing specific tasks or operations) is overridden to encapsulate the user-submitted asynchronous task object and the thread pool's thread control object. The `execute` method is a utility class method from the JDK (Java Development Kit, primarily used for Java applications on mobile and embedded devices), mainly used to execute tasks submitted to the thread pool. This design encapsulates custom logic and reuses utility class methods to monitor thread pool task metrics.
[0083] This concludes the S0 subprocess.
[0084] Optionally, refer to Figure 3 Before step 101, execute the initialization monitoring task S1 sub-process.
[0085] In the embodiments of this application, the initialization of the monitoring task S1 sub-process can specifically include the following steps:
[0086] Initialize the CPU metrics monitor, disk metrics monitor, memory metrics monitor, network interface card metrics monitor, and thread pool metrics monitor, and complete the corresponding object instantiation.
[0087] The initialization of the aforementioned indicator monitor can be set according to actual needs, and this application embodiment does not impose any restrictions on this.
[0088] This concludes the S1 subprocess.
[0089] Optionally, refer to Figure 4 Before step 101, execute the initialization monitoring manager S2 sub-process.
[0090] In the embodiments of this application, the initialization of the monitoring manager S2 sub-process can specifically include the following steps:
[0091] Instantiate the system monitoring manager object.
[0092] Register all monitoring task objects in the S1 sub-process to the system monitoring manager object, and instantiate a timer scheduler object. In this embodiment, the timer scheduler can represent a timed task manager, used to execute a task at a fixed time.
[0093] All monitoring tasks are packaged into asynchronous tasks, and the packaged asynchronous tasks are executed through a timer to start all monitoring tasks and begin executing step 101 to collect the corresponding business indicator data; then the weight coefficient calculation S3 sub-process is executed periodically.
[0094] The S2 sub-process has now been completed.
[0095] In step 102, if the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into the preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data.
[0096] After collecting all monitoring task indicator data within a specified time range, determine whether each monitoring indicator data at the same time is within the preset indicator range. If so, input the monitoring indicator data into the preset multiple linear regression model, and calculate the weight coefficients corresponding to each monitoring indicator data through the multiple linear regression model.
[0097] Optionally, the load intercept can be calculated simultaneously when calculating the weight coefficients corresponding to the monitoring metric data. In this application, the load intercept is the thread pool's safety net design parameter, which is equivalent to the initially set default thread pool load size, when the calculated weight coefficients are all 0. This is the thread pool's safety net design parameter when all calculated weight coefficients are 0.
[0098] In one embodiment, reference is made to... Figure 5Step 102 can be executed by calculating the S3 subprocess using weighting coefficients.
[0099] In the embodiments of this application, the weight coefficient calculation S3 sub-process can specifically include the following steps:
[0100] Retrieve historical data for all monitoring task metrics within a specified time range. In this embodiment, it can be configured to retrieve all monitoring task metric data within a 30-minute period, with a set of monitoring task metric data retrieved every 5 minutes.
[0101] Determine whether each monitoring indicator data is greater than 0 and less than 1 at the same time. If not, standardize the data by taking the ratio of the monitoring indicator data to the maximum monitoring indicator data within the specified time range as the standardized monitoring indicator data and inputting it into the equation for calculation. If yes, directly input the data into the equation for calculation.
[0102] The input equation is y = a + b1*x1 + b2*x2 + b3*x3 + ... + bn*xn, where y is the average task waiting time in the thread pool, b1, b2, b3, ..., bn are the weight coefficients of the monitoring tasks, x1, x2, ..., xn are the metric values of the monitoring tasks, and a is the load intercept. The average task waiting time in the thread pool is the average time taken within a specified time range, calculated by subtracting the task submission time from the start execution time of each task. The corresponding weight coefficients are then calculated based on the equation.
[0103] The S3 sub-process has now been completed.
[0104] In step 103, the system load value corresponding to the system load is obtained according to the weight coefficients corresponding to the monitoring index data.
[0105] In the embodiments of this application, after calculating the weight coefficients corresponding to each monitoring indicator data, the system load value corresponding to the system load is calculated based on the corresponding weight coefficients, that is, the system load value corresponding to different monitoring tasks is calculated. Each monitoring task may include multiple monitoring indicator data, and the system load value corresponding to the monitoring task is obtained by adding the load values corresponding to the multiple monitoring indicator data calculated according to their respective weight coefficients.
[0106] In one embodiment, the monitoring task may be a CPU monitoring task, which may include monitoring metrics data such as CPU load value and CPU utilization. The load value of the CPU monitoring task can be calculated using the following formula:
[0107] CPU monitoring task load value = (CPU load value * weight coefficient 1 + CPU utilization * weight coefficient 2)
[0108] Weight coefficient 1 is the weight coefficient corresponding to the CPU load value, and weight coefficient 2 is the weight coefficient corresponding to the CPU utilization rate.
[0109] In step 104, the thread pool task type and load intercept of the thread pool of the electronic device are obtained; the load intercept is preset or calculated based on the multiple linear regression model.
[0110] The thread pool task types and load intercepts of the electronic device's thread pool are obtained. In this embodiment, thread pool task types can be divided into CPU-intensive tasks, I / O-intensive tasks, and other tasks. CPU-intensive tasks are those where CPU utilization is consistently high (approaching or reaching 100%) during execution, while I / O (input / output) latency is short and disk and network activity is infrequent. I / O-intensive tasks are those where CPU utilization is not very high during execution, but I / O latency is long, and significant disk read / write or network activity is observed. Other tasks are task types that do not fall into either of the above two categories. This application does not limit the classification of thread pool task types; those skilled in the art can set them according to actual needs.
[0111] The load intercept can be preset or calculated based on a multiple linear regression model. In this embodiment, the load intercept can be calculated by the multiple linear regression model when calculating the weight coefficients corresponding to the monitoring indicator data; it can also be set according to actual needs, and a preset load intercept can also be directly used in the calculation process of the weight coefficients corresponding to the monitoring indicator data.
[0112] In step 105, a first total system load value is calculated based on the system load value, the thread pool task type, and the load intercept.
[0113] The first total system load value is calculated based on the system load value, thread pool task type, and load intercept mentioned above. The system load values corresponding to each monitoring task are summed to obtain the intermediate total system load value. A corresponding weighting coefficient is set according to the thread pool task type; for example, a weighting coefficient of N is assigned to CPU-intensive tasks, M to I / O-intensive tasks, and K to other tasks. The intermediate total system load value, after being weighted using the weighting coefficients corresponding to the thread pool task types, is added to the load intercept to obtain the first total system load value.
[0114] Optionally, refer to Figure 6 Steps 103, 104, and 105 can be executed through the weighted calculation of the total load weight S4 sub-process.
[0115] In the embodiments of this application, the weighted calculation of the total load weight S4 sub-process can specifically include the following steps:
[0116] The system monitoring administrator obtains the set of all monitoring task indicator collection objects and the time range for which statistical data needs to be collected. In this embodiment, after obtaining the set of all monitoring task indicator collection objects, if the time range for which statistical data needs to be collected is determined to be 30 minutes, then the corresponding monitoring indicator data is determined from the set of all monitoring task indicator collection objects.
[0117] Iterate through the collection of monitoring task metric objects, calculate the load value of each monitoring task based on the weight coefficient corresponding to each monitoring metric data, and then sum the load values of each monitoring task to calculate the total load of all monitoring tasks.
[0118] The thread pool task type is determined based on the monitoring task metrics in the monitoring task metric object set. First, it is determined whether the task type is a CPU-intensive task. If not, it is determined whether it is an I / O-intensive task. Different weight coefficients N are assigned to different task types, and the weight coefficients N are used to perform a weighted calculation with the total load of all monitoring tasks.
[0119] The total weight value is obtained by adding the weight B (i.e., the load intercept is B) to the calculation result.
[0120] The S4 sub-process has now been completed.
[0121] In step 106, the number of threads in the thread pool is adjusted according to the first total system load value.
[0122] In this embodiment of the application, after calculating the first total system load value, the number of threads in the thread pool can be adjusted according to the first total system load value. Optionally, the number of threads in the thread pool can be reduced when the first total system load value is too high; the number of threads in the thread pool can be increased when the first total system load value is too low; and the number of threads in the thread pool can be left unchanged when the first total system load value is within a preset range.
[0123] In this embodiment, the system load of the monitored electronic device is obtained by acquiring monitoring indicator data corresponding to the system load within a first preset time range. If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data. Based on the weight coefficients corresponding to the monitoring indicator data, the system load value corresponding to the system load is obtained, and the thread pool task type and load intercept of the electronic device's thread pool are acquired. The load intercept is preset or calculated based on the multiple linear regression model. A first total system load value is calculated based on the system load value, thread pool task type, and load intercept. The number of threads in the thread pool is adjusted based on the first total system load value. Dynamically and flexibly adjusting the number of threads in the thread pool according to the system load reduces the need for administrators or developers to manually intervene and optimize the thread pool, lowers maintenance costs, improves system response speed and processing capacity, and optimizes system resource utilization.
[0124] In one embodiment of this application, the system load includes a central processing unit, a disk, memory, and a network interface card.
[0125] In this embodiment, metrics of the central processing unit, disk, memory, and network card are monitored, and corresponding monitoring metric data is collected. Furthermore, the weight values are adjusted based on changes in the monitoring metric data, thereby adjusting the number of threads in the thread pool. This allows the application to flexibly adjust according to real-time load and performance metrics to cope with sudden events and load fluctuations.
[0126] In one embodiment of this application, after the monitoring electronic device obtains the monitoring index data corresponding to the system load within a first preset time range, the method further includes:
[0127] If the monitoring indicator data is not within the preset indicator range, then the monitoring indicator data with the largest value among the monitoring indicator data of the system load is obtained as the maximum monitoring indicator data.
[0128] The ratio of the monitoring index data of the system load to the maximum monitoring index data is used as the standardized monitoring index data of the system load.
[0129] The standardized monitoring index data of the system load is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the system load.
[0130] After collecting monitoring indicator data, this application compares it with a preset indicator range. If the data is not within the preset range, it needs to be standardized. First, the monitoring indicator data with the largest value that is within the preset range is obtained from the monitoring indicator data of system load within a first preset time range and is taken as the maximum monitoring indicator data. Then, the ratio of the monitoring indicator data that exceeds the preset range to the maximum monitoring indicator data is calculated. The calculation result is used as the standardized monitoring indicator data and input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the system load.
[0131] In one embodiment, the preset index range can be 0 to 1. If the monitored index data is greater than 1, it exceeds the preset index range and requires standardized data processing. The first preset time range can be 30 minutes. All values of the monitored index data within 30 minutes are obtained, and the largest value between 0 and 1 is taken as the maximum monitored index data. The ratio of the monitored index data greater than 1 to the maximum monitored index data is calculated; this ratio is always less than 1, thus completing the data standardization for subsequent input into a preset multiple linear regression model.
[0132] In one embodiment of this application, calculating the first total system load value based on the system load value, the thread pool task type, and the load intercept includes:
[0133] Calculate the intermediate system load value based on the system load value of the system load described above;
[0134] Set task weight coefficients according to the thread pool task types, and calculate the intermediate system load value by weighting according to the task weight coefficients;
[0135] The first total system load value is obtained by adding the weighted intermediate system load value to the load intercept.
[0136] In this embodiment, after obtaining the system load value, thread pool task type, and load intercept, a first total system load value can be calculated. Specifically, firstly, the system load values corresponding to different monitoring tasks can be added together to calculate an intermediate system load value; then, different weights are set according to different task types to perform a weighted calculation of the intermediate system load value; finally, the load intercept is added to obtain the first total system load value. The embodiments of this application can adapt to CPU-intensive tasks, I / O-intensive tasks, or other mixed tasks, balancing multi-task processing in a concurrent environment.
[0137] In one embodiment of this application, adjusting the number of threads in the thread pool based on the first total system load value includes:
[0138] Obtain the second total system load value within a second preset time range; wherein the second preset time range is earlier than the first preset time range;
[0139] The total system load value with the largest value in the second preset time range is taken as the maximum threshold, and the total system load value with the smallest value in the second preset time range is taken as the minimum threshold.
[0140] The number of threads in the thread pool is adjusted based on the first total system load value, the maximum threshold, and the minimum threshold.
[0141] In this embodiment, a second total system load value within a second preset time range is obtained. The second preset time range is earlier than the first preset time range. Then, the maximum and minimum second total system load values within the second preset time range are obtained and used as the maximum and minimum thresholds, respectively. In one embodiment, assuming all total system load values calculated within 30 minutes are obtained, the first preset time range can be set to 6~30 minutes, then the second preset time range can be set to 0~5 minutes, and the second total system load value is the total system load value calculated during this time period. Furthermore, the maximum and minimum values among the second total system load values are obtained and used as the maximum and minimum thresholds, respectively.
[0142] In one embodiment of this application, adjusting the number of threads in the thread pool based on the first total system load value, the maximum threshold, and the minimum threshold includes:
[0143] If the first total system load value is greater than or equal to the maximum threshold, the number of threads in the thread pool will be gradually reduced according to preset rules.
[0144] If the first total system load value is less than the minimum threshold, the number of threads in the thread pool will be gradually increased according to the preset rules.
[0145] In this embodiment, if the first total system load value is greater than or equal to the maximum threshold, the number of threads in the thread pool is gradually reduced according to a preset rule. That is, a certain number of threads are reduced each time, and the total system load value is gradually reduced to less than the maximum threshold by reducing the number of threads multiple times. If the first total system load value is less than the minimum threshold, the number of threads in the thread pool is gradually increased according to a similar preset rule. Optionally, in one embodiment, if the first total system load value is greater than the maximum threshold, the number of threads can be reduced by X each time, instead of reducing the number of threads to the number that makes the total system load value lower than the maximum threshold all at once, to prevent excessive increase or decrease in the number of threads and improve stability.
[0146] In one embodiment of this application, the formula for the multiple linear regression model is:
[0147] y=a+b1*x1+b2*x2+b3*x3+…+bn*xn
[0148] Where y is the average task waiting time of the thread pool, a is the load intercept, b1, b2, b3, ..., bn are the weight coefficients corresponding to the monitoring indicator data, and x1, x2, x3, ..., xn are the monitoring indicator data.
[0149] In this embodiment, monitoring indicator data can be input into the equation set to calculate the weight coefficients corresponding to the monitoring indicator data; if no load intercept is set, the load intercept also needs to be calculated. In one embodiment, all monitoring indicator data within a first preset time range can be obtained first. Assuming the first preset time range is 0~30 minutes, and monitoring indicator data is collected every 5 minutes, 6 sets of monitoring indicator data can be obtained. The 6 sets of monitoring indicator data collected at different times are input into the equation set to form a system of 6 equations. Solving the system of equations yields the weight coefficients and load intercepts corresponding to the monitoring indicator data.
[0150] In this embodiment, the system load of the monitored electronic device is obtained by acquiring monitoring indicator data corresponding to the system load within a first preset time range. If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data. Based on the weight coefficients corresponding to the monitoring indicator data, the system load value corresponding to the system load is obtained, and the thread pool task type and load intercept of the electronic device's thread pool are acquired. The load intercept is preset or calculated based on the multiple linear regression model. A first total system load value is calculated based on the system load value, thread pool task type, and load intercept. The number of threads in the thread pool is adjusted based on the first total system load value. Dynamically and flexibly adjusting the number of threads in the thread pool according to the system load reduces the need for administrators or developers to manually intervene and optimize the thread pool, lowers maintenance costs, improves system response speed and processing capacity, and optimizes system resource utilization.
[0151] Reference Figure 7 The diagram shows a system architecture design of another embodiment of the thread pool adjustment method of this application.
[0152] In one embodiment, multiple system monitoring tasks can be set: CPU monitoring task, disk monitoring task, memory monitoring task, network monitoring task, and thread pool monitoring task. Based on these monitoring tasks, corresponding monitoring metric data is collected. The monitoring administrator can use the monitoring metric data to calculate the system load value and adjust the number of threads in the thread pool based on the calculation results. This can prevent system crashes or performance degradation due to excessive thread counts; system load helps maintain more stable performance. It can also reduce unnecessary resource consumption and energy usage; when the system load is low, the number of threads can be reduced, thus lowering resource consumption.
[0153] In this embodiment, the system load of the monitored electronic device is obtained by acquiring monitoring indicator data corresponding to the system load within a first preset time range. If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data. Based on the weight coefficients corresponding to the monitoring indicator data, the system load value corresponding to the system load is obtained, and the thread pool task type and load intercept of the electronic device's thread pool are acquired. The load intercept is preset or calculated based on the multiple linear regression model. A first total system load value is calculated based on the system load value, thread pool task type, and load intercept. The number of threads in the thread pool is adjusted based on the first total system load value. Dynamically and flexibly adjusting the number of threads in the thread pool according to the system load reduces the need for administrators or developers to manually intervene and optimize the thread pool, lowers maintenance costs, improves system response speed and processing capacity, and optimizes system resource utilization.
[0154] Reference Figure 8 The diagram shows a class design diagram of another embodiment of the thread pool adjustment method of this application.
[0155] In one embodiment, the following interface and implementation class can be set to implement some or all of the above thread pool adjustment methods.
[0156] Configure the metric monitoring interface, which includes `collectData` (responsible for collecting and storing monitoring metric data), `reportCollectData` (reporting collected monitoring metric data), `getLoad` (getting the load value of its own monitoring task), and `getType` (getting the specific monitoring task type, such as CPU type, memory type, etc.). This interface can be configured with the following implementation classes: `CpuMetricsMonitor` (CPU metric interface), `DiskMetricsMonitor` (disk metric interface), `MemoryMetricsMonitor` (memory metric interface), `NetworkMetricsMonitor` (network metric interface), and `ThreadPoolMetricsMonitor` (thread pool metric interface).
[0157] Furthermore, an interface for a metric monitoring manager that forms an aggregation relationship with the metric monitoring interface can be set. This interface includes `setMetricsMonitors` (responsible for registering metric monitoring interface information), `getMetricsMonitors` (retrieving monitoring metric data collected by the monitoring interface), `startMonitor` (starting the registered metric monitoring task), `stopMonitor` (stopping the registered metric monitoring task), `getSystemLoad` (responsible for retrieving the total weight or total load value of all metric monitoring tasks), `getScheduledTime` (the time period for load monitoring), and `getMetricsIntervalTime` (the time interval for monitoring tasks to collect metric data). This interface can be configured with the following implementation class: `SystemMetricsMonitorsManager` (responsible for implementing the specific methods of the metric monitoring manager interface).
[0158] Furthermore, a system load thread pool class that forms an aggregation relationship with the metrics monitoring manager interface can be set up, including: threadPoolExecutor (injects the JDK's built-in thread pool object properties and implements public methods), scheduler (a scheduled task scheduler used to periodically obtain monitoring load and adjust the number of threads), metricsMonitorManager (a metrics monitoring manager used to obtain monitoring load), initSystemMonitor (initializes monitoring tasks), startMonitor (starts the load scheduler monitoring tasks), adjustThreadPool (adjusts the number of threads in the thread pool to increase, decrease, or remain unchanged based on the monitoring load value), decreaseThreadPoolSize (responsible for decreasing the number of threads in the thread pool), increaseThreadPoolSize (responsible for increasing the number of threads in the thread pool), and Execute (responsible for executing thread pool tasks).
[0159] Furthermore, metric entity class interfaces that depend on the metric monitoring interface can be set, including: Metrics (basic information for monitoring metric identification), setStatsTime (records the current monitoring start time), and getStatsTime (gets the current monitoring start time). This interface can have the following implementation classes: CpuMetrics (stores basic CPU monitoring metric information), TaskMetrics (stores basic thread pool monitoring metric information), MemoryMetrics (stores basic memory monitoring metric information), NetworkMetrics (stores basic network monitoring metric information), and DiskMetrics (stores basic disk monitoring metric information).
[0160] The above interfaces and implementation classes are only examples in this embodiment. Those skilled in the art can configure and implement some or all of the above thread pool adjustment methods according to actual needs.
[0161] In this embodiment, the system load of the monitored electronic device is obtained by acquiring monitoring indicator data corresponding to the system load within a first preset time range. If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data. Based on the weight coefficients corresponding to the monitoring indicator data, the system load value corresponding to the system load is obtained, and the thread pool task type and load intercept of the electronic device's thread pool are acquired. The load intercept is preset or calculated based on the multiple linear regression model. A first total system load value is calculated based on the system load value, thread pool task type, and load intercept. The number of threads in the thread pool is adjusted based on the first total system load value. Dynamically and flexibly adjusting the number of threads in the thread pool according to the system load reduces the need for administrators or developers to manually intervene and optimize the thread pool, lowers maintenance costs, improves system response speed and processing capacity, and optimizes system resource utilization.
[0162] Reference Figure 9 The diagram illustrates a detailed implementation flowchart of an embodiment of a thread pool adjustment method according to this application.
[0163] First, the thread pool initialization sub-process S0 is executed, followed by the initialization monitoring task manager sub-process S2. Then, the thread pool load balancer is initialized, load monitoring tasks are executed periodically, and the weighted calculation of total load weight S4 sub-process is executed, obtaining the total system load based on system metrics monitoring manager. The total system load is compared with the maximum threshold; if it is greater than the maximum threshold, the number of thread pools is reduced; if it is less than the maximum threshold, and further, also less than the minimum threshold, the number of thread pools is increased.
[0164] In this embodiment, the system load of the monitored electronic device is obtained by acquiring monitoring indicator data corresponding to the system load within a first preset time range. If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data. Based on the weight coefficients corresponding to the monitoring indicator data, the system load value corresponding to the system load is obtained, and the thread pool task type and load intercept of the electronic device's thread pool are acquired. The load intercept is preset or calculated based on the multiple linear regression model. A first total system load value is calculated based on the system load value, thread pool task type, and load intercept. The number of threads in the thread pool is adjusted based on the first total system load value. Dynamically and flexibly adjusting the number of threads in the thread pool according to the system load reduces the need for administrators or developers to manually intervene and optimize the thread pool, lowers maintenance costs, improves system response speed and processing capacity, and optimizes system resource utilization.
[0165] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0166] Based on the above embodiments, this embodiment also provides a thread pool adjustment device, which is applied in terminal devices, servers and other electronic devices.
[0167] Reference Figure 10 The diagram illustrates a structural block diagram of an embodiment of a thread pool adjustment device according to this application, which may specifically include the following modules:
[0168] The data monitoring module 1001 is used to monitor the system load of electronic devices and obtain monitoring index data corresponding to the system load within a first preset time range.
[0169] The multiple linear regression model module 1002 is used to input the monitoring indicator data into a preset multiple linear regression model and calculate the weight coefficients corresponding to the monitoring indicator data if the monitoring indicator data is within a preset indicator range.
[0170] The system load value calculation module 1003 is used to obtain the system load value corresponding to the system load based on the weight coefficient corresponding to the monitoring indicator data.
[0171] The parameter acquisition module 1004 is used to acquire the thread pool task type and load intercept of the thread pool of the electronic device; the load intercept is preset or calculated based on the multiple linear regression model.
[0172] The first total system load value calculation module 1005 is used to calculate the first total system load value based on the system load value of the system load, the thread pool task type and the load intercept.
[0173] The thread count adjustment module 1006 is used to adjust the number of threads in the thread pool according to the first total system load value.
[0174] Optionally, the system load includes a central processing unit, a disk, memory, and a network interface card.
[0175] Optionally, the data monitoring module 1001 further includes:
[0176] The maximum monitoring indicator data determination module is used to obtain the monitoring indicator data with the largest value among the monitoring indicator data of the system load as the maximum monitoring indicator data if the monitoring indicator data is not within the preset indicator range.
[0177] The standardization module is used to take the ratio of the monitoring index data of the system load to the maximum monitoring index data as the standardized monitoring index data of the system load.
[0178] The weight coefficient calculation module is used to input the standardized monitoring index data of the system load into a preset multiple linear regression model to calculate the weight coefficients corresponding to the system load.
[0179] Optionally, the first total system load value calculation module 1005 further includes:
[0180] The intermediate system load value calculation module is used to calculate the intermediate system load value based on the system load value of the system load.
[0181] The task weight coefficient module is used to set the task weight coefficient according to the task type of the thread pool, and to calculate the intermediate system load value by weighting according to the task weight coefficient.
[0182] The load intercept module is used to add the weighted intermediate system load value to the load intercept to obtain the first total system load value.
[0183] Optionally, the thread count adjustment module 1006 further includes:
[0184] The second total system load value acquisition module is used to acquire the second total system load value within a second preset time range; wherein, the second preset time range is earlier than the first preset time range;
[0185] The threshold determination module is used to take the total system load value with the largest value in the second preset time range as the maximum threshold, and to take the total system load value with the smallest value in the second preset time range as the minimum threshold.
[0186] The thread pool adjustment module is used to adjust the number of threads in the thread pool based on the first total system load value, the maximum threshold, and the minimum threshold.
[0187] Optionally, the thread pool adjustment module further includes:
[0188] The thread count reduction module is used to gradually reduce the number of threads in the thread pool according to a preset rule if the first total system load value is greater than or equal to the maximum threshold.
[0189] The thread count increase module is used to gradually increase the number of threads in the thread pool according to the preset rules if the first total system load value is less than the minimum threshold.
[0190] Optionally, the formula for the multiple linear regression model is:
[0191] y=a+b1*x1+b2*x2+b3*x3+…+bn*xn
[0192] Where y is the average task waiting time of the thread pool, a is the load intercept, b1, b2, b3, ..., bn are the weight coefficients corresponding to the monitoring indicator data, and x1, x2, x3, ..., xn are the monitoring indicator data.
[0193] In this embodiment, the system load of the monitored electronic device is obtained by acquiring monitoring indicator data corresponding to the system load within a first preset time range. If the monitoring indicator data is within the preset indicator range, the monitoring indicator data is input into a preset multiple linear regression model to calculate the weight coefficients corresponding to the monitoring indicator data. Based on the weight coefficients corresponding to the monitoring indicator data, the system load value corresponding to the system load is obtained, and the thread pool task type and load intercept of the electronic device's thread pool are acquired. The load intercept is preset or calculated based on the multiple linear regression model. A first total system load value is calculated based on the system load value, thread pool task type, and load intercept. The number of threads in the thread pool is adjusted based on the first total system load value. Dynamically and flexibly adjusting the number of threads in the thread pool according to the system load reduces the need for administrators or developers to manually intervene and optimize the thread pool, lowers maintenance costs, improves system response speed and processing capacity, and optimizes system resource utilization.
[0194] This application also provides a non-volatile readable storage medium storing one or more modules (programs). When these modules are applied to a device, they enable the device to execute the instructions for the method steps in this application.
[0195] This application provides one or more machine-readable media storing instructions that, when executed by one or more processors, cause an electronic device to perform one or more of the methods described in the above embodiments. In this application, the electronic device includes various types of devices such as terminal devices and servers (clusters).
[0196] The embodiments of this disclosure can be implemented as an apparatus configured as desired using any suitable hardware, firmware, software, or any combination thereof, including electronic devices such as terminal devices, servers (clusters), etc. Figure 11 An exemplary apparatus 1100 is schematically shown that can be used to implement the various embodiments described in this application.
[0197] In one embodiment, Figure 11 An exemplary device 1100 is shown, which includes one or more processors 1102, a control module (chipset) 1104 coupled to at least one of the processors 1102, a memory 1106 coupled to the control module 1104, a non-volatile memory (NVM) / storage device 1108 coupled to the control module 1104, one or more input / output devices 1110 coupled to the control module 1104, and a network interface 1112 coupled to the control module 1104.
[0198] Processor 1102 may include one or more single-core or multi-core processors, and processor 1102 may include any combination of general-purpose processors or special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, device 1100 can serve as a terminal device, server (cluster), or other device as described in the embodiments of this application.
[0199] In some embodiments, apparatus 1100 may include one or more computer-readable media (e.g., memory 1106 or NVM / storage device 1108) having instructions 1114 and one or more processors 1102 that are combined with the one or more computer-readable media and configured to execute instructions 1114 to implement a module thereby performing the actions described in this disclosure.
[0200] In one embodiment, the control module 1104 may include any suitable interface controller to provide any suitable interface to at least one of the processors 1102 and / or any suitable device or component communicating with the control module 1104.
[0201] The control module 1104 may include a memory controller module to provide an interface to the memory 1106. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0202] Memory 1106 may be used, for example, to load and store data and / or instructions 1114 for device 1100. In one embodiment, memory 1106 may include any suitable volatile memory, such as suitable DRAM. In some embodiments, memory 1106 may include double data rate type quad synchronous dynamic random access memory (DDR4 SDRAM).
[0203] In one embodiment, the control module 1104 may include one or more input / output controllers to provide interfaces to the NVM / storage device 1108 and (one or more) input / output devices 1110.
[0204] For example, NVM / storage device 1108 may be used to store data and / or instructions 1114. NVM / storage device 1108 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable (one or more) non-volatile storage devices (e.g., one or more hard disk drive (HDD), one or more optical disc (CD) drives, and / or one or more digital universal optical disc (DVD) drives).
[0205] NVM / storage device 1108 may include storage resources that are physically part of a device on which device 1100 is mounted, or that can be accessed by the device without being part of the device. For example, NVM / storage device 1108 may be accessed via a network via one or more input / output devices 1110.
[0206] One or more input / output devices 1110 may provide an interface for device 1100 to communicate with any other suitable device. Input / output devices 1110 may include communication components, audio components, sensor components, etc. A network interface 1112 may provide an interface for device 1100 to communicate via one or more networks. Device 1100 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, such as accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof.
[0207] In one embodiment, at least one of the processors 1102 may be logically packaged with one or more controllers (e.g., memory controller modules) of the control module 1104. In one embodiment, at least one of the processors 1102 may be logically packaged with one or more controllers of the control module 1104 to form a system-in-package (SiP). In one embodiment, at least one of the processors 1102 may be integrated with the logic of one or more controllers of the control module 1104 on the same die. In one embodiment, at least one of the processors 1102 may be integrated with the logic of one or more controllers of the control module 1104 on the same die to form a system-on-a-chip (SoC).
[0208] In various embodiments, device 1100 may be, but is not limited to, a server, desktop computing device, or mobile computing device (e.g., laptop computing device, handheld computing device, tablet computer, netbook, etc.). In various embodiments, device 1100 may have more or fewer components and / or different architectures. For example, in some embodiments, device 1100 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touchscreen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.
[0209] The detection device can use a main control chip as a processor or control module, and sensor data, position information, etc. can be stored in a memory or NVM / storage device. The sensor group can be used as an input / output device, and the communication interface can include a network interface.
[0210] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0211] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0212] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable thread pool-tuned terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable thread pool-tuned terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0213] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable thread pool to adjust the terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0214] These computer program instructions can also be loaded onto a computer or other programmable thread pool adjustment terminal device, causing a series of operational steps to be performed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0215] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0216] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0217] The above provides a detailed description of a thread pool adjustment method and apparatus, an electronic device, and a storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A thread pool adjustment method, characterized in that, The method comprises: monitoring system load of an electronic device to obtain monitoring index data corresponding to the system load within a first preset time range; if the monitoring index data is within a preset index range, inputting the monitoring index data into a preset multiple linear regression model to calculate weight coefficients corresponding to the monitoring index data; obtaining a system load value corresponding to the system load according to the weight coefficients corresponding to the monitoring index data; obtaining thread pool task types and load intercepts of a thread pool of the electronic device; the load intercepts are preset or calculated according to the multiple linear regression model; calculating an intermediate system load value according to the system load value of the system load; setting task weight coefficients according to the thread pool task types and performing weighted calculation on the intermediate system load value according to the task weight coefficients; adding the intermediate system load value after the weighted calculation and the load intercept to obtain a first total system load value; adjusting the number of threads of the thread pool according to the first total system load value. The formula of the multiple linear regression model is: y=a+b1*x1+b2*x2+b3*x3+…+bn*xn wherein y is the average task waiting time of the thread pool, a is the load intercept, b1, b2, b3, …, bn are the weight coefficients corresponding to the monitoring index data, and x1, x2, x3, …, xn are the monitoring index data.
2. The method of claim 1, wherein, The system load comprises a central processing unit, a disk, a memory, and a network card.
3. The method of claim 1, wherein, After obtaining the monitoring index data corresponding to the system load of the electronic device within a first preset time range, the method further comprises: if the monitoring index data is not within a preset index range, obtaining the monitoring index data with the largest value among the monitoring index data of the system load as the maximum monitoring index data; taking the ratio of the monitoring index data of the system load to the maximum monitoring index data as the standardized monitoring index data of the system load; inputting the standardized monitoring index data of the system load into a preset multiple linear regression model to calculate the weight coefficients corresponding to the system load.
4. The method of claim 1, wherein, The adjustment of the number of threads of the thread pool according to the first total system load value comprises: obtaining a second total system load value within a second preset time range; wherein the second preset time range is earlier than the first preset time range; taking the total system load value with the largest value within the second preset time range as a maximum threshold value, and taking the total system load value with the smallest value within the second preset time range as a minimum threshold value; adjusting the number of threads of the thread pool according to the first total system load value, the maximum threshold value, and the minimum threshold value.
5. The method of claim 4, wherein, The adjustment of the number of threads of the thread pool according to the first total system load value, the maximum threshold value, and the minimum threshold value comprises: if the first total system load value is greater than or equal to the maximum threshold value, gradually reducing the number of threads of the thread pool according to a preset rule. If the first total system load value is less than the minimum threshold value, the number of threads of the thread pool is gradually increased according to the preset rule.
6. A thread pool adjustment apparatus, characterized by comprising: The device comprises: a data monitoring module configured to monitor system load of an electronic device to obtain monitoring index data corresponding to the system load in a first preset time range; a multiple linear regression model module configured to, if the monitoring index data is within a preset index range, input the monitoring index data into a preset multiple linear regression model, and calculate a weight coefficient corresponding to the monitoring index data; a system load value calculation module configured to obtain a system load value corresponding to the system load according to the weight coefficient corresponding to the monitoring index data; a parameter acquisition module configured to acquire a thread pool task type and a load intercept of a thread pool of the electronic device; the load intercept is pre-set or calculated according to the multiple linear regression model; an intermediate system load value calculation module configured to calculate an intermediate system load value according to the system load value of the system load; a task weight coefficient module configured to set a task weight coefficient according to the thread pool task type, and perform weighted calculation on the intermediate system load value according to the task weight coefficient; a load intercept module configured to add the intermediate system load value after the weighted calculation and the load intercept to obtain a first total system load value; a thread number adjustment module configured to adjust the number of threads of the thread pool according to the first total system load value. The formula of the multiple linear regression model is: y = a + b1*x1 + b2*x2 + b3*x3 + … + bn*xn wherein y is the average task waiting time of the thread pool, a is the load intercept, b1, b2, b3, …, bn are the weight coefficients corresponding to the monitoring index data, and x1, x2, x3, …, xn are the monitoring index data.
7. An electronic device, comprising: comprise: a processor; and a memory having executable code stored thereon, which, when executed, causes the processor to perform the thread pool adjustment method of one or more of claims 1-5.
8. One or more machine-readable media having stored thereon executable code that, when executed, cause a processor to perform the thread pool adjustment method of one or more of claims 1-5.
Citation Information
Patent Citations
Thread number control method and device, electronic equipment and medium
CN116610358A
Distributed shared memory
CN116774914A