CN117215800A - Dynamic thread control system - Google Patents

Dynamic thread control system Download PDF

Info

Publication number
CN117215800A
CN117215800A CN202311465573.7A CN202311465573A CN117215800A CN 117215800 A CN117215800 A CN 117215800A CN 202311465573 A CN202311465573 A CN 202311465573A CN 117215800 A CN117215800 A CN 117215800A
Authority
CN
China
Prior art keywords
thread
configuration
module
threads
latest
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311465573.7A
Other languages
Chinese (zh)
Inventor
许京奕
刁兴春
李梓煜
尹林茵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Big Data Advanced Technology Research Institute
Original Assignee
Beijing Big Data Advanced Technology Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Big Data Advanced Technology Research Institute filed Critical Beijing Big Data Advanced Technology Research Institute
Priority to CN202311465573.7A priority Critical patent/CN117215800A/en
Publication of CN117215800A publication Critical patent/CN117215800A/en
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application provides a dynamic thread control system, which relates to the technical field of thread control, and comprises: the management end is used for managing the thread configuration of the client; the dynamic configuration management end is used for pulling the latest thread configuration from the management end, comparing the latest thread configuration with the current thread configuration, and pushing the latest thread configuration to the client end under the condition that the latest thread configuration is inconsistent with the current thread configuration; and the client is used for managing the thread resources of the thread pool according to the latest thread configuration. The application realizes the operation of dynamically adjusting and interfacing the thread resource parameters through the management end, dynamically pulls the latest configuration from the management end through the dynamic configuration management end, compares the latest configuration with the current configuration, and if the latest configuration is inconsistent with the current configuration, the latest configuration is pushed to the client, and the client monitors and updates the latest configuration, thereby realizing the dynamic scheduling and management of the thread resource and improving the resource utilization rate.

Description

Dynamic thread control system
Technical Field
The application relates to the technical field of thread control, in particular to a dynamic thread control system.
Background
With the rapid development of the computer industry, multi-core CPUs are becoming the mainstream. Threads are the basic unit of CPU scheduling, and are the basic units of independent scheduling and dispatch by the system. In order to fully utilize the multi-core CPU resources of the computer, the mainstream operating system provides related methods for operating threads, task scheduling is carried out by using the threads, and corresponding interfaces are provided for managing the threads.
However, in a multi-threaded environment, the system is unable to determine how many tasks need to be performed and how many resources need to be devoted at any time, so it is difficult to achieve efficient thread resource management. In particular, applying for the resources corresponding to the threads wastes a large amount of computer CPU resources, and each thread needs time to make and destroy, if the task is simpler, the resources consumed by the making and destroying threads may be larger than the resources consumed by the threads to execute the task itself. In addition, too many threads occupy too much memory and cache resources, and the system becomes unstable while context switching is continuously performed among threads.
Therefore, it is necessary to develop a dynamic thread control system to realize dynamic management of thread resources and improve the utilization rate of thread resources.
Disclosure of Invention
In view of the above, embodiments of the present application provide a dynamic thread control system to overcome or at least partially solve the above problems.
In a first aspect of an embodiment of the present application, there is provided a dynamic thread control system, including:
the management end is used for managing the thread configuration of the client;
the dynamic configuration management end is used for pulling the latest thread configuration from the management end, comparing the latest thread configuration with the current thread configuration, and pushing the latest thread configuration to the client end under the condition that the latest thread configuration is inconsistent with the current thread configuration;
and the client is used for managing the thread resources of the thread pool according to the latest thread configuration.
In an alternative embodiment, the client includes:
the configuration monitoring module is used for monitoring the dynamic configuration management end so as to receive the latest thread configuration pushed by the dynamic configuration management end in real time;
the thread creation module is used for creating threads according to the latest thread configuration;
the thread destroying module is used for destroying threads according to the latest thread configuration;
and the configuration modification module is used for modifying the thread configuration and the thread parameters according to the latest thread configuration.
In an alternative embodiment, the management end includes:
the creation module is used for creating new thread configuration according to the creation operation triggered by the user;
the deleting module is used for deleting the appointed thread configuration according to the deleting operation triggered by the user;
the modification module is used for modifying the appointed thread configuration according to the modification operation triggered by the user;
and the viewing module is used for displaying the appointed thread configuration according to the viewing operation triggered by the user.
In an alternative embodiment, the client includes a task management module and a thread management module;
the task management module is used for generating tasks to be distributed according to the received user request;
the thread management module is used for distributing threads for the tasks to be distributed according to the condition of the thread pool.
In an alternative embodiment, the allocating a thread to the task to be allocated according to the situation of the thread pool includes:
under the condition that an idle thread exists in the thread pool, applying for a thread to execute the task to be allocated from the idle thread;
if no idle thread exists in the thread pool and the number of tasks to be allocated in a buffer queue does not reach a preset saturated number, adding the tasks to be allocated into the buffer queue;
and refusing to execute the tasks to be allocated under the condition that no idle thread exists in the thread pool and the number of the tasks to be allocated in the buffer queue reaches the preset saturated number.
In an alternative embodiment, in the case that a plurality of tasks to be allocated exist, the thread management module allocates threads for the tasks to be allocated according to the situation of the thread pool and priorities of the plurality of tasks to be allocated.
In an alternative embodiment, the thread management module is further configured to reclaim a first thread in the thread pool, where the first thread indicates that no thread to be allocated is obtained beyond a first duration.
In an alternative embodiment, the system further comprises: the task monitoring module and the operation monitoring module;
the task monitoring module is used for performing transaction monitoring according to application granularity, thread granularity and task granularity, and recording task execution information of the thread pool, wherein the task execution information comprises task execution conditions, maximum task execution time and average task execution time of each thread;
the operation monitoring module is used for monitoring the operations of creating the thread, modifying the thread and deleting the thread of the client, and sending corresponding operation notification to the working terminal.
In an alternative embodiment, the thread management module further comprises:
the application submodule is used for triggering a thread to increase application according to the task execution information;
the stop state judging submodule is used for terminating the thread increasing application when the thread pool is in a stop state, and maintaining the thread increasing application when the thread pool is not in the stop state;
the intermediate state judging submodule is used for judging whether to terminate the thread increasing application according to whether the thread is used for processing the residual task under the condition that the thread pool is in the stopping intermediate state, and maintaining the thread increasing application under the condition that the thread pool is not in the stopping intermediate state;
a thread number determining submodule, configured to determine the number of threads to be added according to the thread adding application;
the thread capacity determining submodule is used for judging whether the number of the added bus threads exceeds the preset maximum number of threads according to the determined number of the threads to be added; terminating the thread increasing application when the number of bus threads exceeds the maximum number of threads;
the system thread number determining submodule is used for judging whether the total thread number exceeds the system core number or not under the condition that the total thread number does not exceed the maximum thread number, and terminating the thread increasing application under the condition that the total thread number exceeds the system core number;
the thread registration sub-module is used for registering newly added threads when the total number of threads does not exceed the number of the system cores, completing thread addition when the thread registration is successful, and terminating the thread addition application;
and the thread state inquiring sub-module is used for inquiring the thread state under the condition that the thread registration fails, re-executing the thread quantity determining sub-module under the condition that the thread state is unchanged, and re-executing the stop state judging sub-module under the condition that the thread state is changed.
In an alternative embodiment, the system further comprises:
an operation log, configured to record a thread parameter modification record of the management end, where the operation record at least includes a modification time, a modification object, and a parameter value before modification;
and the permission checking module is used for checking the operation permission of the user at the management end.
The embodiment of the application provides a dynamic thread control system, which comprises: the management end is used for managing the thread configuration of the client; the dynamic configuration management end is used for pulling the latest thread configuration from the management end, comparing the latest thread configuration with the current thread configuration, and pushing the latest thread configuration to the client end under the condition that the latest thread configuration is inconsistent with the current thread configuration; and the client is used for managing the thread resources of the thread pool according to the latest thread configuration. The embodiment of the application utilizes the management end to uniformly manage the thread configuration of the client. The operation and maintenance personnel can modify related parameters through the interface operation of the management end according to specific computer configuration and the running state of the current program, then the dynamic configuration management end dynamically pulls the latest thread configuration from the management end, and then compares the latest thread configuration with the current thread configuration, if the latest thread configuration is inconsistent with the current thread configuration, the latest thread configuration is pushed to the client, and the client monitors and updates the latest thread configuration, so that the dynamic scheduling and management of the thread resources of the client are realized, and the resource utilization rate is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments of the present application will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a dynamic thread control system according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a pull and push process for a thread configuration according to an embodiment of the present application;
FIG. 3 is a flow chart of a thread addition according to an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings in the embodiments of the present application. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the application to those skilled in the art.
With the rapid development of the computer industry, moore's law gradually fails, and multi-core CPUs become the mainstream. Threads are the basic unit of CPU scheduling, and are the basic units of independent scheduling and dispatch by the system. In order to fully utilize the multi-core CPU resources of the computer, the mainstream operating systems on the market all provide related methods for operating threads, task scheduling is performed by using the threads, and the threads are managed through corresponding interfaces of various operating systems.
However, in a multi-threaded environment, the system is unable to determine how many tasks need to be performed and how many resources need to be devoted at any time. This uncertainty presents several problems for thread resource management: (1) Frequent application/destruction of resources and scheduling of resources will bring about additional consumption, which may be very large. Applying for the resources corresponding to the threads wastes a large amount of computer CPU resources, and each thread needs time to make and destroy, so that if the task is simpler, the resources consumed by the making and destroying threads may be larger than the resources consumed by the threads to execute the task. (2) The lack of a suppression means for the unlimited application of the resources is easy to cause the risk of system resource exhaustion. (3) The system cannot reasonably manage the internal resource distribution, and the stability of the system can be reduced. The excessive threads occupy excessive memory and cache resources, and the system becomes unstable when context switching is continuously performed among the threads.
In view of the above problems, an embodiment of the present application proposes a dynamic thread control system to solve the problems of undesirable thread resource management effects. The dynamic thread control system provided by the embodiment of the application is described in detail below through some embodiments and application scenarios thereof with reference to the accompanying drawings.
An embodiment of the present application provides a dynamic thread control system, referring to fig. 1, fig. 1 is a schematic structural diagram of the dynamic thread control system provided by the embodiment of the present application, as shown in fig. 1, where the method includes:
and the management end is used for managing the thread configuration of the client.
In this embodiment, the management end represents a terminal for managing thread configuration of the client, and may be an electronic device provided with a visual interface, such as a computer, a mobile phone, a tablet, or the like. And the operation and maintenance personnel view and modify the thread configuration of the client through the visual interface of the management end, so that unified management of the thread resources is realized. The thread refers to the minimum unit of operation scheduling of an operating system, multiple threads can be concurrent in one process, each thread is used for executing different tasks, the multiple threads share all system resources in the process, the threads can be kernel threads scheduled by the kernel of the operating system, and the thread configuration represents configuration related parameters of all thread resources of a client, including the kernel size of a thread pool, the maximum kernel size, the queue length and the like.
In an alternative embodiment, the management end includes:
the creation module is used for creating new thread configuration according to the creation operation triggered by the user;
the deleting module is used for deleting the appointed thread configuration according to the deleting operation triggered by the user;
the modification module is used for modifying the appointed thread configuration according to the modification operation triggered by the user;
and the viewing module is used for displaying the appointed thread configuration according to the viewing operation triggered by the user.
As shown in fig. 1, the management end mainly performs unified management on core parameters of threads, and main functional modules include: the system comprises a creation module, a deletion module, a modification module and a viewing module, wherein a user performs manual operation through an operation interface of a management end, and modification of the thread configuration selected by operation can be realized through the modules to generate a new thread configuration. The management end supports the dynamic adjustment and the interfacing operation of the thread resource parameters, realizes the unified management and configuration of the thread parameters, and reduces the modification cost of the thread parameters.
And the dynamic configuration management end is used for pulling the latest thread configuration from the management end, comparing the latest thread configuration with the current thread configuration, and pushing the latest thread configuration to the client end under the condition that the latest thread configuration is inconsistent with the current thread configuration.
In this embodiment, the dynamic configuration manager needs to dynamically pull the latest thread configuration from the manager in real time, considering that the user will modify the thread configuration of the manager at any time, where the latest thread configuration represents the thread configuration stored by the manager at the current time. Referring to fig. 2, fig. 2 shows a schematic drawing and pushing process of a thread configuration, as shown in fig. 2, where the management end performs corresponding modification on the thread configuration according to a modification thread request (node 1 in fig. 2), the dynamic configuration management end performs a timing task round, that is, performs a timing task once every a certain time interval, pulls from the management end to obtain the latest thread configuration (node 2 in fig. 2), for example, takes 29 seconds as a waiting period, takes 1 second as an inspection period, pulls from the management end to obtain the latest thread configuration in the inspection period, and compares the latest thread configuration with the current thread configuration. The current thread configuration represents the thread configuration obtained from the management end at the last time, or the thread configuration of the client at the current moment. If the two are different, the management end modifies the thread configuration in the period. In this case, the dynamic configuration manager stores the latest thread configuration as an event message, and issues the message through the API interface to push the latest thread configuration to the client (e.g., node 3 in fig. 2).
And the client is used for managing the thread resources of the thread pool according to the latest thread configuration.
The client is used for managing the thread resources of the thread pool, and the thread resources can be correspondingly adjusted according to the received latest thread configuration, and if the latest thread configuration is one thread less than the current thread configuration, the client correspondingly deletes the thread. As shown in fig. 2, after the client finishes the thread configuration modification, a notification of successful modification (such as node 4 in fig. 2) may be returned to the dynamic configuration manager, so that the dynamic configuration manager sends the notification message to the manager to notify relevant personnel that the thread configuration modification is completed. In addition, the client may persist information about the current thread configuration modification to a structured data store (e.g., node 5 in FIG. 2).
In an alternative embodiment, the client includes:
the configuration monitoring module is used for monitoring the dynamic configuration management end so as to receive the latest thread configuration pushed by the dynamic configuration management end in real time;
the thread creation module is used for creating threads according to the latest thread configuration;
the thread destroying module is used for destroying threads according to the latest thread configuration;
and the configuration modification module is used for modifying the thread configuration and the thread parameters according to the latest thread configuration.
The clients are the subject of executing programs, with the purpose of using multithreading mainly to make full use of the computing resources of the clients. As shown in fig. 1, in the dynamic thread control system, main functional modules of a client include: the device comprises a configuration monitoring module, a thread creation module, a thread destruction module and a configuration modification module. Specifically, the client monitors the dynamic configuration management end through the configuration monitoring module to receive the latest thread configuration pushed by the dynamic configuration management end in real time, and according to the difference between the latest thread configuration and the current thread configuration, the corresponding thread configuration updating operation is realized through the corresponding modules (the thread creation module, the thread destruction module and the configuration modification module).
The embodiment of the application utilizes the management end to uniformly manage the thread configuration of the client, a user can modify related parameters through the interface operation of the management end according to specific computer configuration and the running state of the current program, then the dynamic configuration management end dynamically pulls the latest thread configuration from the management end, and then the latest thread configuration is compared with the current thread configuration, if the latest thread configuration is inconsistent, the latest thread configuration is pushed to the client, and the client monitors and updates the latest thread configuration, thereby realizing the dynamic scheduling and uniform management of the thread resources of the client and improving the resource utilization rate.
In an alternative embodiment, the client includes a task management module and a thread management module;
the task management module is used for generating tasks to be distributed according to the received user request;
the thread management module is used for distributing threads for the tasks to be distributed according to the condition of the thread pool.
In this embodiment, the client is the subject of the execution program, and maintains a dynamic thread pool formed by a plurality of threads. In order to maintain the thread pool, the client also comprises a task management module and a thread management module, wherein the two modules form a producer consumer model, the task management module is the producer model and is used for mainly managing tasks of the client, for example, corresponding tasks to be distributed are generated according to received user requests; the thread management module is a consumer model and mainly performs thread management, corresponding threads are distributed to tasks to be distributed, which are generated by the task management module, according to the current practical use condition of a thread pool, and the created threads are repeatedly utilized through the idea of resource pooling, so that the loss caused by thread creation and destruction is reduced. Therefore, the thread and the task are decoupled and are not directly associated, so that the task is well buffered, the thread is multiplexed, and when the task arrives, the task can be immediately executed without waiting for the creation of the thread, thereby further improving the response speed.
In an alternative embodiment, the allocating a thread to the task to be allocated according to the situation of the thread pool includes:
under the condition that an idle thread exists in the thread pool, applying for a thread to execute the task to be allocated from the idle thread;
if no idle thread exists in the thread pool and the number of tasks to be allocated in a buffer queue does not reach a preset saturated number, adding the tasks to be allocated into the buffer queue;
and refusing to execute the tasks to be allocated under the condition that no idle thread exists in the thread pool and the number of the tasks to be allocated in the buffer queue reaches the preset saturated number.
In this embodiment, after the task management module submits the task to be allocated as the producer model, the thread management module determines the subsequent circulation of the task to be allocated. There are three possible circulation scenarios for this task. Specifically, under the condition that an idle thread exists in the thread pool, the thread management module directly applies for the thread from the idle thread so as to execute the task to be allocated. If all threads in the thread pool are executing other tasks and no idle threads exist, the number of tasks in the buffer queue needs to be determined. The buffer queue is a queue for buffering tasks not yet allocated with threads, and due to the limited capacity of the buffer queue, if the number of tasks in the queue is too large, part of tasks will wait for execution. Therefore, a preset saturation number is preset for the buffer queue, and the preset saturation number refers to the maximum number of tasks that can be buffered in the buffer queue. Under the condition that no idle thread exists in the thread pool, if the number of tasks to be allocated in the buffer queue does not reach the preset saturation number, the tasks to be allocated can be added into the buffer queue to wait for the allocation of threads; if the number of tasks to be allocated in the buffer queue reaches the preset saturation number, no task can be added into the buffer queue, in this case, the task management module refuses to execute the tasks to be allocated, and sends a refusal execution notification to the corresponding user terminal.
In an alternative embodiment, in the case that a plurality of tasks to be allocated exist, the thread management module allocates threads for the tasks to be allocated according to the situation of the thread pool and priorities of the plurality of tasks to be allocated.
In the actual application process, under the condition that the client is busy, the task management module may submit a plurality of tasks to be allocated simultaneously, in this case, if threads are allocated to the tasks only according to the time sequence of task submission, the processing lag of important tasks is easy to be caused. In this embodiment, in the case where there are a plurality of tasks to be allocated, the thread management module needs to allocate threads in combination with the actual situation of the thread pool and priorities of the plurality of tasks to be allocated. Specifically, when an idle thread exists in the thread pool, the idle thread is preferentially allocated to a task to be allocated with higher priority; when no idle thread exists in the thread pool and the number of tasks to be allocated in the buffer queue does not reach the preset saturated number, the tasks to be allocated with higher priority are preferentially added into the buffer queue. Therefore, under the condition that a plurality of tasks to be allocated exist, the threads can be preferentially allocated to the tasks to be allocated with higher priority, so that the important tasks can be preferentially processed, and the task processing efficiency is further improved.
In an alternative embodiment, the thread management module is further configured to reclaim a first thread in the thread pool, where the first thread indicates that no thread to be allocated is obtained beyond a first duration.
The task management module is used as a consumer model to distribute threads for each task to be distributed according to task requests, and when the threads execute the distributed tasks, the tasks become idle threads again, and the task management module continues to distribute new tasks to be distributed for the tasks. In the process, the thread does not acquire tasks all the time, if the duration exceeds the first duration, the number of tasks in the current client is reduced, the thread is idle, and the thread can be recycled and deleted without needing so many threads. The size of the first duration may be set according to actual requirements, and is not limited in this embodiment. Therefore, the embodiment carries out recovery management on the idle threads according to the time that the threads do not acquire the task, further dynamically controls the number of the threads, and improves the utilization rate of thread resources.
In an alternative embodiment, the system further comprises: the task monitoring module and the operation monitoring module;
the task monitoring module is used for performing transaction monitoring according to application granularity, thread granularity and task granularity, and recording task execution information of the thread pool, wherein the task execution information comprises task execution conditions, maximum task execution time and average task execution time of each thread;
the operation monitoring module is used for monitoring the operations of creating the thread, modifying the thread and deleting the thread of the client, and sending corresponding operation notification to the working terminal.
In this embodiment, the dynamic thread control system further includes a corresponding monitoring module (a task monitoring module and an operation monitoring module) for monitoring the relevant state of the thread control. Specifically, the task monitoring module monitors a thread pool of the client to obtain real-time task execution information of each thread, wherein the task execution condition of each thread represents the success rate of executing a task by the thread, the maximum task execution time represents the longest time spent in executing a plurality of tasks by the thread, and the average task execution time represents the time spent by the thread to execute a task on average. According to the task execution information, the real-time condition of the execution task of the thread pool is monitored, so that the state of the thread pool can be known in time.
In addition, in this embodiment, through the operation monitoring module, when the client monitors the modification of the thread (the operations of creating the thread, modifying the thread, and deleting the thread), the sending operation can be timely notified to the working terminal to notify the development responsible person of the application, so that the relevant staff can timely understand the operation of each thread modification. The thread management module is used for recovering the thread of which any task to be allocated is not acquired beyond the first time period, deleting the thread, monitoring the operation of the deleted thread by the operation monitoring module, and sending a deleted thread notification to a development responsible person. According to the embodiment, the thread operation monitoring is carried out through the operation monitoring module, when the thread pool is abnormal, the abnormal reasons can be traced back according to the monitored thread operation information, and the thread pool is maintained by workers.
In an alternative embodiment, the thread management module further comprises:
and the application submodule is used for triggering the thread to increase the application according to the task execution information. Referring to fig. 3, fig. 3 shows a flow chart of thread adding, and as shown in fig. 3, the application submodule determines that the thread needs to be added in the current state (for example, the number of tasks in the buffer queue continuously reaches a saturation state beyond a second duration) according to the monitored state of the thread pool (i.e., task execution information), and generates a thread adding application for applying for adding the thread.
And the stop state judging sub-module is used for terminating the thread increasing application when the thread pool is in a stop state, and maintaining the thread increasing application when the thread pool is not in a stop state. As shown in fig. 3, after the application for adding a thread is made, it is first determined whether the thread pool is in a stop state, if the thread pool is in a stop state, it means that there is no task to be executed in the current thread pool, and if no thread is needed to be added, the corresponding application for adding a thread is terminated, and a notification of thread addition failure is sent.
And the intermediate state judging sub-module is used for judging whether to terminate the thread increasing application according to whether the thread is used for processing the residual task when the thread pool is in the stopping intermediate state, and maintaining the thread increasing application when the thread pool is not in the stopping intermediate state. As shown in fig. 3, when the thread pool is not in a stopped state, it is further determined whether the thread pool is stopping. If the thread is not used for executing the residual task, the thread adding application flow is not needed, and the corresponding thread adding application is terminated, and a notification of thread adding failure is sent.
And the thread number determining submodule is used for determining the thread number (namely the acquired thread number in fig. 3) which needs to be increased according to the thread increasing application.
The thread capacity determining submodule is used for judging whether the number of the added bus threads exceeds the preset maximum number of threads according to the determined number of the threads to be added; and terminating the thread increasing application under the condition that the number of bus threads exceeds the maximum number of threads. It is known that threads are scarce resources, and if created without limit, not only would system resources be consumed, but also resource scheduling imbalance would be caused by unreasonable distribution of threads, reducing system stability. In order to prevent thread from being created without limitation, the present embodiment proposes a thread parameter of fixing the maximum thread usage amount, that is, the maximum thread number is preset, so that a submodule is determined by the thread capacity, as shown in fig. 3, whether the increased bus thread number exceeds the thread capacity (the preset maximum thread number), if the increased bus thread number exceeds the thread capacity, the thread increase application is terminated, and a notification of thread increase failure is sent.
And the system thread number determining submodule is used for judging whether the bus thread number exceeds the system core number under the condition that the bus thread number does not exceed the maximum thread number, and terminating the thread increasing application under the condition that the bus thread number exceeds the system core number. The embodiment also considers the upper limit of the system thread number, because the CPU resource of the client is limited and the CPU core number is limited, the system thread number determining submodule limits the thread number of the client to not exceed the CPU core number by comparing the total thread number with the system core number.
And the thread registration sub-module is used for registering the newly added thread under the condition that the total number of threads does not exceed the number of the system cores, completing the thread addition under the condition that the thread registration is successful, and terminating the thread addition application.
The thread state inquiry submodule is used for inquiring the thread state under the condition that the thread registration fails, re-executing the thread number determination submodule as shown in fig. 3 under the condition that the thread state is not changed, namely re-jumping to the step of determining the number of threads to be increased according to the thread increasing application, re-executing the subsequent steps according to the flow shown in fig. 3 until the thread adding or ending the thread increasing application is completed, and sending a notification of the thread increasing failure; and when the thread state is changed, re-executing the stopping state judging submodule as shown in fig. 3, namely re-jumping to execute the thread increasing application under the condition that the thread pool is in a stopping state, maintaining the step of the thread increasing application under the condition that the thread pool is not in the stopping state, re-executing the subsequent steps according to the flow shown in fig. 3 until the thread adding or the thread increasing application is completed, and sending a notification of thread increasing failure.
In an alternative embodiment, the system further comprises:
and the operation log is used for recording the thread parameter modification record of the management end, and the operation record at least comprises modification time, a modification object and a parameter value before modification. By looking up the operation log, the modification record of the thread pool parameter can be looked up, so that information such as what thread pool parameter is modified at what time, what parameter value before modification is, and the like can be known.
And the permission checking module is used for checking the operation permission of the user at the management end so as to improve the thread management security.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus, electronic devices, and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the application.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The foregoing has outlined a detailed description of a dynamic thread control system in accordance with the present application, wherein specific examples are presented herein to illustrate the principles and embodiments of the present application, and the above examples are intended only to facilitate an understanding of the method and core concepts of the present application; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. A dynamic thread control system, the system comprising:
the management end is used for managing the thread configuration of the client;
the dynamic configuration management end is used for pulling the latest thread configuration from the management end, comparing the latest thread configuration with the current thread configuration, and pushing the latest thread configuration to the client end under the condition that the latest thread configuration is inconsistent with the current thread configuration;
and the client is used for managing the thread resources of the thread pool according to the latest thread configuration.
2. The dynamic thread control system of claim 1, wherein the client comprises:
the configuration monitoring module is used for monitoring the dynamic configuration management end so as to receive the latest thread configuration pushed by the dynamic configuration management end in real time;
the thread creation module is used for creating threads according to the latest thread configuration;
the thread destroying module is used for destroying threads according to the latest thread configuration;
and the configuration modification module is used for modifying the thread configuration and the thread parameters according to the latest thread configuration.
3. The dynamic thread control system of claim 1, wherein the managing side comprises:
the creation module is used for creating new thread configuration according to the creation operation triggered by the user;
the deleting module is used for deleting the appointed thread configuration according to the deleting operation triggered by the user;
the modification module is used for modifying the appointed thread configuration according to the modification operation triggered by the user;
and the viewing module is used for displaying the appointed thread configuration according to the viewing operation triggered by the user.
4. The dynamic thread control system of claim 1, wherein the client comprises a task management module and a thread management module;
the task management module is used for generating tasks to be distributed according to the received user request;
the thread management module is used for distributing threads for the tasks to be distributed according to the condition of the thread pool.
5. The dynamic thread control system of claim 4, wherein said assigning threads to said tasks to be assigned based on the context of said thread pool comprises:
under the condition that an idle thread exists in the thread pool, applying for a thread to execute the task to be allocated from the idle thread;
if no idle thread exists in the thread pool and the number of tasks to be allocated in a buffer queue does not reach a preset saturated number, adding the tasks to be allocated into the buffer queue;
and refusing to execute the tasks to be allocated under the condition that no idle thread exists in the thread pool and the number of the tasks to be allocated in the buffer queue reaches the preset saturated number.
6. The dynamic thread control system of claim 4, wherein in the event that there are a plurality of tasks to be allocated, the thread management module allocates threads to the tasks to be allocated based on the condition of the thread pool and priorities of the plurality of tasks to be allocated.
7. The dynamic thread control system of claim 4, wherein the thread management module is further configured to reclaim a first thread in the thread pool, the first thread indicating that no threads to be assigned are acquired beyond a first duration.
8. The dynamic thread control system of claim 1, wherein the system further comprises: the task monitoring module and the operation monitoring module;
the task monitoring module is used for performing transaction monitoring according to application granularity, thread granularity and task granularity, and recording task execution information of the thread pool, wherein the task execution information comprises task execution conditions, maximum task execution time and average task execution time of each thread;
the operation monitoring module is used for monitoring the operations of creating the thread, modifying the thread and deleting the thread of the client, and sending corresponding operation notification to the working terminal.
9. The dynamic thread control system of claim 8, wherein the thread management module further comprises:
the application submodule is used for triggering a thread to increase application according to the task execution information;
the stop state judging submodule is used for terminating the thread increasing application when the thread pool is in a stop state, and maintaining the thread increasing application when the thread pool is not in the stop state;
the intermediate state judging submodule is used for judging whether to terminate the thread increasing application according to whether the thread is used for processing the residual task under the condition that the thread pool is in the stopping intermediate state, and maintaining the thread increasing application under the condition that the thread pool is not in the stopping intermediate state;
a thread number determining submodule, configured to determine the number of threads to be added according to the thread adding application;
the thread capacity determining submodule is used for judging whether the number of the added bus threads exceeds the preset maximum number of threads according to the determined number of the threads to be added; terminating the thread increasing application when the number of bus threads exceeds the maximum number of threads;
the system thread number determining submodule is used for judging whether the total thread number exceeds the system core number or not under the condition that the total thread number does not exceed the maximum thread number, and terminating the thread increasing application under the condition that the total thread number exceeds the system core number;
the thread registration sub-module is used for registering newly added threads when the total number of threads does not exceed the number of the system cores, completing thread addition when the thread registration is successful, and terminating the thread addition application;
and the thread state inquiring sub-module is used for inquiring the thread state under the condition that the thread registration fails, re-executing the thread quantity determining sub-module under the condition that the thread state is unchanged, and re-executing the stop state judging sub-module under the condition that the thread state is changed.
10. The dynamic thread control system of claim 1, wherein the system further comprises:
an operation log, configured to record a thread parameter modification record of the management end, where the operation record at least includes a modification time, a modification object, and a parameter value before modification;
and the permission checking module is used for checking the operation permission of the user at the management end.
CN202311465573.7A 2023-11-07 2023-11-07 Dynamic thread control system Pending CN117215800A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311465573.7A CN117215800A (en) 2023-11-07 2023-11-07 Dynamic thread control system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311465573.7A CN117215800A (en) 2023-11-07 2023-11-07 Dynamic thread control system

Publications (1)

Publication Number Publication Date
CN117215800A true CN117215800A (en) 2023-12-12

Family

ID=89051370

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311465573.7A Pending CN117215800A (en) 2023-11-07 2023-11-07 Dynamic thread control system

Country Status (1)

Country Link
CN (1) CN117215800A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1987792A (en) * 2006-12-20 2007-06-27 金魁 Application system for high grade multiple line distance management
US9354931B1 (en) * 2015-05-14 2016-05-31 Tmaxsoft, Co., Ltd. Method, server and computer-readable recording medium for managing size of thread pool dynamically
CN108763046A (en) * 2018-06-01 2018-11-06 中国平安人寿保险股份有限公司 Thread operation and monitoring method, device, computer equipment and storage medium
CN112068937A (en) * 2020-07-29 2020-12-11 苏州浪潮智能科技有限公司 Software self-adaptive multithreading control method based on load efficiency and priority
CN114217993A (en) * 2021-12-17 2022-03-22 深圳前海微众银行股份有限公司 Method, system, terminal device and storage medium for controlling thread pool congestion
CN115391020A (en) * 2022-10-27 2022-11-25 广州市玄武无线科技股份有限公司 Priority queue scheduling method, system, equipment and storage medium based on thread pool
CN116185618A (en) * 2023-01-30 2023-05-30 北京达佳互联信息技术有限公司 Task execution method, device, equipment and storage medium
CN116560834A (en) * 2023-04-19 2023-08-08 上海中通吉网络技术有限公司 Method and device for built-in monitoring alarm of dynamic thread pool
CN116627615A (en) * 2023-06-07 2023-08-22 平安银行股份有限公司 Task processing method and device, electronic equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1987792A (en) * 2006-12-20 2007-06-27 金魁 Application system for high grade multiple line distance management
US9354931B1 (en) * 2015-05-14 2016-05-31 Tmaxsoft, Co., Ltd. Method, server and computer-readable recording medium for managing size of thread pool dynamically
CN108763046A (en) * 2018-06-01 2018-11-06 中国平安人寿保险股份有限公司 Thread operation and monitoring method, device, computer equipment and storage medium
CN112068937A (en) * 2020-07-29 2020-12-11 苏州浪潮智能科技有限公司 Software self-adaptive multithreading control method based on load efficiency and priority
CN114217993A (en) * 2021-12-17 2022-03-22 深圳前海微众银行股份有限公司 Method, system, terminal device and storage medium for controlling thread pool congestion
CN115391020A (en) * 2022-10-27 2022-11-25 广州市玄武无线科技股份有限公司 Priority queue scheduling method, system, equipment and storage medium based on thread pool
CN116185618A (en) * 2023-01-30 2023-05-30 北京达佳互联信息技术有限公司 Task execution method, device, equipment and storage medium
CN116560834A (en) * 2023-04-19 2023-08-08 上海中通吉网络技术有限公司 Method and device for built-in monitoring alarm of dynamic thread pool
CN116627615A (en) * 2023-06-07 2023-08-22 平安银行股份有限公司 Task processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CA3000422C (en) Workflow service using state transfer
CN109034396B (en) Method and apparatus for processing deep learning jobs in a distributed cluster
CN110941481A (en) Resource scheduling method, device and system
CN105320561B (en) Task management method and system
CN109412874B (en) Equipment resource configuration method, device, server and storage medium
CN107018091B (en) Resource request scheduling method and device
CN112000455B (en) Multithreading task processing method and device and electronic equipment
US10686728B2 (en) Systems and methods for allocating computing resources in distributed computing
CN111427675B (en) Data processing method and device and computer readable storage medium
CN101533417A (en) A method and system for realizing ETL scheduling
CN111338791A (en) Method, device and equipment for scheduling cluster queue resources and storage medium
KR20170116439A (en) Apparatus for scheduling task
JP2020531967A (en) Distributed system Resource allocation methods, equipment, and systems
CN112445615A (en) Thread scheduling system, computer equipment and storage medium
CN110958311A (en) YARN-based shared cluster elastic expansion system and method
CN112148480A (en) Task processing method, device and equipment based on multithreading and storage medium
CN114579323A (en) Thread processing method, device, equipment and medium
CN113391911B (en) Dynamic scheduling method, device and equipment for big data resources
CN109388501B (en) Communication matching method, device, equipment and medium based on face recognition request
CN114461385A (en) Thread pool scheduling method, device and equipment and readable storage medium
CN111225007B (en) Database connection method, device and system
CN117215800A (en) Dynamic thread control system
CN110888726A (en) Multitask concurrent processing method and system
CN113687931A (en) Task processing method, system and device
CN113515355A (en) Resource scheduling method, device, server and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination