Data parallel scheduling method for joint simulation based on pipeline and SPSC queue
By adopting a joint simulation data parallel scheduling method based on pipelines and SPSC queues in a distributed simulation system, combining the MWPT scheduling model and work theft algorithm, the problem of low simulation data processing efficiency in the existing technology is solved, and efficient message processing is achieved and performance improvement.
Patent Information
- Application Number
- CN202411503990.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-10-25
AI Technical Summary
The existing distributed simulation system is inefficient in processing simulation data received by multiple links, resulting in busy waiting threads and reduced message processing efficiency, especially when there are too many messages, parallel processing degenerates into serial.
Adopt the joint simulation data parallel scheduling method based on pipelines and SPSC queues, and through the MWPT scheduling model and work theft algorithm, efficient message scheduling and processing is achieved, ensuring the order and causality of messages, and collaborating on multiple pipelines and MWPT scheduling models. Improve concurrent processing capabilities under work.
It effectively reduces the lag of message processing, improves the overall performance of distributed joint simulation, reduces time cost consumption, and improves concurrent processing performance when there are too many messages.
Smart Images

Figure CN119025301B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of simulation data parallel scheduling, and in particular to a joint simulation data parallel scheduling method based on pipeline and SPSC queue. Background Art
[0002] The receiving end of the distributed simulation system receives simulation data from multiple links, and needs to provide an efficient and fast parallel scheduling method to realize multi-queue reading and parallel processing of messages.
[0003] In distributed joint simulation, messages are causal and sequential, that is, the first message sent must be processed first, and the event must be triggered at the time of occurrence. Message queues (publish-subscribe) are used to read and write messages, and topics and message queues are matched one by one. Combined with the first-in-first-out feature of message queues, the message sequence is guaranteed, and messages can be processed serially without temporal causal confusion. Message queues are usually divided into multi-producer multi-consumer queues (MPMC), multi-producer single-consumer queues (MPSC), single producer multi-consumer queues (SPMC) and single producer single consumer (SPSC). The high-performance message processing method of multi-threaded models generally uses MPMC composed of multiple SPSC queues for parallel message processing. That is to say, one topic corresponds to one SPSC, and multiple topics correspond to multiple SPSCs. The strategy of assigning SPSC queues to threads for execution. However, with the continuous development of technology, the simulation demand for complex systems is increasing, and higher requirements are placed on the performance of simulation systems. Existing methods usually use a single queue to serially process received data, which has low operating efficiency. When there are too many messages in a queue, threads will be busy waiting, and parallel processing will degenerate into serial processing, resulting in a decrease in message processing efficiency. Summary of the invention
[0004] Based on this, it is necessary to provide a joint simulation data parallel scheduling method based on pipeline and SPSC queue to address the above technical problems.
[0005] A joint simulation data parallel scheduling method based on pipeline and SPSC queue, the method comprising:
[0006] Multiple simulation units send messages to the corresponding simulation servers, and the message receiving module receives the messages according to the topics and inserts the messages into the working thread cache queue after receiving them.
[0007] The message parsing processing module parses the worker thread message and performs topic matching and handle matching based on the parsed topic name and simulation unit handle. After the matching is completed, data is distributed and the message is inserted into the corresponding task queue.
[0008] The message execution scheduling module uses the MWPT scheduling model to schedule and execute the unit message queue; the MWPT scheduling model is used to manage the stateful task queue waiting to run through the global control function and the local queue, and to achieve efficient scheduling through the collaboration of the operating system thread and the processor.
[0009] In one embodiment, the MWPT scheduling model includes: a message M, a stateful task queue W to be executed, a processor P, and an operating system thread T.
[0010] Among them, the message M is the smallest unit to be executed, and the message M includes two attributes: the subject and the simulation unit handle; the message M must be bound to the stateful task queue W to be executed before it can be executed.
[0011] The stateful task queue W to be executed is a collection of messages M with the same attributes. The stateful task queue W to be executed must consider the order and causality of the messages when executing. The stateful task queue W to be executed needs to be bound to the processor P through a topic before it can be executed.
[0012] Processor P is a local scheduler running on a thread. Processor P is the core of WMP, connecting the upper and lower parts, and realizing the dynamic combination between the stateful task queue W to be executed and the operating system thread T.
[0013] The operating system thread T is scheduled and managed by the scheduler of the operating system. The operating system thread T does not directly execute the stateful task queue W, but is first bound to the processor P. The processor P determines the stateful task queue W to be executed. The operating system thread T and the stateful task queue W to be executed are loosely coupled.
[0014] In one embodiment, the execution steps of the MWPT scheduling model include:
[0015] Bind the processor P and the operating system thread T to establish a binding relationship.
[0016] The operating system thread T takes out the stateful task queue W to be executed from the local queue of the processor P and starts execution.
[0017] When all pending stateful task queues W are completed or have no right to execute, they enter the waiting state, waiting to be activated.
[0018] In one embodiment, the message parsing processing module parses the work thread message, and performs topic matching and handle matching according to the parsed topic name and simulation unit handle, distributes data after the matching is completed, and inserts the message into the corresponding task queue, including:
[0019] Based on the second-layer data parsing module of the pipeline, topic matching and handle matching are performed through the parsed topic name and simulation unit handle. After the matching is completed, the message is distributed into the queue and waits to be executed.
[0020] The process of topic matching is as follows: processor P is a set of stateful task queues W to be executed, which has a one-to-one correspondence with the topic. Message M finds the target processor P through the mapping relationship between the topic and processor P.
[0021] The handle matching process is as follows: the stateful task queue W to be executed is a collection of messages M, which corresponds one-to-one to the simulation unit handles. Message M finds the target stateful task queue W to be executed through the mapping relationship between the simulation unit handle and the stateful task queue W to be executed, and then inserts the message M into the queue.
[0022] In one of the embodiments, the method further includes: ensuring that the binding mechanism and matching principle between the message M and the stateful task queue W to be executed do not change.
[0023] The stateful task queue W to be executed is used as the smallest atomic execution unit. During execution, it is ensured that only one operating system thread T executes the stateful task queue W to be executed, and multiple operating system threads T cannot execute the stateful task queue W to be executed at the same time.
[0024] In one of the embodiments, in order to keep all operating system threads T working during the scheduling process, the simulation unit receiving end uses a work stealing algorithm to balance the loads of different operating system threads T during runtime.
[0025] In one embodiment, the simulation unit receiving end uses a work stealing algorithm to balance the load of different operating system threads T during operation, including:
[0026] If an operating system thread T cannot find an executable stateful task queue W to be executed through the bound processor P, it steals the stateful task queue W to be executed from other processors P for execution, and returns the stolen stateful task queue W to be executed to the original processor P after execution.
[0027] For the stolen stateful task queue W to be executed, only the index is obtained and the binding relationship between the stateful task queue W to be executed and the processor P is not really changed. Based on this, when a new message M arrives, the new message M can continue to be inserted into the stateful task queue W to be executed through double matching of the subject + simulation unit handle.
[0028] The above-mentioned method for parallel scheduling of joint simulation data based on pipeline and SPSC queue can improve the concurrent processing capability of messages by introducing the pipeline operation method and the MWPT scheduling model based on SPSC queue; under the collaborative work of multiple pipelines and MWPT scheduling models, the simulation data received by multiple links are efficiently and quickly processed. By centrally processing messages of the same topic and processing messages from different senders in parallel, the message processing between threads is balanced, and the busy waiting of threads is reduced, thereby improving the concurrent processing performance when there are too many messages on a certain topic. Compared with traditional message processing processes and scheduling methods, this method can effectively reduce the lag of message processing, improve the overall performance of distributed joint simulation, and reduce the time cost consumption during the simulation process. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A schematic diagram of a flow chart of a joint simulation data parallel scheduling method based on pipeline and SPSC queue in one embodiment;
[0030] Figure 2 It is a flow chart of pipeline processing messages in another embodiment;
[0031] Figure 3 is an execution flow chart of the MWPT scheduling model in another embodiment;
[0032] Figure 4 is a flow chart of a MWPT data distribution module in another embodiment;
[0033] Figure 5 is a flowchart of MWPT parallel processing in another embodiment;
[0034] Figure 6 FIG. 4 is a flow chart of a MWPT balanced scheduling strategy in another embodiment. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0036] In one embodiment, Figure 1 As shown, a joint simulation data parallel scheduling method based on pipeline and SPSC queue is provided, and the method comprises the following steps:
[0037] Step 100: Multiple simulation units send messages to corresponding simulation servers, and a message receiving module receives the messages according to the topics, and inserts the messages into the work thread cache queue after receiving the messages.
[0038] Specifically, the pipeline module, as a technology to improve processor performance, can bring better resource utilization and faster processing speed. The joint simulation data parallel scheduling method based on pipeline and SPSC queue proposed in this application includes message reception, parsing, processing and execution. The detailed process of Pipeline includes:
[0039] The first-level message receiving module receives messages according to the topic and inserts the messages into the worker thread cache queue after receiving them.
[0040] The second-layer message parsing processing module parses the worker thread message and distributes the data according to the simulation unit handle added by the message at the sending end (which is unique and obtained from the simulation server during the simulation initialization phase), and inserts the message into the corresponding task queue (Worker).
[0041] The third layer is the message execution scheduling module, which executes the unit message queue efficiently.
[0042] The pipeline message processing process is as follows Figure 2 shown.
[0043] Step 102: The message parsing processing module parses the work thread message, and performs topic matching and handle matching based on the parsed topic name and simulation unit handle. After the matching is completed, data distribution is performed and the message is inserted into the corresponding task queue.
[0044] Step 104: the message execution scheduling module uses the MWPT scheduling model to schedule the execution of the unit message queue; the MWPT scheduling model is used to manage the stateful task queue waiting to be executed through the global control function and the local queue, and realize efficient scheduling through the cooperation of the operating system thread and the processor.
[0045] In the above-mentioned joint simulation data parallel scheduling method based on pipeline and SPSC queue, the method can improve the concurrent processing capability of messages by introducing the pipeline operation method and the MWPT scheduling model based on SPSC queue; under the collaborative work of multiple pipelines and MWPT scheduling models, the simulation data received by multiple links are efficiently and quickly processed. By centrally processing messages of the same topic and processing messages from different senders in parallel, the message processing between threads is balanced, and the busy waiting of threads is reduced, thereby improving the concurrent processing performance when there are too many messages on a certain topic. Compared with traditional message processing processes and scheduling methods, this method can effectively reduce the lag of message processing, improve the overall performance of distributed joint simulation, and reduce the time cost consumption during the simulation process.
[0046] In one embodiment, the MWPT scheduling model in step 104 includes: a message M, a stateful task queue W to be executed, a processor P, and an operating system thread T.
[0047] Among them, message M is the smallest unit to be executed, and message M includes two attributes: subject and simulation unit handle; message M must be bound to the stateful task queue W to be executed before it can be executed. From the perspective of message M, the stateful task queue W to be executed is the CPU of message M, and message M belongs to the stateful task queue W to be executed.
[0048] The stateful task queue W to be executed is a collection of messages M with the same attributes (i.e., the same subject and simulation unit handle attributes). The stateful task queue W to be executed must consider the order and causality of the messages when executing. The stateful task queue W to be executed needs to be bound to the processor P through the subject before it can be executed. From the perspective of the stateful task queue W to be executed, the processor P is the CPU of the stateful task queue W to be executed.
[0049] Processor P is a local scheduler running on a thread. Processor P is the core of WMP, connecting the upper and lower parts, and realizing the dynamic combination between the stateful task queue W to be executed and the operating system thread T.
[0050] The operating system thread T is scheduled and managed by the scheduler of the operating system. The operating system thread T does not directly execute the stateful task queue W, but is first bound to the processor P. The processor P determines the stateful task queue W to be executed. The operating system thread T and the stateful task queue W to be executed are loosely coupled.
[0051] In one embodiment, the execution steps of the MWPT scheduling model in step 104 include:
[0052] Bind the processor P and the operating system thread T to establish a binding relationship.
[0053] The operating system thread T takes out the stateful task queue W to be executed from the local queue of the processor P and starts execution.
[0054] When all pending stateful task queues W are completed or have no right to execute, they enter the waiting state, waiting to be activated.
[0055] The execution process of the MWPT scheduling model is as follows: Figure 3 shown.
[0056] In one embodiment, step 102 includes: based on the second-layer data parsing module of the pipeline, the subject name and the simulation unit handle are parsed and processed to perform subject matching and handle matching, and after the matching is completed, the message is distributed into a queue to wait for execution; wherein, the subject matching process is: the processor P is a collection of stateful task queues W to be executed, which has a one-to-one correspondence with the subject, and the message M finds the target processor P through the mapping relationship between the subject and the processor P; the handle matching process is: the stateful task queue W to be executed is a collection of messages M, which has a one-to-one correspondence with the simulation unit handle, and the message M finds the target stateful task queue W to be executed through the mapping relationship between the simulation unit handle and the stateful task queue W to be executed, and then inserts the message M into the queue. The MWPT data distribution module process is as follows: Figure 4 shown.
[0057] In one of the embodiments, the method also includes: ensuring that the binding mechanism and matching principle between the message M and the stateful task queue W to be executed do not change; using the stateful task queue W to be executed as the atomic minimum execution unit, and ensuring that only one operating system thread T executes the stateful task queue W to be executed during execution, and multiple operating system threads T cannot execute the stateful task queue W to be executed at the same time.
[0058] Specifically, the collaborative optimization strategy of the MWPT scheduling method based on Pipeline is how to ensure the sequentiality and causality of message execution during parallel scheduling, and execute messages to the maximum extent. First, ensure the binding mechanism and matching principle of M and W; secondly, W is the smallest atomic execution unit. During execution, it is ensured that only one T is executing the stateful task queue W, and multiple Ts cannot execute the stateful task queue W at the same time. The above method can maximize the parallel execution of messages on the same topic while ensuring both sequentiality and causality, thereby improving message processing performance. The MWPT parallel processing flow is as follows: Figure 5 shown.
[0059] In one of the embodiments, in order to keep all operating system threads T working during the scheduling process, the simulation unit receiving end uses a work stealing algorithm to balance the loads of different operating system threads T during runtime.
[0060] In one of the embodiments, the simulation unit receiving end uses a work stealing algorithm to balance the load of different operating system threads T during runtime, including: if an operating system thread T cannot find an executable stateful task queue W to be executed through the bound processor P, then steal the stateful task queue W to be executed from other processors P for execution, and return the stolen stateful task queue W to be executed to the original processor P after execution; for the stolen stateful task queue W to be executed, only the index is obtained and the binding relationship between the stateful task queue W to be executed and the processor P is not actually changed. Based on this, when a new message M arrives, the new message M can continue to be inserted into the stateful task queue W to be executed through double matching of subject + simulation unit handle.
[0061] Specifically, the MWPT scheduling model is used for scheduling. In order to keep all Ts working, the simulation unit receiver uses a work stealing algorithm to balance the load of different Ts during runtime. If a T cannot find an executable W through the bound P, it will try to steal W from other Ps to execute. Under the double (topic + handle) matching rule of W, W is unique at this time and can be safely executed in parallel. After execution, W is returned to the original P. For the stolen W, only the index is obtained and the binding relationship between W and P is not really changed. Based on this, when a new M arrives, M can continue to be inserted into the W through double matching. This method can maximize the guarantee that each T has tasks to execute as much as possible, avoid performance waste, and improve message throughput performance. The MWPT balanced scheduling strategy process is as follows Figure 6 shown.
[0062] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0063] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0064] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A joint simulation data parallel scheduling method based on pipeline and SPSC queue, characterized in that: The method comprises: Multiple simulation units send messages to the corresponding simulation server, and the message receiving module receives the message according to the topic and inserts the message into the work thread cache queue after receiving it; The message parsing processing module parses the worker thread message and performs topic matching and handle matching based on the parsed topic name and simulation unit handle. After the matching is completed, data is distributed and the message is inserted into the corresponding task queue. The message execution scheduling module uses the MWPT scheduling model to schedule and execute the unit message queue; the MWPT scheduling model is used to manage the stateful task queue waiting to be run through the global control function and the local queue, and realize efficient scheduling through the cooperation of the operating system thread and the processor; The MWPT scheduling model includes: a message M, a stateful task queue W to be executed, a processor P, and an operating system thread T; Among them, message M is the smallest unit to be executed, and message M includes two attributes: subject and simulation unit handle; message M must be bound to the stateful task queue W to be executed before it can be executed; The stateful task queue W to be executed is a collection of messages M with the same attributes. The order and causality of messages must be considered when executing the stateful task queue W. The stateful task queue W to be executed must be bound to the processor P through a topic before it can be executed. Processor P is a local scheduler running on the thread. Processor P is the hub of WMP. Processor P connects the upper and lower parts to realize the dynamic combination between the stateful task queue W to be executed and the operating system thread T. The operating system thread T is scheduled and managed by the scheduler of the operating system. The operating system thread T does not directly execute the stateful task queue W, but is first bound to the processor P. The processor P determines the stateful task queue W to be executed. The operating system thread T and the stateful task queue W to be executed are loosely coupled.
2. The method for parallel scheduling of joint simulation data based on pipeline and SPSC queue according to claim 1, characterized in that: The execution steps of the MWPT scheduling model include: Bind the processor P and the operating system thread T to establish a binding relationship; The operating system thread T takes out the stateful task queue W to be executed from the local queue of the processor P and starts execution; When all pending stateful task queues W are completed or have no right to execute, they enter the waiting state, waiting to be activated.
3. The method for parallel scheduling of joint simulation data based on pipeline and SPSC queue according to claim 1, characterized in that: The message parsing processing module parses the worker thread message and performs topic matching and handle matching based on the parsed topic name and simulation unit handle. After the matching is completed, data is distributed and the message is inserted into the corresponding task queue, including: Based on the second-layer data parsing module of the pipeline, the topic name and the simulation unit handle are parsed and processed to perform topic matching and handle matching. After the matching is completed, the message is distributed into the queue and waits to be executed. The process of topic matching is as follows: the processor P is a set of stateful task queues W to be executed, which has a one-to-one correspondence with the topic, and the message M finds the target processor P through the mapping relationship between the topic and the processor P; The handle matching process is as follows: the stateful task queue W to be executed is a collection of messages M, which corresponds one-to-one to the simulation unit handles. Message M finds the target stateful task queue W to be executed through the mapping relationship between the simulation unit handle and the stateful task queue W to be executed, and then inserts the message M into the queue.
4. The method for parallel scheduling of joint simulation data based on pipeline and SPSC queue according to claim 1, characterized in that: The method further comprises: Ensure that the binding mechanism and matching principle between the message M and the stateful task queue W to be executed remain unchanged; The stateful task queue W to be executed is used as the smallest atomic execution unit. During execution, it is ensured that only one operating system thread T executes the stateful task queue W to be executed, and multiple operating system threads T cannot execute the stateful task queue W to be executed at the same time.
5. The method for parallel scheduling of joint simulation data based on pipeline and SPSC queue according to claim 1, characterized in that: In order to keep all operating system threads T working during the scheduling process, the simulation unit receiver uses a work-stealing algorithm to balance the load of different operating system threads T during runtime.
6. The method for parallel scheduling of joint simulation data based on pipeline and SPSC queue according to claim 5, characterized in that: The simulation unit receiver uses a work-stealing algorithm to balance the load of different operating system threads T at runtime, including: If an operating system thread T cannot find an executable stateful task queue W through the bound processor P, it steals the stateful task queue W from other processors P to execute, and returns the stolen stateful task queue W to the original processor P after execution; For the stolen stateful task queue W to be executed, only the index is obtained and the binding relationship between the stateful task queue W to be executed and the processor P is not really changed. Based on this, when a new message M arrives, the new message M can continue to be inserted into the stateful task queue W to be executed through double matching of the subject + simulation unit handle.