CN-122019126-A - Thread pool optimization method, device, equipment and storage medium
Abstract
The invention provides a thread pool optimization method, a device, equipment and a storage medium, wherein the thread pool optimization method comprises the steps of obtaining state parameters of a thread pool and predicting the load change trend of the thread pool based on the state parameters and a load prediction model; and predicting a target configuration parameter of the thread pool based on the load change trend and a configuration parameter prediction model, and configuring the thread pool based on the target configuration parameter. According to the method, the future load change trend of the thread pool is predicted through the load prediction model and the state parameters of the thread pool, the corresponding target configuration parameters are predicted based on the change trend and the configuration parameter prediction model, and the thread pool is configured in advance through the target configuration parameters, so that the configured thread pool is accurately adapted to the future load demands.
Inventors
- ZHI YU
Assignees
- 北京卓益达科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251212
Claims (10)
- 1. A method for thread pool optimization, comprising: Acquiring state parameters of a thread pool, and predicting the load change trend of the thread pool based on the state parameters and a load prediction model; predicting a target configuration parameter of the thread pool based on the load change trend and a configuration parameter prediction model; And configuring the thread pool based on the target configuration parameters.
- 2. The thread pool optimization method of claim 1, wherein predicting a trend of load change of the thread pool based on the state parameters and a load prediction model comprises: and inputting the state parameters into the load prediction model to obtain the load change trend, wherein the state parameters comprise the number of threads, the queue capacity and the task execution time.
- 3. The thread pool optimization method of claim 1, wherein predicting the target configuration parameters of the thread pool based on the load trend and configuration parameter prediction model comprises: And inputting the load change trend into the configuration parameter prediction model to obtain the target configuration parameters, wherein the target configuration parameters comprise the number of core threads, the maximum number of threads, the task queue capacity and the thread idle recovery threshold.
- 4. The thread pool optimization method of claim 1, wherein after said configuring said thread pool based on said target configuration parameters, said method further comprises: acquiring a task to be executed, and determining a task type of the task to be executed; Determining a target task processing layer corresponding to the task to be executed based on the task type, wherein the target task processing layer comprises a first task processing layer based on a CPU or a second task processing layer based on a GPU in the thread pool; And allocating an independent thread queue for the task to be executed at the target task processing layer, and executing the task to be executed based on the independent thread queue.
- 5. The thread pool optimization method of claim 1, wherein after said configuring said thread pool based on said target configuration parameters, said method further comprises: Acquiring a task to be executed, and determining the priority of the task to be executed based on a task priority classifier; And determining a target thread sub-pool corresponding to the task to be executed based on the priority, and executing the task to be executed based on the target thread sub-pool.
- 6. The thread pool optimization method of claim 1, wherein after said configuring said thread pool based on said target configuration parameters, said method further comprises: acquiring container resources corresponding to the thread pool in a container; and adjusting the maximum thread number of the thread pool based on the container resource.
- 7. The thread pool optimization method of any one of claims 1 to 6, wherein after the configuring of the thread pool based on the target configuration parameters, the method further comprises: And acquiring the multidimensional thread parameters of the thread pool, and displaying the multidimensional thread parameters on a preset display page.
- 8. A thread pool optimization apparatus, comprising: The first acquisition module is configured to acquire state parameters of a thread pool and predict a load change trend of the thread pool based on the state parameters and a load prediction model; The prediction module is configured to predict target configuration parameters of the thread pool based on the load change trend and a configuration parameter prediction model; And the configuration module is configured to configure the thread pool based on the target configuration parameters.
- 9. An electronic device comprising a memory, a processor and a computer program stored on the memory and running on the processor, wherein the processor implements the thread pool optimization method of any one of claims 1 to 7 when executing the computer program.
- 10. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the thread pool optimization method of any one of claims 1 to 7.
Description
Thread pool optimization method, device, equipment and storage medium Technical Field The present invention relates to the field of computer technologies, and in particular, to a thread pool optimization method, apparatus, device, and storage medium. Background Thread pools are a form of multi-threaded processing in which tasks are added to a queue and then automatically started after a thread is created. The thread pool technology can remarkably improve the performance and stability of data processing, and becomes one of the infrastructures of modern high concurrency systems. However, the current thread pool technology has thread resource competition (such as registers and instruction queues), so that the configuration parameters of the thread pool need to be adjusted, but the existing parameter adjustment depends on manual experience, and meanwhile, the configuration parameters are fixed and cannot adapt to dynamic load, so that even after the configuration parameters of the thread pool are adjusted, the load requirements cannot be accurately adapted. Disclosure of Invention The invention provides a thread pool optimization method, a thread pool optimization device, thread pool optimization equipment and a storage medium, which are used for solving the defects in the prior art. The invention provides a thread pool optimization method, which comprises the following steps: Acquiring state parameters of a thread pool, and predicting the load change trend of the thread pool based on the state parameters and a load prediction model; predicting a target configuration parameter of the thread pool based on the load change trend and a configuration parameter prediction model; And configuring the thread pool based on the target configuration parameters. According to the thread pool optimization method provided by the invention, the load change trend of the thread pool is predicted based on the state parameter and the load prediction model, and the method comprises the following steps: and inputting the state parameters into the load prediction model to obtain the load change trend, wherein the state parameters comprise the number of threads, the queue capacity and the task execution time. According to the thread pool optimization method provided by the invention, the target configuration parameters of the thread pool are predicted based on the load change trend and the configuration parameter prediction model, and the method comprises the following steps: And inputting the load change trend into the configuration parameter prediction model to obtain the target configuration parameters, wherein the target configuration parameters comprise the number of core threads, the maximum number of threads, the task queue capacity and the thread idle recovery threshold. According to the thread pool optimization method provided by the invention, after the thread pool is configured based on the target configuration parameters, the method further comprises the following steps: acquiring a task to be executed, and determining a task type of the task to be executed; Determining a target task processing layer corresponding to the task to be executed based on the task type, wherein the target task processing layer comprises a first task processing layer based on a CPU or a second task processing layer based on a GPU in the thread pool; And allocating an independent thread queue for the task to be executed at the target task processing layer, and executing the task to be executed based on the independent thread queue. According to the thread pool optimization method provided by the invention, after the thread pool is configured based on the target configuration parameters, the method further comprises the following steps: Acquiring a task to be executed, and determining the priority of the task to be executed based on a task priority classifier; And determining a target thread sub-pool corresponding to the task to be executed based on the priority, and executing the task to be executed based on the target thread sub-pool. According to the thread pool optimization method provided by the invention, after the thread pool is configured based on the target configuration parameters, the method further comprises the following steps: acquiring container resources corresponding to the thread pool in a container; and adjusting the maximum thread number of the thread pool based on the container resource. According to the thread pool optimization method provided by the invention, after the thread pool is configured based on the target configuration parameters, the method further comprises the following steps: And acquiring the multidimensional thread parameters of the thread pool, and displaying the multidimensional thread parameters on a preset display page. The invention also provides a thread pool optimizing device, which comprises: The first acquisition module is configured to acquire state parameters of a thread pool and predict a load chang