Data transmission methods, devices, electronic equipment, storage media and software products

By optimizing the data transmission logic through RDMA and memory pool technologies, the problems of high CPU resource overhead and low transmission efficiency were solved, enabling efficient data transmission in the high-energy physics laboratory and improving system performance and responsiveness.

CN119396763BActive Publication Date: 2025-11-14INST OF MODERN PHYSICS CHINESE ACADEMY OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411767550.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-11-14
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

Existing data transmission methods require CPU involvement, resulting in high resource consumption and low transmission efficiency, which cannot meet the data transmission needs of high-energy physics laboratories.

Method used

By employing RDMA technology, multiple work queue pairs are created through RDMA resource initialization, and the data buffer is divided into memory blocks of a predetermined size. Different work queue pairs are selected for data transmission based on data type and priority. Combined with memory pool technology and serialization processing, the data transmission logic and synchronization mechanism are optimized.

Benefits of technology

It improves data transmission throughput and efficiency, reduces transmission latency, avoids single queue bandwidth bottlenecks, and ensures real-time processing of critical data and efficient utilization of system resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396763B_ABST
    Figure CN119396763B_ABST
Patent Text Reader

Abstract

This invention relates to the field of data transmission technology, providing a data transmission method, apparatus, electronic device, storage medium, and program product. The method includes: initializing resources required for RDMA, wherein the initialization process includes: creating registered memory for RDMA; creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each work queue pair corresponding to a data transmission logic; dividing the data buffer in the registered memory into memory blocks of predetermined size; writing the target data packets to be transmitted into the data buffer in units of memory blocks; selecting the corresponding target work queue based on the data transmission logic of the target data packets to be transmitted; sending the target data packets to be transmitted in the data buffer to the peer, or receiving data from the peer into the data buffer. This invention selects different work queue pairs as logical channels for data transmission according to different data transmission logics to complete the operation, enabling parallel transmission of multiple data packets and reducing transmission latency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data transmission technology, and in particular to a data transmission method, apparatus, electronic device, storage medium, and program product. Background Technology

[0002] With the rapid development of electronics and data storage technologies, and the continuous expansion of the scale and types of detectors in physics experiments, the number of sampling channels has increased dramatically, significantly increasing the amount of data that experiments need to process and the demand for processing speed. When transmitting data from the front-end electronics of a distributed detector to the back-end server cluster, the traditional Ethernet protocol is often used. This involves remote CPUs and operating systems controlling memory read / write operations and transmitting data via PCIe or PXIe buses. Traditional transmission methods require the CPU to perform extensive copying, encapsulation, and parsing of data, resulting in significant resource overhead and CPU burden, and also low transmission efficiency. However, with the ever-increasing demands for transmission performance, traditional transmission methods can no longer meet the data transmission requirements of accelerator laboratories. Summary of the Invention

[0003] This invention provides a data transmission method, apparatus, electronic device, storage medium, and program product to solve the problems of existing data transmission processes requiring CPU participation, resulting in high resource consumption, heavy CPU burden, and low transmission efficiency.

[0004] This invention provides a data transmission method, comprising:

[0005] The resources required for initializing RDMA are initialized, wherein the initialization process includes: creating the registration memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each work queue pair corresponding to a data transmission logic;

[0006] The data buffer in the registered memory is divided into memory blocks of a predetermined size;

[0007] When sending data, the target data packet to be transmitted is written into the data buffer in units of memory blocks. Based on the data transmission logic of the target data packet to be transmitted, the corresponding target work queue pair is selected as the sending queue. A sending request corresponding to the target data packet to be transmitted is generated and sent to the sending queue. The sending request is executed in the order of the queue to send the target data packet to be transmitted in the data buffer.

[0008] When receiving data, the target data packet to be transmitted is received into the data buffer, a receive request corresponding to the target data packet to be transmitted is generated, the receive queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, and the receive request is executed in the order of the queue to send the target data packet to be transmitted to the corresponding application.

[0009] According to a data transmission method provided by the present invention, the data transmission logic includes: transmitting data according to data type, wherein different data types correspond to their respective work queue pairs.

[0010] According to a data transmission method provided by the present invention, the data transmission logic includes: transmitting data of different data types according to their respective data type priorities.

[0011] According to a data transmission method provided by the present invention, the higher the frequency of the target data packet to be transmitted, the larger the memory block.

[0012] According to a data transmission method provided by the present invention, before writing the target data packet to be transmitted into the data buffer in units of the memory block, the method further includes:

[0013] Obtain the raw data and create a corresponding data structure according to the data type of the raw data;

[0014] Add metadata corresponding to the original data to the data structure;

[0015] The data structure with added metadata is serialized and packaged to obtain the packaged target data packet to be transmitted.

[0016] According to a data transmission method provided by the present invention, after sending the corresponding target data packet to be transmitted in the data buffer, or after receiving the target data to be transmitted to the data buffer, the method further includes:

[0017] Create a synchronization instance of the target data packet to be transmitted, add the socket file descriptor used for RDMA communication to the epoll event list, and monitor input and output events;

[0018] The loop processes each event returned by epoll. If the current event is an output event and the size of the monitored data to be sent is smaller than the size of the target data packet to be transmitted, a write operation is performed. If the transmission is successful, the number of bytes sent is updated. If the transmission fails, an error message is printed and the loop is exited.

[0019] If the current event is an input event and the size of the monitored received data is smaller than the size of the target data packet to be transmitted, then a read operation is performed. If the reception is successful, the number of bytes received is updated. If the reception fails, an error message is printed and the loop is exited.

[0020] The present invention also provides a data transmission device, comprising the following units:

[0021] The RDMA initialization unit is used to initialize the resources required for RDMA. The initialization process includes: creating the RDMA registration memory, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, with each work queue pair corresponding to a data transmission logic.

[0022] A memory block partitioning unit is used to divide the data buffer in the registered memory into memory blocks of a predetermined size.

[0023] The RDMA transmission unit is configured to, when transmitting data, write the target data packet to be transmitted into the data buffer in units of memory blocks, select the transmission queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, generate a transmission request corresponding to the target data packet to be transmitted, send the transmission request to the transmission queue, and execute the transmission request in the order of the queue to transmit the target data packet to be transmitted in the data buffer.

[0024] The RDMA receiving unit is configured to receive the target data packet to be transmitted into the data buffer when receiving data, generate a receiving request corresponding to the target data packet to be transmitted, select the receiving queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, and execute the receiving request in the order of the queues to send the target data packet to be transmitted to the corresponding application.

[0025] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the data transmission method as described above.

[0026] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data transmission method as described above.

[0027] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the data transmission method as described above.

[0028] The data transmission method, apparatus, electronic device, storage medium, and program product provided by this invention are based on RDMA. During RDMA operation, different work queue pairs are selected as logical channels for data transmission according to different data transmission logic and work queue pair indexes. This avoids the bandwidth bottleneck of a single queue pair, improves the overall throughput, and enables multiple data to be transmitted in parallel, reducing transmission latency. In addition, the data buffer in the registered memory is divided into memory blocks of a predetermined size, and the target data packets to be transmitted are sent or received in memory block sizes, improving transmission performance and efficiency. Attached Figure Description

[0029] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0030] Figure 1 This is a flowchart illustrating the data transmission method provided by the present invention.

[0031] Figure 2 This is a schematic diagram of the RDMA-based architecture in the data transmission method provided by the present invention.

[0032] Figure 3 This is a schematic diagram of the logical data channel based on RDMA in the data transmission method provided by the present invention.

[0033] Figure 4 This is a flowchart illustrating the specific application of the data transmission method provided by the present invention.

[0034] Figure 5 This is a schematic diagram of the finite state machine of the work queue pair in the data transmission method provided by the present invention.

[0035] Figure 6 This is a schematic diagram of the data transmission device provided by the present invention.

[0036] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0038] To address the aforementioned technical problems in existing related technologies, this embodiment provides a data transmission method based on Remote Direct Memory Access (RDMA). The specific process is as follows: Figure 1 As shown, the procedure includes steps S110 to S140.

[0039] Step S110: Initialize the resources required for RDMA, wherein the initialization process includes: creating the registration memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each work queue pair corresponding to a data transmission logic. Specifically, as follows Figure 2 As shown, the RDMA architecture includes: a resource management module, a communication connection establishment module, an RDMA operation module, a queue management module, and a resource cleanup module. The resource management module initializes and creates all necessary resources, including TCP connections, device resources, registered memory, memory protection domains, work completion queues, work queue pairs (send queue and receive queue), and data buffers (data buffers in registered memory), so that they can be called and returned by other modules. In this embodiment, to improve bandwidth utilization and data transmission parallelism, multiple work queue pairs are created according to different data transmission logics. Data from different data transmission logics is allocated to their respective work queue pairs for transmission. Data from different data transmission logics can be transmitted in parallel based on their respective work queue pairs, improving bandwidth utilization and data transmission efficiency, and meeting the needs of high-frequency target data packets generated by particle accelerators in high-energy physics experiments.

[0040] Of course, before initializing the resources required for RDMA, it is necessary to set up an RDMA-based transmission system, deploy network adapters, and complete device connections. Install the network adapters on the two transmission terminals (e.g., client and server) that need to run this transmission method. Select an appropriate fiber optic connection to connect the transmission terminals, start the transmission terminals, and install the necessary package manager, environment dependency packages, and drivers for running the network adapter on the transmission terminals. Restart the transmission terminals to make the network adapter effective. After the hardware deployment is complete, it is necessary to set up the transmission-related network environment. Edit the network configuration file according to actual needs to configure the network interface, enabling normal network connection between the transmission terminals. Finally, load the RDMA network card driver, configure the RDMA parameters through the network configuration file, and verify the functionality.

[0041] like Figure 3As shown, the network adapter is physically connected to the transmission terminal via a PCIe interface. Its DMA controller can directly read and write to the transmission terminal's memory. Network adapters between transmission terminals are directly connected via optical fiber to form a physical data channel during transmission. Resources such as work queues and completion queues created by the application in the transmission terminal's memory can be abstracted as data interfaces with the network adapter to form a logical data channel during transmission.

[0042] Step S120: Divide the data buffer in the registered memory into memory blocks of a predetermined size. Since particle accelerators in high-energy physics experiments generate target data packets to be transmitted at high frequencies, to further improve transmission performance and efficiency in high-frequency transmission scenarios, this embodiment introduces memory pool technology to manage the memory buffer (i.e., the data buffer in the registered memory) used in RDMA transmission. Specifically, the data buffer is divided into memory blocks of a predetermined size, and the target data packets to be transmitted are stored in units of memory blocks. For high-frequency data transmission scenarios, the memory block size is preferably 512 bytes to 2048 bytes. The network adapter can directly access these data buffers, and after the RDMA operation is completed, the memory blocks are released back to the data buffer.

[0043] Because particle accelerators in high-energy physics experiments generate target data packets at high frequencies, memory needs to be allocated and freed frequently. Conventional dynamic memory allocation (such as using malloc and free) can lead to memory fragmentation, resulting in decreased memory utilization. Memory pooling technology pre-allocates and divides large amounts of memory (i.e., memory buffers) into small blocks, reducing fragmentation introduced during dynamic allocation. Moreover, with memory pooling, memory block sizes are fixed, and allocation and freeing only require simple pointer operations. The memory pool only needs to adjust pointers, significantly reducing allocation and freeing latency (in contrast, conventional allocation requires maintaining more complex parameters, such as free lists and block sizes, affecting memory allocation and freeing speed), thereby improving transmission performance and efficiency. In addition, in current CPUs, CPU caches (such as L1, L2, and L3 caches) have a significant impact on data access performance. When data is stored in fixed-size blocks, data blocks can be highly localized in the cache, improving cache hit rate and reducing memory access latency, thus improving transmission performance and efficiency.

[0044] Step S130: When sending data, the target data packet to be transmitted is written into the data buffer in units of memory blocks. Based on the data transmission logic of the target data packet to be transmitted, the corresponding target work queue pair's transmission queue is selected. A transmission request corresponding to the target data packet to be transmitted is generated and sent to the transmission queue. The transmission request is executed in the queue order to send the target data packet to be transmitted in the data buffer. That is, as the data sending end, when executing the transmission request, the target data packet to be transmitted in the data buffer is sent to the receiving end.

[0045] Step S140: When receiving data, the target data packet to be transmitted is received into the data buffer, a receive request corresponding to the target data packet to be transmitted is generated, and the receive queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted. The receive request is executed in the queue order to send the target data packet to be transmitted to the corresponding application. Here, the application is the application in the transmission terminal acting as the receiving end that processes the target data packet to be transmitted.

[0046] It should be noted that, based on the RDMA mechanism, after successful data transmission and reception, the sending end transfers the transmission requests in the transmission queue to the corresponding work completion queue, and the receiving end transfers the reception requests in the reception queue to the corresponding work completion queue.

[0047] Specifically, such as Figure 4 As shown, the communication connection establishment module establishes a TCP communication connection between two transmission terminals (e.g., a server and a client), and the two parties exchange configuration parameter information to ensure the integrity of the data path. In server mode, a listening socket is created and connections are accepted; in client mode, the server address is resolved and a connection request is sent. After a successful connection, a socket file descriptor is obtained. Further, the two communicating parties exchange connection messages to establish a data channel. The connection message content includes the address of the data buffer in the local registered memory, the memory remote access key, the work queue pair number, and the communication identifier code, all of which are converted to network byte order. The two communicating parties exchange connection messages through the socket file descriptor.

[0048] The local end parses the received connection message to obtain the data buffer address in the registered memory of the peer end, the memory remote access key, and the communication identification code, converts them into host byte order, and stores them for later use.

[0049] The communication link establishment module calls the queue management module to modify the queue pair state in preparation for data transmission. The work queue pair is divided into 5 states, and its finite state machine is as follows: Figure 5As shown. After creation, the work queue pair automatically enters the "reset" state. At this time, only the preparation of related resources is completed, but no RDMA operations can be performed. The application will adjust the work queue pair to enter the "initialization" state, setting a series of attribute fields of the work queue pair, which will serve as an interface to receive operation requests sent by the application to the network adapter. Then, the application will adjust the work queue pair to the "ready to receive" state, sending the work requests in the work queue pair to the network adapter. Next, it will adjust to the "ready to send" state. In this state, the work queue pair can complete all RDMA operations, indicating that the data path between the transmission terminals has been established. Finally, there is the "error" state, which the work queue pair will immediately enter after an error occurs in other states, requiring the application to adjust and recover.

[0050] When the work queue is in the "ready to send" or "ready to receive" state, the RDMA operation module is used for data transmission and reception. The RDMA operation module is the direct interface for performing RDMA operations. The RDMA operation module creates its own work threads (send queue thread, receive queue thread, and completion queue thread) for the send queue, receive queue, and completion queue, respectively, so that the send queue, receive queue, and completion queue at both ends of the communication work asynchronously, thereby significantly improving the system's throughput and response speed, reducing latency, and providing better error handling and state management capabilities.

[0051] The send queue thread is used to send "send requests" or "RDMA read / write requests (i.e., read or write requests)" to the network adapter. Based on the obtained data buffer address in the peer's registered memory, memory access remote key, and communication identifier, after submitting the send request or "RDMA read / write request" to the network adapter, the network adapter parses the send request and reads the target data packet corresponding to the send request from its own data buffer and sends it to the peer (i.e., sends it to the data buffer in the peer's registered memory), and displays the corresponding message to indicate whether the operation was successful; or the network adapter parses the RDMA read / write request and reads or writes data in the data buffer in the peer's registered memory.

[0052] The send request defines the necessary information for the send operation. This necessary information includes the starting address of the target data packet to be transmitted in the local end's registered memory buffer, the data length, the memory local access key, the address of the data buffer in the peer's registered memory, and the send operation code (e.g., ...). Figure 4 The RDMA read / write request defines the necessary information for the read / write operation, including the length of the data to be read / written, the address of the data buffer in the peer's registered memory, and the read / write opcode (such as the transmission opcode in the memory). Figure 4 The read / write opcodes in the code are used to perform RDMA read / write operations.

[0053] The receive queue thread is used to submit receive requests to the network adapter. After parsing the receive request, the network adapter receives the target data packet to be transmitted sent by the other end, writes the target data packet to be transmitted into the data buffer of the local registered memory, and displays the corresponding message to indicate whether the operation was successful.

[0054] The completion queue thread polls the completion queue within a specified timeout period to check the completion status of work requests (send requests, receive requests, or RDMA read / write requests). The completion queue thread obtains the current time and repeatedly polls the completion queue within the timeout period. If no completed work request is found or the polling fails, the corresponding error message is displayed. If a completed work request is found, its status is checked to see if the work was successful and the corresponding success or error message is displayed.

[0055] The resource cleanup module is used to clean up and release all allocated resources and destroy the connection between the two ends of the communication to ensure that there is no resource leakage when the program exits.

[0056] The data transmission method in this embodiment is based on RDMA. During the RDMA operation, different work queue pairs are selected as logical channels for data transmission according to different data transmission logic and work queue pair indexes. This avoids the bandwidth bottleneck of a single queue pair, improves the overall throughput, and enables multiple data to be transmitted in parallel, reducing transmission latency. In addition, the data buffer in the registered memory is divided into memory blocks of a predetermined size. The target data packets to be transmitted are sent or received in memory block size, improving transmission performance and efficiency.

[0057] In some embodiments, the data transmission logic includes: transmitting data according to data type, where different data types correspond to their respective work queue pairs. High-energy physics particle accelerators may generate various types of data. During RDMA operations, different work queue pairs need to be selected as logical channels for data transmission based on the data type and work queue pair index. This avoids bandwidth bottlenecks from single queue pairs, improves overall throughput, and allows multiple data to be transmitted in parallel, reducing transmission latency.

[0058] Specifically, the data types mainly include: experimental data, control data, and configuration data.

[0059] Experimental data includes: raw physical data of the accelerator; control data includes: control and monitoring data of the accelerator and related equipment, such as temperature, high pressure, air pressure, radiation level, etc.; configuration data includes: accelerator-related parameters, such as: beam intensity, beam profile position, etc.

[0060] Different data types have their own type index values. The corresponding work queue pair number of the data type is queried according to the preset mapping table, thereby determining the work queue pair corresponding to the data type.

[0061] In this embodiment, each work queue independently processes work requests for data of its corresponding data type, enabling parallel processing and ensuring that multiple data sets are processed efficiently simultaneously. For example, experimental data transmission from sensors to processing nodes occurs concurrently, and the collection and transmission of control data are not blocked due to experimental data processing. Furthermore, for each data type, independent work queue pairs mean that while one data set is being processed, other data types can continue to be processed, ensuring that crucial real-time feedback is completed quickly. For example, if an anomaly occurs in the control data, it can be immediately reported to the control system without waiting for the experimental data processing to complete. Therefore, by designing independent work queue pairs for each data type, different data can be processed independently, avoiding overall delays caused by slow processing of one type of data.

[0062] In some embodiments, the data transmission logic includes transmitting data of different data types according to their respective data type priorities. In practical applications, experimental data has a high priority, control data has a medium priority, and configuration data has a low priority.

[0063] Specifically, QoS (Quality of Service) and priority scheduling mechanisms are introduced to ensure that critical data receives priority processing. First, a priority allocator prioritizes the raw data according to its data type. Then, separate work queues are initialized for each priority level, configuring QoS parameters corresponding to different priorities: Traffic Class (TC) and Service Level (SL). TC and SL control data transmission at the network and link layers, respectively, selecting the appropriate work queue for transmission based on data priority. Simultaneously, during data scheduling, a priority queue based on a max-heap data structure is constructed and sorted to ensure that high-priority data receives priority processing.

[0064] In some embodiments, the higher the frequency of the target data packets to be transmitted, the larger the memory block. When the frequency of the target data packets to be transmitted is high, using a larger memory block helps to effectively reduce the overhead of memory allocation, that is, reduce the number of allocations, reduce the overhead of allocation and release, improve cache utilization (ensure that data is better adapted to the cache structure and achieve a higher cache hit rate), and also reduce memory fragmentation and optimize the efficiency of data processing (in scenarios with high-frequency data generation, data can be sent in batches, and using large memory can reduce memory calls when writing data). This is especially important in scenarios with high-frequency data generation, such as high-energy physics experiments, and helps to improve the overall performance and responsiveness of the system.

[0065] In some embodiments, before writing the target data packet to be transmitted into the data buffer in units of the memory blocks, the method further includes:

[0066] Obtain the raw data and create a corresponding data structure according to the data type of the raw data. Different data types have different data structures.

[0067] Add metadata corresponding to the original data to the data structure, wherein the metadata may include information such as the data type and / or priority of the original data.

[0068] The data structure with added metadata is serialized and packaged to obtain the packaged target data packet to be transmitted. The serialization format uses a compact binary encoding method, which can significantly reduce the volume of data transmission and thus improve transmission efficiency. Moreover, serialization converts complex data structures (such as nested objects, arrays, tuples, etc.) into a unified format, enabling different systems to seamlessly parse and understand data.

[0069] Particle accelerators in physics laboratories may generate various types of data, which are abundant and generated frequently. To effectively transmit this data, it is necessary to serialize the data before transmission and add metadata support. Specifically, the lightweight serialization library Protocol Buffers is chosen for data serialization and deserialization. A .proto file is defined to describe the data structure of the raw data to be transmitted, and metadata fields are added to the data structure. These metadata fields include the data acquisition timestamp, device ID, measurement accuracy, etc., ensuring that the receiving end can correctly interpret the data and facilitating the acquisition and management of diverse particle accelerator data. This .proto file is compiled to generate relevant code. The method in this embodiment is based on this code to package and serialize the data at the sending end, fill the relevant fields of the data structure with the data to be transmitted, allocate a buffer and perform serialization, calculate the length of the serialized data for unpacking at the receiving end, and then unpack and deserialize the target data packet, and parse, store, and display the metadata.

[0070] In high-energy physics experiments, serializing transmitted data offers several key advantages: High-energy physics experiments typically involve large amounts of complex and high-dimensional data, such as raw detector signals (e.g., event data) and intermediate results from the analysis process (e.g., four-momentum data from collision products). Serialization can package these complex, multi-type data structures into a single stream or file, facilitating transmission over networks or archiving in storage. Furthermore, high-energy physics experiments often use distributed computing and storage systems for data processing; serialized data is easily distributed to distributed storage systems (e.g., Hadoop HDFS) and subsequently reassembled or analyzed.

[0071] In some embodiments, after sending the corresponding target data packet to be transmitted in the data buffer, or after receiving the target data to be transmitted to the data buffer, the method further includes:

[0072] Create a synchronization instance of the target data packet to be transmitted, add the socket file descriptor used for RDMA communication to the epoll event list, and monitor input and output events.

[0073] The loop processes each event returned by epoll. If the current event is an output event and the size of the monitored data to be sent is less than the size of the target data packet to be transmitted, a write operation is performed. If the transmission is successful, the number of bytes sent is updated. If the transmission fails, an error message is printed and the loop is exited.

[0074] If the current event is an input event and the size of the monitored received data is smaller than the size of the target data packet to be transmitted, then a read operation is performed. If the reception is successful, the number of bytes received is updated. If the reception fails, an error message is printed and the loop is exited.

[0075] Using an event-driven communication model to implement a data synchronization mechanism is suitable for high-concurrency RDMA applications in high-energy physics experiments, greatly reducing CPU idle waiting time and improving system resource utilization.

[0076] Meanwhile, the data synchronization mechanism uses batch processing to combine multiple synchronization operations into one, reducing operational overhead.

[0077] epoll monitors both output and input events. If, at any given moment, there are both writable and readable events on the socket, epoll will process both types of events simultaneously. This avoids traditional sequential blocking processing, allowing sending and receiving to be performed in parallel.

[0078] During the monitoring process, multiple events may be returned and stored in an array of data synchronization instances. epoll processes all returned events in batches in a loop, rather than processing one event at a time.

[0079] The data transmission device provided by the present invention will be described below. The data transmission device described below can be referred to in correspondence with the data transmission method described above.

[0080] The data transmission device of this invention embodiment, such as Figure 6 As shown, it includes the following units:

[0081] RDMA initialization unit 610 is used to initialize the resources required for RDMA. The initialization process includes: creating the registration memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, with each work queue pair corresponding to a data transmission logic.

[0082] The memory block partitioning unit 620 is used to divide the data buffer in the registered memory into memory blocks of a predetermined size.

[0083] RDMA transmission unit 630 is configured to, when transmitting data, write the target data packet to be transmitted into the data buffer in units of memory blocks, select the transmission queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, generate a transmission request corresponding to the target data packet to be transmitted, send the transmission request to the transmission queue, and execute the transmission request in the order of the queue to transmit the target data packet to be transmitted in the data buffer.

[0084] RDMA receiving unit 640 is configured to receive the target data packet to be transmitted into the data buffer when receiving data, generate a receiving request corresponding to the target data packet to be transmitted, select the receiving queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, and execute the receiving request in the order of the queue to send the target data packet to be transmitted to the corresponding application.

[0085] In some embodiments, the data transmission logic includes: transmitting by data type, where different data types correspond to their respective work queue pairs.

[0086] In some embodiments, the data transmission logic includes: transmitting data of different data types according to their respective data type priorities.

[0087] In some embodiments, the higher the frequency of the target data packets to be transmitted, the larger the memory block.

[0088] In some embodiments, the data transmission device further includes the following modules:

[0089] The data structure creation module is used to obtain raw data and create corresponding data structures according to the data type of the raw data.

[0090] The metadata adding module is used to add metadata corresponding to the original data in the data structure.

[0091] The serialization module is used to serialize and package the data structure after adding metadata to obtain the packaged target data packet to be transmitted.

[0092] In some embodiments, the data transmission device further includes: a data synchronization module, configured to, after sending the corresponding target data packet to be transmitted in the data buffer, or after receiving the target data to be transmitted into the data buffer, create a synchronization instance of the target data packet to be transmitted, add the socket file descriptor used for RDMA communication to the epoll event list, and monitor input and output events; process each event returned by epoll in a loop, if the current event is an output event and the monitored size of the transmitted data is less than the size of the target data packet to be transmitted, perform a write operation, update the number of bytes sent after successful transmission, and print an error message and exit the loop if transmission fails; if the current event is an input event and the monitored size of the received data is less than the size of the target data packet to be transmitted, perform a read operation, update the number of bytes received after successful reception, and print an error message and exit the loop if reception fails.

[0093] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7 As shown, the electronic device may include: a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communications interface 720, and the memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute a data transmission method, which includes the following steps:

[0094] The resources required for initializing RDMA are initialized, wherein the initialization process includes: creating the registration memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each work queue pair corresponding to a data transmission logic.

[0095] The data buffer in the registered memory is divided into memory blocks of a predetermined size.

[0096] When sending data, the target data packet to be transmitted is written into the data buffer in units of memory blocks. Based on the data transmission logic of the target data packet to be transmitted, the corresponding target work queue pair is selected as the sending queue. A sending request corresponding to the target data packet to be transmitted is generated and sent to the sending queue. The sending request is executed in the order of the queue to send the target data packet to be transmitted in the data buffer.

[0097] When receiving data, the target data packet to be transmitted is received into the data buffer, a receive request corresponding to the target data packet to be transmitted is generated, the receive queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, and the receive request is executed in the order of the queue to send the target data packet to be transmitted to the corresponding application.

[0098] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0099] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer is able to execute the data transmission method provided by the above methods, the method comprising the following steps:

[0100] The resources required for initializing RDMA are initialized, wherein the initialization process includes: creating the registration memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each work queue pair corresponding to a data transmission logic.

[0101] The data buffer in the registered memory is divided into memory blocks of a predetermined size.

[0102] When sending data, the target data packet to be transmitted is written into the data buffer in units of memory blocks. Based on the data transmission logic of the target data packet to be transmitted, the corresponding target work queue pair is selected as the sending queue. A sending request corresponding to the target data packet to be transmitted is generated and sent to the sending queue. The sending request is executed in the order of the queue to send the target data packet to be transmitted in the data buffer.

[0103] When receiving data, the target data packet to be transmitted is received into the data buffer, a receive request corresponding to the target data packet to be transmitted is generated, the receive queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, and the receive request is executed in the order of the queue to send the target data packet to be transmitted to the corresponding application.

[0104] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the data transmission methods provided by the methods described above, the method comprising the following steps:

[0105] The resources required for initializing RDMA are initialized, wherein the initialization process includes: creating the registration memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each work queue pair corresponding to a data transmission logic.

[0106] The data buffer in the registered memory is divided into memory blocks of a predetermined size.

[0107] When sending data, the target data packet to be transmitted is written into the data buffer in units of memory blocks. Based on the data transmission logic of the target data packet to be transmitted, the corresponding target work queue pair is selected as the sending queue. A sending request corresponding to the target data packet to be transmitted is generated and sent to the sending queue. The sending request is executed in the order of the queue to send the target data packet to be transmitted in the data buffer.

[0108] When receiving data, the target data packet to be transmitted is received into the data buffer, a receive request corresponding to the target data packet to be transmitted is generated, the receive queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, and the receive request is executed in the order of the queue to send the target data packet to be transmitted to the corresponding application.

[0109] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0110] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data transmission method, characterized in that, include: The resources required for initializing RDMA are initialized, wherein the initialization process includes: creating the registration memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each work queue pair corresponding to a data transmission logic; The data buffer in the registered memory is divided into memory blocks of a predetermined size; When sending data, the target data packet to be transmitted is written into the data buffer in units of memory blocks. Based on the data transmission logic of the target data packet to be transmitted, the corresponding target work queue pair is selected as the sending queue. A sending request corresponding to the target data packet to be transmitted is generated and sent to the sending queue. The sending request is executed in the order of the queue to send the target data packet to be transmitted in the data buffer. When receiving data, the target data packet to be transmitted is received into the data buffer, a receive request corresponding to the target data packet to be transmitted is generated, the receive queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, and the receive request is executed in the order of the queue to send the target data packet to be transmitted to the corresponding application.

2. The data transmission method according to claim 1, characterized in that, The data transmission logic includes: transmission by data type, with different data types corresponding to their respective work queue pairs.

3. The data transmission method according to claim 2, characterized in that, The data transmission logic includes: data of different data types are transmitted according to their respective data type priorities.

4. The data transmission method according to claim 1, characterized in that, The higher the frequency of the target data packets to be transmitted, the larger the memory block.

5. The data transmission method according to any one of claims 1 to 4, characterized in that, Before writing the target data packet to be transmitted into the data buffer in units of the memory block, the method further includes: Obtain the raw data and create a corresponding data structure according to the data type of the raw data; Add metadata corresponding to the original data to the data structure; The data structure with added metadata is serialized and packaged to obtain the packaged target data packet to be transmitted.

6. The data transmission method according to any one of claims 1 to 4, characterized in that, After sending the corresponding target data packet to be transmitted in the data buffer, or after receiving the target data to be transmitted into the data buffer, the method further includes: Create a synchronization instance of the target data packet to be transmitted, add the socket file descriptor used for RDMA communication to the epoll event list, and monitor input and output events; The loop processes each event returned by epoll. If the current event is an output event and the size of the monitored data to be sent is smaller than the size of the target data packet to be transmitted, a write operation is performed. If the transmission is successful, the number of bytes sent is updated. If the transmission fails, an error message is printed and the loop is exited. If the current event is an input event and the size of the monitored received data is smaller than the size of the target data packet to be transmitted, then a read operation is performed. If the reception is successful, the number of bytes received is updated. If the reception fails, an error message is printed and the loop is exited.

7. A data transmission device, characterized in that, include: The RDMA initialization unit is used to initialize the resources required by RDMA. The initialization process includes: creating the registration memory of RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, with each work queue pair corresponding to a data transmission logic. A memory block partitioning unit is used to divide the data buffer in the registered memory into memory blocks of a predetermined size; The RDMA transmission unit is configured to, when transmitting data, write the target data packet to be transmitted into the data buffer in units of the memory block, select the transmission queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, generate a transmission request corresponding to the target data packet to be transmitted, send the transmission request to the transmission queue, and execute the transmission request in the order of the queue to transmit the target data packet to be transmitted in the data buffer. The RDMA receiving unit is configured to receive the target data packet to be transmitted into the data buffer when receiving data, generate a receiving request corresponding to the target data packet to be transmitted, select the receiving queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, and execute the receiving request in the order of the queues to send the target data packet to be transmitted to the corresponding application.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the data transmission method as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the data transmission method as described in any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the data transmission method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data transmission method and device, computer readable storage medium and electronic equipment

    CN118301101A

  • Shared receive queues

    US20040193811A1