RPC data processing method, electronic device, storage medium and program product
By using a network card in the RPC system to store the packet header and body of the data packet into different ring buffers, and the central processor reconstructs the requested data, the problem of discontinuity of storage locations caused by out-of-order data packets is solved, and the processing efficiency and performance of the RPC system are improved.
Patent Information
- Application Number
- CN202510493486.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-05-27
AI Technical Summary
In the RPC system, due to network sharding, TCP mechanism and multi-queue reception, data packets may arrive in out of order, resulting in discontinuous storage locations in the buffer data structure of the receiving end, affecting RPC data processing efficiency and system performance.
The packet header and body of the data packet are stored in different ring buffers through the network card, and the central processor reconstructs the requested data based on the data stored in these buffers to achieve correct analysis and processing of the data.
This method avoids the CPU directly participating in data processing, reduces CPU load, improves data throughput, reduces memory bandwidth usage, and significantly improves the performance of RPC system.
Smart Images

Figure CN120050319A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer network communication, and particularly to an RPC data processing method, an electronic device, a storage medium, and a program product. Background Art
[0002] The global scale and challenging requirements of modern cloud applications have led to the development of complex, widely distributed, service-oriented applications. Remote Procedure Call (RPC) is one of the enabling technologies for such applications. It is the basis for communication between servers and the standard communication layer for cloud services. RPC allows developers to build network applications using a simple and familiar programming model and is supported by multiple popular libraries such as gRPC, Thrift, and eRPC, etc. RPC systems have been widely applied to distributed data storage, network file systems, consensus protocols, data analysis frameworks, as well as cluster schedulers and coordinators.
[0003] In an RPC system, request data is transmitted from a sending end to a receiving end, and the receiving end processes it and returns a response. During the transmission of the request data, due to requirements such as Maximum Transmission Unit (MTU) limitations, network device policies, and transport layer protocols, larger request data is often split into multiple data packets for transmission at the sending end; in high-throughput scenarios, the receiving end typically uses a buffered data structure for data reception and recombination.
[0004] However, due to reasons such as network fragmentation, TCP mechanisms, and multi-queue reception, data packets may arrive out of order, resulting in discontinuous storage positions of the data in the buffered data structure at the receiving end. In order to ensure correct data parsing, it is necessary to move the data in the buffered data structure to make it continuous, which affects the RPC data processing efficiency and system performance. Summary of the Invention
[0005] The present invention provides an RPC data processing method, an electronic device, a storage medium, and a program product.
[0006] According to one aspect of the present invention, there is provided an RPC data processing method, including: in response to a data packet sent by a sending end based on request data, obtaining a packet header and a packet body from the data packet through a network card; storing the packet header into a first circular buffer and storing the packet body into a second circular buffer different from the first circular buffer through the network card; reconstructing the request data according to the data stored in the first circular buffer and the second circular buffer by a central processing unit.
[0007] According to the RPC data processing method of at least one embodiment of the present invention, the data packet sent by the sending end based on the request data is obtained by the sending end after serializing the request data; the reconstructing the request data by the central processing unit according to the data stored in the first circular buffer and the second circular buffer includes: deserializing the data stored in the first circular buffer and the second circular buffer by the central processing unit to obtain the request data.
[0008] According to the RPC data processing method of at least one embodiment of the present invention, when the sending end serializes the request data, the sending end is used to obtain the pointer and length of each field in the request data, respectively construct scatter-gather elements for each field according to the pointer and length of each field, and obtain a data packet according to the scatter-gather element array based on the scatter-gather elements of each field.
[0009] According to the RPC data processing method of at least one embodiment of the present invention, when the sending end is used to respectively construct scatter-gather elements for each field according to the pointer and length of each field, the sending end is specifically used to respectively construct scatter-gather elements for each field according to the pointer and length of each field with a length greater than 0; and / or when the sending end is used to construct a scatter-gather element array based on the scatter-gather elements of each field, the sending end is specifically used to obtain the processing order and memory alignment constraint of the scatter-gather elements of each field; construct a scatter-gather element array according to the processing order and memory alignment constraint of the scatter-gather elements of each field; and / or the process of the sending end obtaining the data packet is limited by the maximum transmission unit.
[0010] According to the RPC data processing method of at least one embodiment of the present invention, after the central processing unit reconstructs the request data according to the data stored in the first circular buffer and the second circular buffer, it further includes: processing the request data by the central processing unit to obtain response data of the request data; sending the response data to the sending end by the central processing unit.
[0011] The RPC data processing method according to at least one embodiment of the present invention, wherein the processing of the request data by the central processing unit includes: obtaining a processing thread of the request data by the central processing unit; processing the request data in the processing thread by the central processing unit; and / or the interaction with the sending end is controlled by a sending end driver protocol, the sending end driver protocol stipulates that the sending end controls the sending of data packets in batches, for data packets other than the last data packet in the data packets sent in batches by the sending end, a token is returned explicitly, and for the token of the last data packet in the data packets sent in batches by the sending end, it is implicitly returned in the first response data packet of the response data, and the first response data packet in the response data is returned after the first data packet in the data packets sent in batches is processed; the response data packets after the first response data packet are triggered to be returned by the sending end through request response data packets.
[0012] The RPC data processing method according to at least one embodiment of the present invention, before responding to the data packets sent by the sending end based on the request data, further includes: allocating a double buffer for the RPC connection of the sending end by the central processing unit, storing the corresponding relationship between the RPC connection and the double buffer in a management database by the central processing unit, the double buffer corresponds to the RPC connection one by one, and the double buffer includes a first circular buffer for storing packet headers and a second circular buffer for storing packet bodies; the storing of the packet header in the first circular buffer and the packet body in the second circular buffer by the network card includes: obtaining the RPC connection used by the request data by the network card; determining the double buffer of the RPC connection used by the request data from the management database by the network card; storing the packet header in the first circular buffer by the network card; storing the packet body in the second circular buffer by the network card.
[0013] According to another aspect of the present invention, there is provided an electronic device, including: a memory storing execution instructions; and a processor that executes the execution instructions stored in the memory, so that the processor executes the RPC data processing method according to any one of the embodiments of the present invention.
[0014] According to still another aspect of the present invention, there is provided a readable storage medium storing execution instructions, and when the execution instructions are executed by a processor, they are used to implement the RPC data processing method according to any one of the embodiments of the present invention.
[0015] According to yet another aspect of the present invention, there is provided a computer program product including a computer program, and when the computer program is executed by a processor, it implements the RPC data processing method according to any one of the embodiments of the present invention. Description of the Drawings
[0016] The accompanying drawings illustrate exemplary embodiments of the present invention and, together with the description thereof, are used to explain the principles of the present invention. These accompanying drawings are included to provide a further understanding of the present invention and are included in this specification and form a part of this specification.
[0017] Figure 1 It is a schematic diagram of an application scenario of the RPC data processing method according to an embodiment of the present invention.
[0018] Figure 2 It is the flow of the RPC data processing method according to an embodiment of the present invention Figure 1 .
[0019] Figure 3 It is the flow of the RPC data processing method according to an embodiment of the present invention Figure 2 .
[0020] Figure 4 It is the flow of the RPC data processing method according to an embodiment of the present invention Figure 3 .
[0021] Figure 5 It is Figure 4 The flowchart of the request processing method in the RPC data processing method shown.
[0022] Figure 6 It is the flow of the RPC data processing method according to an embodiment of the present invention Figure 4 .
[0023] Figure 7 It is Figure 6 The flowchart of the buffer writing method in the RPC data processing method shown.
[0024] Figure 8 It is the interactive schematic flowchart of the RPC data processing method according to an embodiment of the present invention.
[0025] Figure 9 It is the structural schematic block diagram of the RPC data processing device according to an embodiment of the present invention.
[0026] Figure 10 It is the structural schematic block diagram of an electronic device according to an embodiment of the present invention. Detailed Embodiments
[0027] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It can be understood that the specific examples described herein are only used to explain the relevant content and do not limit the present invention. Additionally, it should be noted that for the convenience of description, only parts related to the present invention are shown in the accompanying drawings.
[0028] It should be noted that, without conflict, the embodiments in the present invention and the features in the embodiments can be combined with each other. The technical solutions of the present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0029] In 4K video stream transmission scenarios such as cloud gaming, cloud rendering, remote desktop, video on demand, and live streaming, the sending end needs to transmit video data to the receiving end through RPC (Remote Procedure Call), ensuring high-quality and low-latency video playback. Taking the example that a single RPC needs to transmit 200MB of high-definition video data, since it exceeds the MTU (Maximum Transmission Unit) limit in network transmission (for example, the Ethernet MTU is usually 1500 bytes), in order to ensure efficient transmission, the sending end will split the high-definition video data into 139,811 data packets for transmission. When the receiving end uses a buffer data structure to store the data packets, due to network congestion, multiple data packets arrive through different network card queues, resulting in out-of-order data stored in the buffer data structure. For example, the order of data packet arrival is [3], [1], [4], [2]... Since data packets [1] and [2] are stored in the wrong positions in the buffer data structure, they must be moved to the correct positions to be correctly parsed. When moving the data packets, all data packets need to be traversed to find the correct positions and rearranged. This will increase the burden on the CPU (Central Processing Unit), affecting the RPC data processing efficiency and system performance.
[0030] Therefore, the present invention proposes an RPC data processing method, an electronic device, a storage medium, and a program product. The present invention can be implemented through remote procedure call data processing software installed on electronic devices such as servers and embedded devices.
[0031] Figure 1 FIG. shows an application scenario of the RPC data processing method according to an embodiment of the present invention. In this application scenario, it may include a sending end 100 and a receiving end 200, and the sending end 100 establishes a communication connection with the receiving end 200 through a network.
[0032] For the convenience of description and to make the technical solutions of the specific embodiments of the present invention easier to understand, the technical terms related to the present invention are explained as follows.
[0033] RPC (Remote Procedure Call) is a technology that allows a program to call services on a remote device as if it were calling a local function.
[0034] The packet header is the control information part of the data packet, used to identify the transmission attributes, routing path, and protocol type of the data packet, and is usually located at the front of the data packet.
[0035] The packet body is the actual payload transmitted in the data packet, containing application layer data such as RPC request parameters, file data, video streams, database query results, etc.
[0036] Serialization refers to the conversion of a data structure or object into a format that can be stored or transmitted.
[0037] Deserialization refers to the process of restoring serialized data to its original data structure or object state.
[0038] MTU (Maximum Transmission Unit) is the maximum size of a single data packet or data frame that a network device can transmit in the network layer or data link layer, usually expressed in bytes.
[0039] Figure 2 The overall flowchart of the RPC data processing method M100 according to an embodiment of the present invention is shown. As Figure 2 The method shown includes steps S110 to S130.
[0040] In step S110, in response to the data packet sent by the sending end based on the request data, the packet header and packet body are obtained from the data packet through the network card.
[0041] In some embodiments of the present invention, the request data in step S110 is usually information for requesting the execution of a target operation. The request data contains the parameters required to call the target method and other necessary metadata. Specifically, the request data usually includes: method name or identifier for specifying the remote method or service to be called, parameter data required by the remote method, timestamp, timeout setting, authentication information, and other metadata.
[0042] To prevent the data packet sent by the sending end from being too large (i.e., exceeding the pre-set MTU), resulting in the data packet being discarded and affecting system performance, the size of the data packet can be controlled to be less than the MTU at the sending end. Among them, the MTU can be set based on network type (such as the MTU of Ethernet is set to 1500 bytes, the MTU of IPv6 is set to 1280 bytes, the MTU of WiFi is set to 2304 bytes, etc.), hardware devices (such as the MTU limit of hardware devices such as network cards and routers), transmission protocols (different protocols have different requirements for MTU), etc.
[0043] A network card is a hardware device at the data link layer, used to receive, send, and transmit data packets. When a data packet arrives at the network card, the network card can parse the data packet based on the packet parsing logic to extract the packet header and the packet body. This packet parsing logic can be implemented by dedicated network card hardware circuits (such as application-specific integrated circuits or field-programmable gate arrays), network card firmware (firmware running on the embedded processor of the network card), or programmable processors.
[0044] In step S120, the packet header is stored in the first circular buffer through the network card, and the packet body is stored in a second circular buffer different from the first circular buffer.
[0045] In some embodiments of the present invention, step S120 can use direct memory access (DMA) through the network card to store the packet header and the packet body in the first circular buffer and the second circular buffer respectively.
[0046] In particular, the first circular buffer and the second circular buffer in step S120 can share the same index variable, so as to ensure that the packet header and the packet body of each data packet always match, thereby improving data consistency. In addition, the first circular buffer and the second circular buffer sharing the same index variable can also reduce the computational and synchronization overhead of managing two independent index variables, and at the same time reduce the complexity of data copying and moving. Through the same index variable, it is also possible to simplify the synchronization control of the first circular buffer and the second circular buffer, reduce the coordination and management overhead during concurrent access, thereby simplifying the RPC data processing flow, and improving synchronization and the overall system performance.
[0047] In a multi-producer or multi-consumer scenario, a locking mechanism or other synchronization mechanism can be adopted for the first circular buffer and the second circular buffer in step S120 to ensure data consistency. In a single-producer or single-consumer scenario, a lock-free design can be adopted for the first circular buffer and the second circular buffer in step S120, thereby improving the RPC data processing efficiency.
[0048] In step S130, the CPU reconstructs the request data according to the data stored in the first circular buffer and the second circular buffer.
[0049] In some embodiments of the present invention, step S130 can directly use polling or other methods by the CPU to read the packet header from the first circular buffer and read the packet body from the second circular buffer, and implement data reconstruction according to the packet header and the packet body.
[0050] The RPC data processing method provided by the present invention utilizes the multi-queue feature of the network card to achieve separate storage of the packet header and the packet body in the data packet. During the process of reconstructing the request data, there is no need to move or copy the data, solving the problems in the prior art due to reasons such as network fragmentation, TCP (Transmission Control Protocol) mechanism, and multi-queue reception. The data packets may arrive out of order, resulting in discontinuous storage positions of the data in the buffer data structure at the receiving end. To ensure correct data parsing, it is necessary to move the data in the buffer data structure to make it continuous, which affects the RPC data processing efficiency and system performance. By implementing separate storage of the packet header and the packet body through the network card, it is also possible to avoid direct participation of the CPU in data processing, thereby reducing the CPU load, increasing the data throughput, and reducing the memory bandwidth occupancy.
[0051] In some embodiments of the present invention, the network card at the receiving end can support the zero-copy technology, allowing direct access between the network card and the memory, thereby avoiding data copy operations and reducing the burden on the CPU and the consumption of memory bandwidth.
[0052] Regarding the data packet sent by the sending end based on the request data in step S110, it can specifically be the result of serializing the request data by the sending end.
[0053] Specifically, the process of serializing the request data by the sending end may include: the sending end organizes the request data into a structured data object through the CPU according to information such as the method name, parameters, and request ID (the unique identifier for tracking the request) required for RPC transmission; the sending end converts the structured data object into a binary data stream through the CPU using a serialization method (such as JSON (JavaScript Object Notation, a lightweight data interchange format), Protobuf (Protocol Buffer, a data description language), MessagePack (a binary serialization format), Thrift (a remote procedure call framework), etc.); the sending end encapsulates the binary data stream into a data packet through the CPU. In particular, during the process of encapsulating the binary data stream into a data packet, the encapsulation process can also be controlled based on a pre-set MTU, so that the encapsulated data packet conforms to the pre-set MTU, thereby enabling each data packet to maximize the use of network bandwidth and improving network transmission efficiency.
[0054] At this time, regarding step S130, in some embodiments of the present invention, it can specifically be the following step S131 as Figure 3 shown: Deserialize the data stored in the first circular buffer and the second circular buffer through the CPU to obtain the request data.
[0055] In some embodiments of the present invention, to ensure the correct restoration of the requested data and the security and stability of the system, the deserialization needs to follow the same data format protocol as that during serialization. The deserialization process in this step is the process of restoring the requested data from the first circular buffer and the second circular buffer.
[0056] By implementing the sending and restoration of the requested data through serialization and deserialization, cross-network transmission of the requested data can be achieved, improving the data transmission efficiency.
[0057] In some embodiments of the present invention, when the sender serializes the requested data, the sender is specifically configured to: obtain the pointers and lengths of each field in the requested data, respectively construct scatter-gather elements for each field based on the pointers and lengths of each field, and obtain a data packet based on the scatter-gather element array after constructing the scatter-gather element array for each field.
[0058] The sender can execute the above entire process through the CPU of the sender. In particular, the sender can also be responsible for obtaining the above pointers and lengths, constructing scatter-gather elements and the scatter-gather element array through the CPU of the sender, and be responsible for obtaining the data packet through the network card of the sender, so as to separate the work of the CPU and the network card of the sender, thereby avoiding a single resource from becoming a bottleneck and overall improving the data transmission efficiency.
[0059] The content of specific fields in the requested data usually depends on the specific RPC protocol, framework, and application scenario; generally speaking, the requested data may include the following fields: request identifier (used to identify the requested data), method name (used to specify the name of the function or method that needs to be remotely called), parameters (used to specify the parameters required for remotely calling the method or function), authentication information (used to provide authentication credentials or tokens), request timestamp (used to mark the time when the requested data is sent), sender information (used to provide the identification, version number, etc. of the client), packet header (used to provide meta-information of the requested data), packet body (used to provide the actual content of the request), etc.
[0060] The pointer and length of a certain field in the requested data are used to help find the data of that field; among them, the pointer of that field can be the memory address pointing to the data storing that field, and the length of that field can be the size of the data of that field, usually in bytes. Through the pointer of that field, the position of the data of that field can be quickly found, and through the length of that field, the content of the field can be correctly read to prevent data out-of-bounds.
[0061] In this step, the scatter-gather element is a data structure used to describe the position information of each field in the request data. When the sender constructs an array of scatter-gather elements based on the scatter-gather elements of each field in this step, it can first construct an empty array of scatter-gather elements. After constructing the scatter-gather element of each field, each scatter-gather element of each field is pushed to the end of the empty array of scatter-gather elements one by one, thus forming the final array of scatter-gather elements.
[0062] Through the above serialization process, the sender can achieve introspective serialization, which can make better use of network bandwidth, reduce data reorganization and copying, avoid the memory occupation of the entire data structure, reduce memory pressure and performance overhead, enable complex request data to be directly sent to the receiver, and improve data transmission efficiency.
[0063] When the sender constructs the scatter-gather element of each field according to the pointer and length of each field respectively, the constructed scatter-gather element can include all fields in the request data. In particular, when the sender is used to construct the scatter-gather element of each field according to the pointer and length of each field respectively, the sender can also be specifically used to construct the scatter-gather element of each field according to the pointer and length of each field with a length greater than 0 respectively.
[0064] In some embodiments of the present invention, a field with a length of 0 usually indicates that the field exists, but it does not contain any content, that is, the field is empty; this may mean data loss, the field is not applicable, or the field is optional and no data is filled.
[0065] Through this step, the processing of fields with a length of 0 can be skipped, so that the scatter-gather element only contains useful data, thereby reducing the processing of invalid data and improving data transmission efficiency and overall performance.
[0066] When the sender is used to construct an array of scatter-gather elements based on the scatter-gather elements of each field, the sender can directly construct the array of scatter-gather elements in the construction order of the scatter-gather elements, or the sender can construct the array of scatter-gather elements in the order of the size of the length values in the scatter-gather elements, or the sender can also randomly shuffle the order of the scatter-gather elements and then construct the array of scatter-gather elements, etc.
[0067] In particular, the sender can also be specifically used to obtain the processing order and memory alignment constraints of the scatter-gather elements of each field; construct an array of scatter-gather elements according to the processing order and memory alignment constraints of the scatter-gather elements of each field.
[0068] In some embodiments of the present invention, the processing order of the scatter-gather elements is usually specified or adjusted by the user according to needs. Memory alignment constraints require that data be aligned according to the constraint address boundaries when stored to meet the requirements of hardware or DMA (Direct Memory Access). The scatter-gather elements corresponding to the memory alignment constraints have a higher priority than those specified by the processing order, and the scatter-gather elements corresponding to the memory alignment constraints need to be sorted first when constructing the scatter-gather element array.
[0069] When constructing the scatter-gather element array through this step, an empty scatter-gather element array can be constructed first, and then the scatter-gather elements corresponding to the memory alignment constraints are sequentially pushed to the end of the empty scatter-gather element array according to the processing order. Finally, the scatter-gather elements other than those corresponding to the memory alignment constraints are sequentially pushed to the end of the empty scatter-gather array according to the processing order to obtain the final scatter-gather element array.
[0070] When constructing the scatter-gather element array in this step, considering both the processing order and the memory processing constraints not only improves data locality but also optimizes the memory access speed, which can enhance data processing efficiency and the overall system performance.
[0071] The sender can directly obtain a large data packet. In particular, to prevent a high packet loss rate and increased latency caused by retransmission, the process of the sender obtaining the data packet can be limited by the maximum transmission unit; when the data packet is limited by the MTU, the data packet can be split based on the MTU to ensure that each split data packet is smaller than the MTU.
[0072] The process of the sender obtaining the data packet can also be restricted by the maximum request size of the server, the server processing capacity, security policies, etc.
[0073] Furthermore, the RPC data processing method provided by the present invention, after step S130, may further include steps S140 to S150 as Figure 4 shown.
[0074] In step S140, the CPU processes the request data to obtain the response data of the request data. In some embodiments of the present invention, in step S140, the CPU can parse the request data to obtain the RPC request parameters, and then call the corresponding local function or local method based on the RPC request parameters for processing to obtain the response data of the request data. Among them, the processing based on the RPC request parameters to call the corresponding local function or local method may involve operations such as database query, calling other application programming interfaces (Application Programming Interface, API), computing data (such as AI inference, data analysis, etc.).
[0075] Step S150: Send response data to the sending end through the CPU. In some embodiments of the present invention, when sending response data to the sending end through the CPU in step S150, it is usually necessary to ensure that the response data does not exceed the MTU, and if necessary, the response data needs to be split.
[0076] The interaction between the sending end and the receiving end is realized through steps S140 to S150.
[0077] Regarding step S140, in some embodiments of the present invention, it may include steps S141 to S142 as Figure 5 shown.
[0078] Step S141: Obtain the processing thread of the request data through the CPU. In some embodiments of the present invention, step S141 may obtain the processing thread of the request data based on a user instruction. The processing thread of the request data may specifically be a scheduling thread or a working thread of the receiving end, etc. The scheduling thread is used to process fast and short-term tasks, such as tasks at the nanosecond level. The working thread is used to process longer and resource-intensive tasks, such as tasks at the microsecond, millisecond level or longer.
[0079] Step S142: Process the request data in the processing thread through the CPU. In some embodiments of the present invention, when processing the request data in the processing thread through the CPU in step S142, it can be achieved by means of task allocation through a thread pool, binding the request data to the processing thread for execution, or controlling the processing thread to process the request data through a queue, etc.
[0080] Steps S141 to S142 can share resource conflicts through thread control, improving data consistency, the stability of RPC data processing, and the response speed.
[0081] In some embodiments of the present invention, the interaction with the sending end can be controlled by a protocol in which both the receiving end and the sending end can independently send data (such as a two-way communication protocol or a full-duplex protocol, etc.). In particular, in order to reduce the burden on the receiving end, simplify the implementation and maintenance of the protocol, and reduce the protocol complexity, the interaction with the sending end can also be controlled by a sending-end-driven protocol, which stipulates that the sending end batch-controls the sending of data packets. For data packets other than the last data packet in the data packets batch-sent by the sending end, CR (Credit Return) is displayed. For the token of the last data packet in the data packets batch-sent by the sending end, it is implicitly returned in the first response data packet of the response data, and the first response data packet is returned after processing the first data packet in the batch-sent data packets; the response data packets after the first response data packet are triggered and returned by the sending end through RFR (Request for Response) data packets.
[0082] In some embodiments of the present invention, the above-mentioned sending-end-driven protocol can control the sending volume of data packets based on a preset token limit for each session. Taking the token limit as C, when the sending end batch-controls the sending of data packets, it can control the sending of a window containing at most C data packets.
[0083] In the process of controlling the interaction between the sending end and the receiving end based on the sending-end-driven protocol, each response data packet returned by the receiving end is a response to the data packet sent by the sending end. The sending-end-driven protocol has fewer "moving parts" than a protocol in which both the sending end and the receiving end can independently send data. The transmission of data may fail due to network errors, packet loss, or other problems. At this time, the retransmission mechanism becomes an important means to ensure reliable data transmission. In the sending-end-driven protocol, only the sending end maintains the wired protocol state rolled back during retransmission, which eliminates the need for coordination between the sending end and the receiving end before rollback, thereby reducing the complexity of data transmission. The sending-end-driven protocol also completely transfers the overhead of rate limiting to the sending end, thereby releasing the CPU of the receiving end, which is usually more valuable.
[0084] The data transmission rate of the sending end can also be controlled through CR, that is, the traffic of the sending end is controlled, so as to ensure that the receiving end will not be flooded with data and prevent the receiving end from overloading. Embedding the token of the last data packet in the batch of sent data packets into the first response data packet can save additional control messages, reduce the additional traffic and bandwidth occupation on the network, and the reduction of an additional interaction can also bring obvious delay optimization and improve the data interaction efficiency. Controlling the sending of response data packets through RFR can prevent the receiving end from sending too much data at one time and causing network congestion; and the sending end controls when to receive response data through RFR, enabling the sending end to adjust the receiving rhythm according to its own processing ability, improving the flexibility of data processing, and avoiding the CPU overload of the sending end.
[0085] Further, the RPC data processing method provided by the present invention may further include steps S160 to S170 as Figure 6 shown before step S110.
[0086] In step S160, the CPU allocates a double buffer for the RPC connection of the sending end.
[0087] In some embodiments of the present invention, the double buffer in step S160 corresponds one-to-one with the RPC connection. The double buffer includes a first circular buffer for storing the packet header and a second circular buffer for storing the packet body. Based on the above limitations, corresponding buffers can be allocated for different RPC connections.
[0088] In step S170, the CPU stores the corresponding relationship between the RPC connection and the double buffer in the management database.
[0089] In some embodiments of the present invention, the management database in step S170 is used to manage the corresponding relationship between different RPC connections and different double buffers.
[0090] Step S160 controls the one-to-one correspondence between the double buffer and the RPC connection, that is, a separate circular buffer for storing the packet header and a circular buffer for storing the packet body are allocated for each PRC connection, which can reduce the memory copy caused by the discontinuity of the packet body.
[0091] At this time, regarding step S120, in some embodiments of the present invention, it may include steps S121 to S124 as Figure 7 shown.
[0092] In step S121, the RPC connection used for obtaining the request data is acquired through the network card.
[0093] In step S122, the double buffer of the RPC connection used for the request data is determined from the management database through the network card.
[0094] In some embodiments of the present invention, step S122 may search for corresponding data from the management database through the network card based on the PRC connection used by the request data, and determine the double buffer of the RPC connection used by the request data based on the found data.
[0095] In step S123, the network card stores the packet header into the first circular buffer. In step S124, the network card stores the packet body into the second circular buffer.
[0096] During the process of storing data into the first circular buffer and the second circular buffer by the network card in step S123 and step S124, the first circular buffer and the second circular buffer can be registered as memory areas accessible by RDMA (Remote Direct Memory Access). Two scatter-gather elements are constructed for the packet header and the packet body respectively. One of the two scatter-gather elements points to the first circular buffer, and its size is set to the length of the packet header; the other scatter-gather element of the two scatter-gather elements points to the second circular buffer, and its size is set to the MTU minus the length of the packet header. Create an ibv_recv_wr structure (a structure of the RDMA protocol), and bind the two scatter-gather elements to obtain a WQE (Work Queue Element); call the ibv_post_recv structure (a structure of the RDMA protocol) to submit the WQE to achieve data storage.
[0097] Steps S121 to S124 store the packet header and the packet body into the double circular buffer corresponding to the RPC connection, thereby enhancing the independence of data processing.
[0098] The RPC data processing method provided by the present invention can reduce the CPU overhead and simultaneously achieve efficient data transmission and processing. After testing, compared with eRPC (Embedded Remote Procedure Call Component) on the YCSB (Yahoo Cloud Serving Benchmark) key-value store, the RPC data processing method provided by the present invention can reduce the 99th percentile tail latency (P99 latency, which means that 99% of the requests are completed within this time range, and only 1% of the requests are slower than this time) by about 21%, and the throughput is increased by about 62%, significantly improving the performance of the RPC system in a high-throughput and low-latency network environment.
[0099] When testing RPCs with a size of 1MB, the P99 latency of the RPC data processing method provided by the present invention is reduced by 3.3 times and 4.2 times respectively compared to that of eRPC+FlatBuffers (FB) and eRPC+Protocol Buffers (PB). Here, FlatBuffers is a serialization library, and Protocol Buffers is a data serialization protocol.
[0100] When testing request data of 512B, the throughput of the RPC data processing method provided by the present invention reaches 1.68 Mrps, while that of eRPC+FB is 1.45 Mrps and that of eRPC+PB is 1.21 Mrps. The throughput of the RPC data processing method provided by the present invention is 15.8% and 38.8% higher than theirs respectively; when the P99 latency is 32 μs, the throughput of the RPC data processing method provided by the present invention is 33.9% higher than that of Cornflakes.
[0101] The RPC data processing method provided by the present invention can be applied to scenarios such as microservice architectures, database and storage systems, cloud computing and distributed computing, high-frequency trading and financial systems.
[0102] Figure 8 An exemplary flowchart implemented based on the RPC data processing method of the present invention is shown.
[0103] Figure 8 In the shown flowchart, taking the high-frequency trading scenario as an example, in this scenario, the receiving end needs to receive market data in real time, and the sending end needs to submit trading requests with extremely low latency. The RPC data processing method may include: Step S210, the sending end obtains the pointers and lengths of each field in the trading instruction.
[0104] In some embodiments of the present invention, the trading instruction in step S210 is the request data in the RPC system. The fields of the trading instruction in step S210 may include order basic information (such as order unique identifier, order creation time, etc.), trading direction (such as buy or sell), price information (such as order price, trading quantity, trading amount, etc.), and so on.
[0105] The pointer obtained through step S210 may be a specific memory address, such as 0x1000A, 0x10010, etc.; the length obtained through step S210 may be expressed in bytes, such as 6 bytes, 8 bytes, etc. (byte is a byte).
[0106] Step S220, the sending end constructs scatter-gather elements for each field respectively according to the pointer and length of each field.
[0107] In some embodiments of the present invention, taking the fields of a trading instruction including an order unique identifier, an order creation time, a trading direction, and an order price as an example, the scatter collection elements of the above four fields can be obtained through step S220.
[0108] Step S230, the sending end obtains the processing order and memory alignment constraints of the scatter collection elements of each field.
[0109] In some embodiments of the present invention, the processing order obtained through step S230 indicates which scatter collection elements of which fields are processed first and which are processed later. Assume that the processing order obtained through step S230 is the scatter collection elements of order unique identifier → order creation time → trading direction → order price.
[0110] The memory alignment constraints obtained through step S230 can determine which scatter collection elements of which fields need to be subjected to memory alignment processing. Assume that the memory alignment constraints obtained through step S230 are that the data corresponding to the scatter collection elements of the "order price" field needs to be aligned by 8 bytes.
[0111] Step S240, the sending end constructs a scatter collection element array according to the processing order and memory alignment constraints of the scatter collection elements of each field.
[0112] In some embodiments of the present invention, when constructing a scatter collection element array according to the above processing order and memory alignment constraints, the order of the fields of the scatter collection elements in the constructed scatter collection element array can be: order price → order unique identifier → order creation time → trading direction.
[0113] Step S250, the sending end obtains a data packet according to the scatter collection element array. Step S260, the sending end sends the data packet to the receiving end. Step S270, in response to the data packet sent by the sending end based on the request data, the receiving end obtains the packet header and the packet body from the data packet through the network card. Step S280, the receiving end stores the packet header in the first circular buffer and stores the packet body in a second circular buffer different from the first circular buffer through the network card. Step S290, the receiving end reconstructs the request data according to the data stored in the first circular buffer and the second circular buffer through the CPU.
[0114] Based on any of the above embodiments, the present invention also provides an RPC data processing device.
[0115] Figure 9 It is a structural schematic block diagram of an RPC data processing device according to an embodiment of the present invention.
[0116] Such as Figure 9As shown in the figure, the RPC data processing device includes a data separation module 110, a data storage module 120, and a data reconstruction module 130. The data separation module 110 is configured to obtain a packet header and a packet body from a data packet through a network card in response to a data packet sent by a sending end based on request data. The data storage module 120 is configured to store the packet header into a first circular buffer and store the packet body into a second circular buffer different from the first circular buffer through the network card. The data reconstruction module 130 is configured to reconstruct the request data according to the data stored in the first circular buffer and the second circular buffer by a CPU.
[0117] The above RPC data processing device may be in the form of computer software, and each module of the above RPC data processing device may be implemented by computer software modules.
[0118] For the implementation processes of the functions and roles of each module in the above device, please refer to the implementation processes of the corresponding steps in the above method for details, which will not be elaborated here.
[0119] The execution subject of the RPC data processing method in the specific implementation manner of the present invention may be an electronic device such as a server.
[0120] Therefore, based on any one of the above embodiments, the present invention further provides an electronic device, which can execute the RPC data processing method of any one of the above embodiments described in the present invention.
[0121] Figure 10 It is a structural schematic block diagram of an electronic device 1000 according to an embodiment of the present invention.
[0122] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture may include any number of interconnected buses and bridges, depending on the specific application of the hardware and the overall design constraints. The bus 1100 connects various circuits including one or more processors 1200, a memory 1300, and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, and external antennas.
[0123] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only one connection line is used in this figure, but it does not mean that there is only one bus or one type of bus.
[0124] The present invention also provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the above-mentioned method. The "readable storage medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples of the readable storage medium include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.
[0125] The present invention also provides a computer program product. The method of the present invention can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the processes or functions of the present invention are executed in whole or in part.
[0126] The computer program or instructions can be stored in a readable storage medium, or transmitted from one readable storage medium to another. For example, the computer program or instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired or wireless manner. The readable storage medium can be any available medium that can be accessed, or a data storage device such as a server or data center integrating one or more available mediums. The available medium can be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it can also be an optical medium, such as a digital video disc; or it can be a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.
[0127] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.
[0128] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices produce a means for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks that specify the functions.
[0129] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction means that implements the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks that specify the functions.
[0130] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks that specify the functions.
[0131] In the description of this specification, the description with reference to terms such as "one embodiment / way", "some embodiments / ways", "example", "specific example", or "some examples" means that the specific features, structures, or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of the present invention. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment / way or example. Moreover, the specific features, structures, or characteristics described can be combined in a suitable manner in any one or more embodiments / ways or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments / ways or examples described in this specification and the features of different embodiments / ways or examples.
[0132] Those skilled in the art should understand that the above embodiments are only for clearly illustrating the present invention, rather than limiting the scope of the present invention. For those skilled in the art, other changes or modifications can be made based on the above disclosure, and these changes or modifications are still within the scope of the present invention.
Claims
1. A RPC data processing method, characterized in that: include: In response to a data packet sent by the sending end based on the request data, obtaining a packet header and a packet body from the data packet through the network card; storing the packet header into a first ring buffer and storing the packet body into a second ring buffer different from the first ring buffer through the network card; as well as The request data is reconstructed by a central processing unit according to the data stored in the first ring buffer and the second ring buffer.
2. The RPC data processing method according to claim 1, characterized in that: The data packet sent by the sending end based on the request data is obtained after the sending end serializes the request data; The reconstructing the request data according to the data stored in the first ring buffer and the second ring buffer by the central processor includes: deserializing the data stored in the first ring buffer and the second ring buffer by the central processor to obtain the request data.
3. The RPC data processing method according to claim 2, characterized in that: When the sending end serializes the request data, the sending end is used to obtain the pointer and length of each field in the request data, construct a scatter collection element for each field according to the pointer and length of each field, construct a scatter collection element array based on the scatter collection elements of each field, and then obtain a data packet according to the scatter collection element array.
4. The RPC data processing method according to claim 3, characterized in that: When the transmitting end is used to construct the scatter-gather element of each field according to the pointer and length of each field respectively, the transmitting end is specifically used to construct the scatter-gather element of each field according to the pointer and length of each field whose length is greater than 0 respectively; and / or When the sending end is used to construct a scatter-collected element array based on the scatter-collected elements of each field, the sending end is specifically used to obtain a processing order and a memory alignment constraint of the scatter-collected elements of each field; and construct the scatter-collected element array according to the processing order and the memory alignment constraint of the scatter-collected elements of each field; and / or The process of the sending end acquiring the data packet is limited by the maximum transmission unit.
5. The RPC data processing method according to any one of claims 1 to 4, characterized in that: After the central processor reconstructs the request data according to the data stored in the first ring buffer and the second ring buffer, the method further includes: Processing the request data by the central processing unit to obtain response data of the request data; and The response data is sent to the sending end through the central processing unit.
6. The RPC data processing method according to claim 5, characterized in that: Processing the request data by the central processor includes: obtaining a processing thread for the request data by the central processor; processing the request data in the processing thread by the central processor; and / or The interaction with the sender is controlled by a sender driver protocol, which stipulates that the sender controls the sending of data packets in batches. Data packets other than the last data packet in the batch sent by the sender are returned by an explicit token, and the token of the last data packet in the batch sent by the sender is implicitly returned in the first response data packet of the response data. The first response data packet in the response data is returned after the first data packet in the batch sent is processed; the response data packets after the first response data packet are triggered and returned by the sender through a request response data packet.
7. The RPC data processing method according to any one of claims 1 to 4, characterized in that: Before the data packet sent by the sending end based on the request data is responded to, the method further includes: allocating a double buffer for the RPC connection of the sending end through the central processor, storing the corresponding relationship between the RPC connection and the double buffer in a management database through the central processor, wherein the double buffer corresponds to the RPC connection one by one, and the double buffer includes a first ring buffer for storing a packet header and a second ring buffer for storing a packet body; Storing the packet header into the first ring buffer and storing the packet body into the second ring buffer through the network card includes: obtaining the RPC connection used by the request data through the network card; determining the double buffer of the RPC connection used by the request data from the management database through the network card; storing the packet header into the first ring buffer through the network card; storing the packet body into the second ring buffer through the network card.
8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instructions stored in the memory, so that the processor executes the RPC data processing method according to any one of claims 1 to 7.
9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the RPC data processing method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the RPC data processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Out of order read transfer with host memory buffer
CN108885584A
File rearrangement method, system and device and readable storage medium
CN112165457A
Data transmission method and device, electronic equipment and computer storage medium
CN113422792A
Data processing method, reconfigurable data processing chip and electronic equipment
CN118568742A
SNMP-based IPv6 sensor network node management method
CN1777123A
Cited By
Financial information submission method and device, computer equipment and readable storage medium
CN120281806A