Data transmission method and device, electronic equipment, storage medium and program product

By adopting the combination method of RDMA and work queue pairs in data transmission, the problems of heavy CPU burden and low transmission efficiency in the prior art are solved, and efficient and parallel data transmission is achieved.

CN119396763AActive Publication Date: 2025-02-07INST OF MODERN PHYSICS CHINESE ACADEMY OF SCI

Patent Information

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

AI Technical Summary

Technical Problem

The existing data transmission methods require CPU participation, resulting in large resource overhead, heavy CPU burden and low transmission efficiency, which cannot meet the data transmission requirements of the accelerator laboratory.

Method used

Using the RDMA-based data transmission method, by initializing the resources required by RDMA, registering memory and work queue pairs are created, the data buffer is divided into memory blocks of predetermined size, and the appropriate work queue pair is selected according to the data transmission logic for data transmission.

Benefits of technology

Avoid bandwidth bottlenecks for a single queue pair, improve overall throughput, reduce transmission delay, and improve transmission performance and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396763A_ABST
    Figure CN119396763A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data transmission, and provides a data transmission method and device, electronic equipment, a storage medium and a program product.The method comprises the steps that resources needed by RDMA are initialized, and the initialization process comprises the steps of creating a registration memory of the RDMA and creating a plurality of work queue pairs according to different data transmission logics of a target data packet to be transmitted, each work queue pair corresponds to one data transmission logic; dividing a data buffer area in the registered memory into memory blocks with preset sizes; writing the to-be-transmitted target data packet into a data buffer area by taking a memory block as a unit; and selecting the corresponding target working queue based on the data transmission logic of the to-be-transmitted target data packet, and sending the to-be-transmitted target data packet in the data buffer area to an opposite end, or receiving data of the opposite end to the data buffer area. According to different data transmission logics, different working queues are selected to complete operation on the logic channels serving as data transmission, multiple pieces of data are transmitted in parallel, and transmission delay is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data transmission, and in particular to a data transmission method, device, electronic equipment, storage medium and program product. Background Art

[0002] With the rapid development of electronics and data storage technology, as well as the continuous expansion of the scale and types of detectors in physical experiments, the number of sampling channels has increased dramatically, and the amount of data that needs to be processed in experiments and the demand for processing speed have greatly increased. When transmitting data from the front-end electronics of distributed detectors to the back-end server cluster, traditional Ethernet protocols are often used, using the remote CPU and operating system to control memory reading and writing, and data transmission is achieved through the PCIe or PXIe bus. The traditional transmission method requires the CPU to copy, encapsulate and parse a large amount of data, resulting in a large resource overhead and CPU burden, and low transmission efficiency. However, with the continuous improvement of transmission performance requirements, traditional transmission methods cannot meet the data transmission requirements of accelerator laboratories. Summary of the invention

[0003] The present invention provides a data transmission method, device, electronic device, storage medium and program product, which are used to solve the problems that the existing data transmission process requires CPU participation, has large resource overhead and heavy CPU burden, and has low transmission efficiency.

[0004] The present invention provides a data transmission method, comprising: Initialize the resources required for RDMA, wherein the initialization process includes: creating a 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 of the work queue pairs corresponding to one data transmission logic; Dividing the data buffer in the registered memory into memory blocks of predetermined sizes; In the case of sending data, the target data packet to be transmitted is written into the data buffer in units of the memory block, a sending queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, a sending request corresponding to the target data packet to be transmitted is generated, the sending request is sent to the sending queue, and the sending request is executed in queue order to send the corresponding target data packet to be transmitted in the data buffer; In the case of 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 queue order to send the target data packet to be transmitted to the corresponding application.

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

[0006] According to a data transmission method provided by the present invention, the data transmission logic includes: data of different data types are transmitted according to their corresponding data type priorities.

[0007] According to a data transmission method provided by the present invention, the higher the frequency at which the target data packets to be transmitted are generated, the larger the memory block is.

[0008] 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 comprises: Acquire original data, and create a corresponding data structure according to the data type of the original data; Adding metadata corresponding to the original data to the data structure; The data structure after adding the metadata is serialized and packaged to obtain the packaged target data packet to be transmitted.

[0009] 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 transmission target data to 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 events and output events; Process each event returned by epoll in a loop. If the current event is an output event and the monitored sending data size is smaller than the size of the target data packet to be transmitted, perform a write operation. If the sending is successful, update the number of bytes sent. If the sending fails, print an error message and exit the loop. If the current event is an input event and the monitored received data size is smaller than the size of the target data packet to be transmitted, a read operation is performed. After successful reception, the number of received bytes is updated. If reception fails, an error message is printed and the loop is exited.

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

[0011] The RDMA initialization unit is used to initialize the resources required by RDMA, wherein the initialization process includes: creating a registered memory of RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each of the work queue pairs corresponding to one data transmission logic.

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

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

[0014] The RDMA receiving unit is used to, when receiving data, receive the target data packet to be transmitted to the data buffer, 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 queue order to send the target data packet to be transmitted to the corresponding application.

[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the data transmission method as described above is implemented.

[0016] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the data transmission method as described above is implemented.

[0017] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned data transmission methods.

[0018] The data transmission method, device, electronic device, storage medium and program product provided by the present invention are implemented based on RDMA. During the RDMA operation, different work queue pairs are selected as logical channels for data transmission according to different data transmission logics and work queue pair indexes to complete the operation. In this way, the bandwidth bottleneck of a single queue pair can be avoided, and the overall throughput can be improved. At the same time, multiple data can be transmitted in parallel to reduce transmission delay. In addition, the data buffer in the registered memory is divided into memory blocks of a predetermined size, and the target data packet to be transmitted is sent or received in the size of the memory block, thereby improving transmission performance and efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 It is a flow chart of the data transmission method provided by the present invention.

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

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

[0023] Figure 4 It is a specific application flow chart of the data transmission method provided by the present invention.

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

[0025] Figure 6 It is a structural schematic diagram of the data transmission device provided by the present invention.

[0026] Figure 7 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0028] In order to solve the above technical problems existing in the existing related technologies, this embodiment provides a data transmission method, which is implemented based on remote direct memory access (RDMA). The specific process is as follows: Figure 1 As shown, the process includes the following steps S110 to S140.

[0029] Step S110: Initialize the resources required by RDMA, wherein the initialization process includes: creating a registered memory for RDMA, and creating multiple work queue pairs according to different data transmission logics of the target data packets to be transmitted, each of which corresponds to a data transmission logic. Figure 2 As shown, the RDMA architecture includes: a resource management module, a communication link establishment module, an RDMA operation module, a queue pair management module and a resource cleanup module. The resource management module is used to initialize and create all necessary resources, including: TCP connection, device resources, registered memory, memory protection domain, work completion queue, work queue pair (send queue and receive queue), data buffer (data buffer in registered memory) and other resources, so as to be called and returned in other modules. In this embodiment, in order to improve bandwidth utilization and parallelism of data transmission, multiple work queue pairs are created according to different data transmission logics, and data of different data transmission logics are allocated to their corresponding work queue pairs for transmission. Data of different data transmission logics can be transmitted in parallel based on their respective work queue pairs, which improves bandwidth utilization and data transmission efficiency, and can meet the high frequency of target data packets to be transmitted generated by particle accelerators in high-energy physics experiments.

[0030] Of course, before initializing the resources required for RDMA, it is necessary to build an RDMA-based transmission system, deploy a network adapter, and complete the device connection. Install the network adapter on the two transmission terminals (for example, the client and the server) that need to run this transmission method, select the transmission terminal with an appropriate optical fiber interface to connect the data transmission, start the transmission terminal, and install the package manager, environment dependency package, and driver required to run the network adapter on the transmission terminal, and restart the transmission terminal to make the network adapter effective. After the hardware is deployed, it is necessary to build a transmission-related network environment, edit its network configuration file according to actual needs to configure the network interface, so that the transmission terminals can be connected to the network normally, and finally load the driver of the RDMA network card, configure the RDMA parameters through the network configuration file, and verify the function.

[0031] like Figure 3 As shown, the network adapter is physically connected to the transmission terminal through the PCIe interface, and can directly read and write the memory of the transmission terminal through its DMA controller. The network adapters between the transmission terminals are directly connected through optical fibers to form a physical data channel during the transmission process. Resources such as work queue pairs and completion queues created by the application in the transmission terminal memory can be abstracted as a data interface with the network adapter to form a logical data channel during the transmission process.

[0032] 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 a high frequency, in order to further improve transmission performance and efficiency in high-frequency transmission scenarios, in this embodiment, a memory pool technology is introduced to manage the memory buffer used in RDMA transmission (i.e., the data buffer in the registered memory). Specifically, the data buffer is divided into memory blocks of a predetermined size, and the target data packets to be transmitted are stored in 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.

[0033] Since particle accelerators in high-energy physics experiments generate target data packets to be transmitted at a high frequency, memory needs to be allocated and released frequently. Conventional dynamic memory allocation (such as using malloc and free) may cause memory fragmentation, resulting in reduced memory utilization. In memory pool technology, a large amount of memory (i.e., memory buffer) is pre-allocated and divided into small blocks, reducing the fragmentation introduced during dynamic allocation. Moreover, after adopting the memory pool, the size of the memory block is fixed, and allocation and release only require simple pointer operations. The memory pool only needs to adjust the pointer, which significantly reduces the delay of allocation and release (in contrast, conventional allocation requires maintenance of more complex parameters, such as free lists, block sizes, etc., which affect memory allocation and release 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 blocks of fixed size, data blocks can be highly localized in the cache, which improves the cache hit rate and reduces memory access latency to improve transmission performance and efficiency.

[0034] Step S130: In the case of sending data, the target data packet to be transmitted is written into the data buffer in units of the memory block, the sending queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, a sending request corresponding to the target data packet to be transmitted is generated, the sending request is sent to the sending queue, and the sending request is executed in queue order to send the corresponding target data packet to be transmitted in the data buffer, that is, as a sending end of data, when executing the sending request, the target data packet to be transmitted in the data buffer is sent to the receiving end.

[0035] Step S140: In the case of receiving data, the target data packet to be transmitted is received into the data buffer, a receiving request corresponding to the target data packet to be transmitted is generated, a receiving 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 receiving request is executed in queue order to send the target data packet to be transmitted to the corresponding application. The application is an application for processing the target data packet to be transmitted in the transmission terminal as the receiving end.

[0036] It should be noted that: based on the RDMA mechanism, after data is successfully sent and received, the sender transfers the send request in the send queue to the corresponding work completion queue, and the receiver transfers the receive request in the receive queue to the corresponding work completion queue.

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

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

[0039] The communication link building module calls the queue pair management module to modify the queue pair state to prepare for data transmission. The work queue pair is divided into 5 states, and its finite state machine is as follows: Figure 5 As shown. After the creation is completed, the work queue pair will automatically enter 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, set a series of attribute fields of the work queue pair, and receive the operation request sent by the application to the network adapter as an interface. Then the application adjusts the work queue pair to the "ready to receive" state and sends the work request in the work queue pair to the network adapter. The next step is to adjust the "ready to send" state. The work queue pair in this state can complete all RDMA operations, indicating that the data path between the transmission terminals has been opened. The last is the "error" state. The work queue pair will enter this state immediately after an error occurs in other states, and the application needs to adjust and recover.

[0040] When the work queue pair is in the "ready to send" or "ready to receive" state, the RDMA operation module is used to send and receive data. The RDMA operation module is a direct interface for performing RDMA operations. The RDMA operation module creates respective 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 status management capabilities.

[0041] The send queue thread is used to send a "send request" or "RDMA read or write request (i.e., read or write request)" to the network adapter. After submitting the send request or "RDMA read or write request" to the network adapter based on the acquired data buffer address in the peer's registered memory, the memory access remote key, and the communication identification code, the network adapter parses the send request, reads the target data packet to be transmitted corresponding to the send request from the data buffer of the local end, and sends it to the peer end (i.e., sends it to the data buffer in the peer's registered memory), and displays a corresponding message to indicate whether the operation is successful; or the network adapter parses the RDMA read or write request, and reads and writes data in the data buffer in the peer's registered memory.

[0042] The send request defines the necessary information for the send operation, which includes the starting address of the target data packet to be transmitted in the local registered memory buffer, the data length, the memory local access key, the data buffer address in the peer registered memory, and the send operation code (such as Figure 4 The RDMA read / write request defines the necessary information for the read / write operation, which includes 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 operation code (such as Figure 4 to perform RDMA read and write operations.

[0043] The receiving queue thread is used to submit a receiving request to the network adapter. After the network adapter parses the receiving request, it 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 registered memory of the local end, and displays a corresponding message to indicate whether the operation is successful.

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

[0045] 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.

[0046] The data transmission method of this embodiment is implemented based on RDMA. During the RDMA operation, different work queue pairs are selected as logical channels for data transmission according to different data transmission logics and work queue pair indexes to complete the operation. This can avoid the bandwidth bottleneck of a single queue pair and improve the overall throughput. At the same time, multiple data can be transmitted in parallel to reduce transmission delay. In addition, the data buffer in the registered memory is divided into memory blocks of a predetermined size, and the target data packet to be transmitted is sent or received in the size of the memory block, thereby improving transmission performance and efficiency.

[0047] In some embodiments, the data transmission logic includes: transmission by data type, and different data types correspond to respective work queue pairs. Particle accelerators in high-energy physics experiments may generate multiple types of data. During RDMA operations, different work queue pairs need to be selected as logical channels for data transmission according to the data type and work queue pair index to complete the operation. This can avoid the bandwidth bottleneck of a single queue pair, improve the overall throughput, and enable multiple data to be transmitted in parallel, reducing transmission delay.

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

[0049] The experimental data include: the original physical data of the accelerator; the control data include: the control and monitoring data of the accelerator and related equipment, such as temperature, high pressure, air pressure, radiation level, etc.; the configuration data include: accelerator related parameters, such as: beam intensity, beam profile position, etc.

[0050] Data of different data types have their type index values. The corresponding work queue pair number of the data type is queried according to the preset mapping table, so as to determine the work queue pair corresponding to the data type.

[0051] In this embodiment, each work queue can realize parallelization for work requests for independently processing data of corresponding data types, ensuring that multiple data are efficiently processed at the same time. For example, the transmission of experimental data from sensors to processing nodes is carried out simultaneously, and the collection and transmission of control data will not be blocked due to the processing of experimental data. Moreover, for each data type, an independent work queue pair means that when one data is being processed, other types of data can continue to work, ensuring that important real-time feedback can be completed quickly. For example, if an abnormality occurs in the control data, it can be immediately fed back to the control system without waiting for the processing of the experimental data to be completed. Therefore, by designing an independent work queue pair for each data type, different data can be processed independently, avoiding overall delays caused by slow processing of a certain type of data.

[0052] In some embodiments, the data transmission logic includes: data of different data types are transmitted according to their corresponding data type priorities. In practical applications, the priority of experimental data is high priority, the priority of control data is medium priority, and the priority of configuration data is low priority.

[0053] Specifically, QoS (Quality of Service) and priority scheduling mechanisms are introduced to ensure that key data can be processed first. First, the original data is prioritized by data type through the priority allocator, and when the respective work queue pairs are initialized for data of different priorities, the QoS parameters corresponding to different priorities are configured, namely, traffic class TC (Traffic Class) and service level SL (Service Level). TC and SL control data transmission at the network layer and link layer respectively, and select the corresponding work queue pair for transmission according to the priority of the data. At the same time, in the data scheduling process, a priority queue based on the Max-Heap data structure is constructed for sorting to ensure that high-priority data can be processed first.

[0054] 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 on memory allocation, that is, reduce the number of allocations, reduce the overhead of allocation and release, improve cache utilization (ensure that the data better adapts to the cache structure and achieves a higher cache hit rate), and can also reduce memory fragmentation and optimize data processing efficiency (in scenarios where high-frequency data is generated, data can be sent in batches, and using a large memory can reduce memory calls when data is written), which is particularly important in scenarios where high-frequency data is generated, such as high-energy physics experiments, and helps to improve the overall performance and responsiveness of the system.

[0055] In some embodiments, before writing the target data packet to be transmitted into the data buffer in units of the memory block, the method further includes: The original data is obtained, and a corresponding data structure is created according to the data type of the original data, where different data types have different data structures.

[0056] Metadata corresponding to the original data is added to the data structure, wherein the metadata may include information such as the data type and / or priority of the original data.

[0057] The data structure with metadata added 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 greatly reduce the volume of data transmission, thereby improving transmission efficiency. In addition, serialization converts complex data structures (such as nested objects, arrays, tuples, etc.) into a unified format, so that different systems can parse and understand data seamlessly.

[0058] The particle accelerator in the physics laboratory may generate various types of data, which are large in quantity and generated frequently. In order to effectively transmit these data, it is necessary to serialize the data before transmission and add metadata support. Specifically, the lightweight serialization library Protocol Buffers is selected to serialize and deserialize the data. A .proto file is defined to describe the data structure of the original data to be transmitted, and metadata fields are added to the data structure. The metadata fields include the timestamp, device ID, measurement accuracy, etc. of the data acquisition, to ensure that the receiving end can correctly interpret the data, and also help the collection and management of the diversity of particle accelerator data. Compile this .proto file to generate relevant code. The method of this embodiment is based on the code to package and serialize the data at the sending end, fill the relevant fields of the data structure with the data to be sent, allocate a buffer and serialize it, calculate the length of the serialized data, and use it for the receiving end to unpack. After the receiving end obtains the target data packet to be transmitted, it is unpacked and deserialized, and the metadata is parsed, stored and displayed.

[0059] In high-energy physics experiments, serializing the transmitted data has the following main advantages: High-energy physics experiments usually involve a large amount of complex and high-dimensional data, such as the original signals from the detector (such as event data) and the intermediate results in the analysis process (such as the four-momentum data of the collision products). Serialization can package these complex multi-type data structures into a single stream or file, which is convenient for transmission over the network or archiving in storage. In addition, high-energy physics experiments usually use distributed computing and storage systems for data processing. Serialized data can be easily distributed to distributed storage systems (such as Hadoop HDFS) and reassembled or analyzed later.

[0060] In some embodiments, after sending the corresponding target data packet to be transmitted in the data buffer, or after receiving the transmission target data to the data buffer, it also 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 events and output events.

[0061] Process each event returned by epoll in a loop. If the current event is an output event and the monitored sending data size is smaller than the size of the target data packet to be transmitted, perform a write operation. If the sending is successful, update the number of bytes sent. If the sending fails, print an error message and exit the loop.

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

[0063] The data synchronization mechanism implemented using an event-driven communication model is suitable for high-concurrency RDMA applications in high-energy physics experiment scenarios, which greatly reduces the CPU idle waiting time and improves the utilization of system resources.

[0064] At the same time, the data synchronization mechanism adopts batch processing to merge multiple synchronization operations together to reduce operation overhead.

[0065] Epoll monitors both output events and input events. If at a certain moment, there are both writable events and readable events on the socket, epoll will process both events at the same time. This avoids traditional sequential blocking processing and allows sending and receiving to be executed in parallel.

[0066] In the process of monitoring events, multiple events may be returned and stored in an array of the data synchronization instance. epoll processes all returned events in batches through a loop instead of processing only one event at a time.

[0067] The data transmission device provided by the present invention is described below. The data transmission device described below and the data transmission method described above can be referenced to each other.

[0068] The data transmission device according to the embodiment of the present invention is as follows: Figure 6 As shown, it includes the following units:

[0069] The RDMA initialization unit 610 is used to initialize the resources required by RDMA, wherein the initialization process includes: creating a 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 of the work queue pairs corresponding to one data transmission logic.

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

[0071] The RDMA sending unit 630 is used to write the target data packet to be transmitted into the data buffer in units of the memory block when sending data, select the sending queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, generate a sending request corresponding to the target data packet to be transmitted, send the sending request to the sending queue, and execute the sending request in queue order to send the corresponding target data packet to be transmitted in the data buffer.

[0072] The RDMA receiving unit 640 is used to, when receiving data, receive the target data packet to be transmitted to the data buffer, 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 queue order to send the target data packet to be transmitted to the corresponding application.

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

[0074] In some embodiments, the data transmission logic includes: data of different data types are transmitted according to their corresponding data type priorities.

[0075] In some embodiments, the higher the frequency at which the target data packets to be transmitted are generated, the larger the memory block is.

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

[0077] The data structure creation module is used to obtain original data and create a corresponding data structure according to the data type of the original data.

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

[0079] 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.

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

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

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

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

[0084] In the case of sending data, the target data packet to be transmitted is written into the data buffer in units of the memory block, the sending queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, a sending request corresponding to the target data packet to be transmitted is generated, the sending request is sent to the sending queue, and the sending request is executed in queue order to send the corresponding target data packet to be transmitted in the data buffer.

[0085] In the case of 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 queue order to send the target data packet to be transmitted to the corresponding application.

[0086] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0087] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the data transmission method provided by the above methods, the method includes the following steps:

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

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

[0090] In the case of sending data, the target data packet to be transmitted is written into the data buffer in units of the memory block, the sending queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, a sending request corresponding to the target data packet to be transmitted is generated, the sending request is sent to the sending queue, and the sending request is executed in queue order to send the corresponding target data packet to be transmitted in the data buffer.

[0091] In the case of 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 queue order to send the target data packet to be transmitted to the corresponding application.

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

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

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

[0095] In the case of sending data, the target data packet to be transmitted is written into the data buffer in units of the memory block, the sending queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, a sending request corresponding to the target data packet to be transmitted is generated, the sending request is sent to the sending queue, and the sending request is executed in queue order to send the corresponding target data packet to be transmitted in the data buffer.

[0096] In the case of 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 queue order to send the target data packet to be transmitted to the corresponding application.

[0097] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0098] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0099] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions 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: Initialize the resources required for RDMA, wherein the initialization process includes: creating a 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 of the work queue pairs corresponding to one data transmission logic; Dividing the data buffer in the registered memory into memory blocks of predetermined sizes; In the case of sending data, the target data packet to be transmitted is written into the data buffer in units of the memory block, a sending queue of the corresponding target work queue pair is selected based on the data transmission logic of the target data packet to be transmitted, a sending request corresponding to the target data packet to be transmitted is generated, the sending request is sent to the sending queue, and the sending request is executed in queue order to send the corresponding target data packet to be transmitted in the data buffer; In the case of 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 queue order 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 according to data type, and different data types correspond to 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 corresponding data type priorities.

4. The data transmission method according to claim 1, characterized in that: The higher the frequency at which the target data packets to be transmitted are generated, the larger the memory block is.

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: Acquire original data, and create a corresponding data structure according to the data type of the original data; Adding metadata corresponding to the original data to the data structure; The data structure after adding the 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 transmission target data to 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 events and output events; Process each event returned by epoll in a loop. If the current event is an output event and the monitored sending data size is smaller than the size of the target data packet to be transmitted, perform a write operation. If the sending is successful, update the number of bytes sent. If the sending fails, print an error message and exit the loop. If the current event is an input event and the monitored received data size is smaller than the size of the target data packet to be transmitted, a read operation is performed. After successful reception, the number of received bytes is updated. If reception fails, an error message is printed and the loop is exited.

7. A data transmission device, characterized in that: include: An RDMA initialization unit is used to initialize the resources required by RDMA, wherein the initialization process includes: creating a registration memory of RDMA, and creating multiple work queue pairs according to different data transmission logics of target data packets to be transmitted, each of the work queue pairs corresponding to one data transmission logic; A memory block division unit, used for dividing the data buffer in the registered memory into memory blocks of a predetermined size; An RDMA sending unit is used to, in the case of sending data, write the target data packet to be transmitted into the data buffer in units of the memory block, select a sending queue of the corresponding target work queue pair based on the data transmission logic of the target data packet to be transmitted, generate a sending request corresponding to the target data packet to be transmitted, send the sending request to the sending queue, and execute the sending request in queue order to send the corresponding target data packet to be transmitted in the data buffer; The RDMA receiving unit is used to, when receiving data, receive the target data packet to be transmitted to the data buffer, 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 queue order 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, wherein: When the processor executes the computer program, the data transmission method according to any one of claims 1 to 6 is implemented.

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, the data transmission method according to any one of claims 1 to 6 is implemented.

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

Citation Information

Patent Citations

  • Java application program remote direct memory access method

    CN101303656A

  • Data transmission method and device

    CN110519242A

  • Network connection device

    CN113746749A

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

    CN114201317A

  • Data processing method for remote direct memory access and related products

    CN115964319A

Cited By

  • Data transmission control method and system

    CN120017603A

  • Data processing system, method, device, medium and program product

    CN120492369A

  • Real-time data acquisition buffer throughput management method and device and electronic equipment

    CN120873057A

  • A real-time data acquisition buffer throughput management method and device and electronic equipment

    CN120873057B

  • Multimedia data transmission method and device based on multiplexing XDMA and storage medium

    CN120881006A