A method and system for data processing in a remote procedure call

By using a zero-copy information conversion library in remote procedure calls, the data to be transmitted is divided into serialized and unserialized parts, which solves the problem of low processing efficiency caused by memory copying in RPC systems and achieves more efficient data transmission.

CN115269223BActive Publication Date: 2026-07-24ALIBABA (CHINA) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIBABA (CHINA) CO LTD
Filing Date
2022-07-20
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

Existing Remote Procedure Call (RPC) systems suffer from low processing efficiency during serialization and deserialization due to memory allocation and memory copying operations, making them unsuitable for scenarios with strict latency and resource consumption requirements.

Method used

A zero-copy information conversion library is used to divide the data to be transmitted into two parts: serialized and unserialized. Only the unserialized part is copied into memory, and the data is transmitted directly through the address values ​​of predefined fields, reducing the memory copy overhead.

Benefits of technology

It reduces the processing latency and memory copy overhead of remote procedure calls, improves processing efficiency, and meets the needs of scenarios with strict requirements on latency and resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115269223B_ABST
    Figure CN115269223B_ABST
Patent Text Reader

Abstract

The application discloses a data processing method and system in a remote procedure call, and the method comprises the following steps: one party of the remote procedure call acquires to-be-transmitted data, wherein the to-be-transmitted data comprises at least one field; the one party acquires serialized data and data in a predetermined field, wherein the serialized data is obtained by serializing data in other fields of the to-be-transmitted data, the other fields are fields of the to-be-transmitted data except the predetermined field, the predetermined field is a field satisfying a predetermined condition, and the data in the predetermined field has not been subjected to serialization processing; and the one party sends the serialized data and the data in the predetermined field to another party of the remote procedure call. The application solves the problem that the RPC cannot meet the requirements due to the large serialization processing overhead in the RPC process, thereby saving the memory copy overhead in the serialization processing and improving the processing efficiency of the RPC.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data transmission, and more specifically, to a data processing method and system in remote procedure calls. Background Technology

[0002] Remote Procedure Call (RPC) is primarily used when applications are deployed on a cluster of multiple machines, requiring communication between them. It allows client applications (also called client programs) to invoke procedures in remote server applications (also called server programs) as if they were local procedures. To accommodate network transmission in RPC, RPC systems typically include serialization and deserialization operations. Serialization in an RPC system converts data structures into a byte stream format suitable for network transmission, while deserialization restores the serialized data to its original structure. For example, the client program in an RPC system serializes the user's requested data and sends it to the server program over the network. Upon receiving the network message, the server program deserializes the message to retrieve the requested data and performs the corresponding processing. After processing, the server program also serializes the returned message and sends it back to the client program, which then deserializes it to obtain the desired result.

[0003] During serialization, client and server programs typically use third-party serialization libraries for serialization and deserialization; these libraries are also known as message conversion libraries. Message conversion libraries need to allocate memory and perform memory copying during the serialization and deserialization process. For example, in the process of serializing data A, the serialized data (also called a byte stream) obtained by serializing data A needs to be allocated a memory buffer. Then, the serialized message is copied into this buffer, essentially storing the serialized byte stream in the buffer space. One of the client or server programs then sends the byte stream from the buffer space to the other. Since the buffer space is also located in memory, the entire serialization or deserialization process involves memory allocation and memory copying, which affects processing efficiency. The following example illustrates this point.

[0004] In this example, assume that the data transmitted from the client program to the server program includes eight fields, that is, the data structure of the data to be transmitted contains the data values ​​1, 2, 3, 4, 5, 6, 7, and 8, where the data lengths of values ​​4 and 6 exceed N bytes, and the data lengths of the other values ​​are less than N bytes.

[0005] Figure 1 It is based on a flowchart of data serialization processing in related technologies. Figure 1 The diagram illustrates memory allocation and copying during the serialization process of data to be transmitted. The following section will combine... Figure 1 This needs to be explained.

[0006] (1) The client program receives the data structure provided by the user that needs to be transmitted to the server program. Figure 1 In the process, the client program receives a data structure named RequestProto from the user input. The data structure contains fields value1, value2, value3, value4, value5, value6, value7, and value8. The data length of value4 and value6 exceeds N bytes, while the data length of the other fields is less than N bytes.

[0007] (2) The client program calls the information conversion library to serialize the application's data structure. The resulting byte stream is stored in one block of memory (i.e., ...). Figure 1 (The memory buffer shown in the image). It should be noted that... Figure 1 In the illustrated process, no special processing is performed on the field during serialization because the length of a single field exceeds N bytes. Figure 1 During serialization, only the overall length of the data structure needs to be known, and memory allocation can be performed based on that overall length.

[0008] That is, first, calculate the length of each field in the data structure, and then add the lengths of each field together to get the length of the data structure.

[0009] Allocate one memory buffer (also called a memory block) based on the total length of the data structure. The length of the memory block is the total buffer space required after serializing value1, value2, value3, value4, value5, value6, value7, and value8.

[0010] The fields value1, value2, value3, value4, value5, value6, value7, and value8 in the input data structure are serialized and saved to the buffer. During the serialization process, the byte streams obtained after serialization of each field need to be copied to this memory buffer respectively.

[0011] (3) The client program reads the byte stream from the memory buffer and sends it to the RPC server program. Through this step, the RPC system completes the transmission of the byte stream stored in the memory.

[0012] Figure 2 This is a flowchart illustrating the deserialization process of byte streams based on relevant technologies. Figure 2 This illustrates the memory allocation and copying involved in the deserialization process of a received byte stream. The following section combines this with... Figure 2 The server-side data receiving process is illustrated below.

[0013] (1) The RPC system server receives a byte stream, which is obtained and sent by the client program from a contiguous buffer. The server program also stores the received byte stream in a memory buffer (i.e., Figure 2 (The buffer shown).

[0014] (2) Call the information conversion library to deserialize the received data (i.e., byte stream).

[0015] The received byte stream is parsed to obtain all fields included in the received byte stream, and the length of each field is calculated. Figure 2 During the process, it was found that the received data contained the fields value1, value2, value3, value4, value5, value6, value7, and value8. Among them, the data length of value4 and value6 exceeded N bytes, while the data length of the other fields was less than N bytes.

[0016] Memory is allocated based on the total length obtained by adding up all fields. This memory is the memory allocated by the information conversion library for value1, value2, value3, value4, value5, value6, value7, and value8.

[0017] The process parses all fields stored in the buffer and deserializes each field one by one, saving them into value1, value2, value3, value4, value5, value6, value7, and value8. During the deserialization of each field, a memory copy is required; that is, the byte stream corresponding to that field is extracted from the buffer, deserialized, and then copied into the memory allocated for that field.

[0018] (3) The server program processes the deserialized data structure RequestProto.

[0019] In the above Figure 1 and Figure 2The process of sending data from the client program to the server program is shown in the figure. The process of sending data from the server program to the client program is similar and will not be described in detail here.

[0020] exist Figure 1 and Figure 2 In the serialization and deserialization methods shown, regardless of the length of each field in the user data structure, the information conversion library needs to allocate memory and perform memory copying. For example, Figure 1 and Figure 2 The data volume of fields 'value4' and 'value6' is relatively large. The information conversion library will still perform additional memory allocation and copying for these two fields within the library, which will result in a relatively large overhead for information conversion.

[0021] In the entire RPC process, serialization (including serialization and / or deserialization) accounts for a significant portion of the overhead. In scenarios with high latency requirements or strict resource consumption constraints, the overhead caused by serialization often prevents current RPC systems from meeting the requirements well. Summary of the Invention

[0022] This application provides a data processing method and system for remote procedure calls, which at least solves the problem that the high overhead of serialization processing in RPC processes causes RPC to fail to meet requirements.

[0023] According to one aspect of this application, a data processing method in a remote procedure call is provided, comprising: one party to the remote procedure call acquiring data to be transmitted, wherein the data to be transmitted includes at least one field; the party acquiring serialized data and data in a predetermined field, wherein the serialized data is obtained by serializing data in other fields of the data to be transmitted, the other fields being fields in the data to be transmitted other than the predetermined field, the predetermined field being a field that meets predetermined conditions, and the data in the predetermined field not being serialized; the party sending the serialized data and the data in the predetermined field to the other party to the remote procedure call, wherein, if the party is a client program, the other party is a server program; or, if the party is a server program, the other party is a client program.

[0024] According to another aspect of this application, a data processing method in a remote procedure call is also provided, comprising: acquiring data to be transmitted from one party in the remote procedure call; serializing data in other fields of the data to be transmitted to obtain serialized data, wherein the other fields are fields in the data to be transmitted other than predetermined fields, and the predetermined fields are fields that satisfy predetermined conditions; acquiring a first address value, wherein the first address value is the address value of the device where the party is located storing the data in the predetermined fields; providing the serialized data obtained after serializing the data in the other fields and the first address value to the party; wherein the first address value is used by the party to acquire the data in the predetermined fields, and the data in the predetermined fields and the serialized data are used to send to the other party in the remote procedure call; wherein the data in the predetermined fields has not been serialized, and the other party is a server program when the party is a client program; or, the other party is a client program when the party is a server program.

[0025] According to another aspect of this application, a data processing method in a remote procedure call is also provided, comprising: one party to the remote procedure call acquiring serialized data, wherein the serialized data is obtained by serializing a portion of data to be transmitted; the one party sending the serialized data and another portion of data to be transmitted to the other party to the remote procedure call, wherein the other portion of data is other data in the data to be transmitted besides the aforementioned portion of data, and the other portion of data has not been serialized; the other party receiving the serialized data and the other portion of data, and obtaining the portion of data obtained by deserializing the serialized data; and the other party obtaining the data to be transmitted based on the portion of data and the other portion of data.

[0026] According to another aspect of this application, a data processing system for remote procedure calls is also provided, comprising: one party to the remote procedure call and another party, wherein the first party includes: a first acquisition module and a sending module, wherein the first acquisition module is used to acquire serialized data, wherein the serialized data is obtained by serializing a portion of the data to be transmitted; the sending module is used to send the serialized data and another portion of the data to be transmitted to the other party to the remote procedure call, wherein the other portion of the data to be transmitted is other data besides the aforementioned portion of data, and the other portion of data has not been serialized; the other party includes a receiving module and a second acquisition module, wherein the receiving module is used to receive the serialized data and the other portion of data; the second acquisition module is used to acquire the data to be transmitted obtained by deserializing the serialized data to obtain the aforementioned portion of data, and based on the aforementioned portion of data and the other portion of data.

[0027] According to another aspect of this application, a readable storage medium is also provided, on which computer instructions are stored, wherein the computer instructions, when executed by a processor, implement the above-described method steps.

[0028] In this embodiment, a remote procedure call (RPC) is employed where one party acquires data to be transmitted, wherein the data to be transmitted includes at least one field; the party acquires serialized data and data from predetermined fields, wherein the serialized data is obtained by serializing data from other fields of the data to be transmitted, the other fields being fields in the data to be transmitted excluding the predetermined fields, the predetermined fields being fields that meet predetermined conditions, and the data in the predetermined fields not being serialized; the party then sends the serialized data and the data from the predetermined fields to the other party of the RPC. This application solves the problem of high serialization overhead in RPC processes causing RPC to fail to meet requirements, thereby saving the memory copy overhead in serialization processing and improving RPC processing efficiency. Attached Figure Description

[0029] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:

[0030] Figure 1 This is a flowchart illustrating the data serialization process based on relevant technologies;

[0031] Figure 2 This is a flowchart illustrating the deserialization process of byte streams based on relevant technologies;

[0032] Figure 3 This is a flowchart of a data processing method in a remote procedure call according to an embodiment of this application;

[0033] Figure 4 This is a flowchart illustrating the serialization and transmission of data according to an embodiment of this application;

[0034] Figure 5 This is a flowchart illustrating the serialization process performed using the information conversion library according to an embodiment of this application;

[0035] Figure 6 This is a flowchart illustrating the deserialization process performed using the information conversion library according to an embodiment of this application;

[0036] Figure 7 This is a schematic diagram illustrating data serialization processing according to an embodiment of this application; and,

[0037] Figure 8 This is a schematic diagram illustrating the deserialization process of a byte stream according to an embodiment of this application. Detailed Implementation

[0038] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0039] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0040] The following embodiments and implementation methods are applied to Remote Procedure Calls (RPCs), which involve two parties: a client program and a server program; or a server program and a client program. For the data transmission process in a RPC, the client program can serialize the data and send it to the server program, which then performs deserialization; alternatively, the server program can serialize the data and send it to the client program, which then performs deserialization. Therefore, in the following embodiments, one party represents the client program or server program that serializes the data, and the other party represents the client program or server program that performs deserialization of the received serialized data.

[0041] This embodiment provides a data processing method in remote procedure calls. Figure 3 This is a schematic diagram of a data processing method in a remote procedure call according to an embodiment of this application. The following describes... Figure 3The steps included in the process are illustrated below.

[0042] Step S302: The party making the remote procedure call obtains the serialized data, wherein the serialized data is obtained by serializing a portion of the data to be transmitted.

[0043] Step S304: The first party sends the serialized data and another part of the data to be transmitted to the other party of the remote procedure call, wherein the other part of the data to be transmitted is other data besides the first part of the data, and the other part of the data has not been serialized.

[0044] In this step, if one party is a client program, the other party is a server program; or, if one party is a server program, the other party is a client program.

[0045] In step S306, the other party receives the serialized data and the other part of the data, and obtains the part of the data by deserializing the serialized data.

[0046] Step S308: The other party obtains the data to be transmitted based on the partial data and the other partial data.

[0047] Through the above steps, a portion of the data to be transmitted is serialized, while the remaining portion is sent directly without serialization. This method, sending unserialized data, increases network transmission overhead compared to fully serializing all data before transmission. However, by avoiding the memory copying overhead inherent in serialization, the extra data is saved. In Remote Procedure Calls (RPCs), memory copying overhead has a far greater impact than network transmission overhead. Therefore, reducing memory copying overhead effectively reduces RPC processing latency. In short, these steps solve the problem of high serialization overhead causing RPC to fail to meet requirements, thereby saving memory copying overhead during serialization and improving RPC processing efficiency.

[0048] In the above steps, the data to be transmitted was divided into two parts, with one part undergoing serialization. There are many ways to divide the data to be transmitted into two parts, and the division can be based on the actual data structure of the data to be transmitted. Figure 1 and Figure 2 The data to be transmitted shown includes multiple fields, and the data transmitted in the remote procedure call is... Figure 1 and Figure 2The data structures shown are similar, and all basically include multiple fields. Therefore, in one alternative approach, one could consider selecting which portion of the data to be serialized and which portion not to be serialized, based on the fields in the data to be transmitted.

[0049] In this optional method, the data to be transmitted includes multiple fields, the other part of the data is data in a predetermined field among the multiple fields, and the other part of the data is data in other fields among the multiple fields. The predetermined field is a field that meets predetermined conditions, and the other fields are fields in the data to be transmitted other than the predetermined field.

[0050] exist Figure 3 The steps shown include serialization and deserialization. The following uses data to be transmitted, which includes multiple fields, as an example to explain the serialization process, data transmission, and deserialization process after receiving the serialized data.

[0051] Figure 4 This is a flowchart illustrating the serialization and transmission of data according to an embodiment of this application. The following describes... Figure 4 The steps for one party in a remote procedure call to perform serialization based on fields are explained, such as... Figure 4 As shown, the process includes the following steps.

[0052] In step S402, the party making the remote procedure call obtains the data to be transmitted, wherein the data to be transmitted includes at least one field.

[0053] In this step, the data to be transmitted has a specific data structure, which is represented by dividing the data into different fields. Therefore, in the following description, the data structure will also be referred to as including at least one field. The data to be transmitted in this step is sent to the other party via a remote procedure call.

[0054] Step S404, the party obtains serialized data and data in a predetermined field, wherein the serialized data is obtained by serializing the data in other fields of the data to be transmitted, the other fields are fields in the data to be transmitted other than the predetermined fields, the predetermined fields are fields that meet predetermined conditions, and the data in the predetermined fields has not been serialized.

[0055] In this step, the fields in the data to be transmitted are distinguished into predetermined fields and other fields. This distinction is based on predetermined conditions, which can be flexibly configured or selected according to the specific circumstances. Regardless of the content of the predetermined conditions, as long as the fields are distinguished and processed in the following steps, the memory copying overhead in serialization can be reduced.

[0056] In step S406, the party sends the serialized data and the data in the predetermined fields to the other party of the remote procedure call.

[0057] Through the above steps, multiple fields in the data to be transmitted are divided into predetermined fields and other fields. Data in the predetermined fields is sent directly to the other party without serialization, while data in the other fields is serialized before being sent. This method sends unserialized data, which increases network transmission overhead compared to serializing all fields before sending. However, the absence of serialization for the predetermined fields saves on the memory copying overhead of the serialization process. In Remote Procedure Calls (RPCs), memory copying overhead has a far greater impact on RPC than network transmission overhead. Therefore, reducing memory copying overhead can reduce the processing latency of RPCs.

[0058] In the above steps, the data to be transmitted is divided into serialized data and unserialized data and sent to the other party. For the multiple fields included in the data to be transmitted, the data in the predetermined fields is not serialized. Therefore, when transmitting data through the network layer, this data can be retrieved directly from the memory storing the data in the predetermined fields. The data in other fields, however, is serialized. During serialization, new memory needs to be allocated to store the serialized data, which adds an extra memory copy. Therefore, the processing of the data in the predetermined fields can be called zero-copy. For the party sending the data, it can directly retrieve the data in the predetermined fields from the address where the data in the predetermined fields is stored in its device, and then send it.

[0059] In this optional implementation, the process of one party obtaining serialized data and data in a predetermined field may include: the party obtaining a first address value, wherein the first address value is the address value of the device where the party is located storing the data in the predetermined field; the party obtaining the data in the predetermined field from the address pointed to by the first address value, and sending the serialized data and data in the predetermined field to the other party.

[0060] The serialization-related processing described above can be performed by the party making the remote procedure call, or it can be executed by an information conversion library. In one optional embodiment, an information conversion library is used. In this optional method, the party calls the information conversion library to perform serialization processing on the data to be transmitted; the party obtains the serialized data and a first address value provided by the information conversion library, wherein the information conversion library is used for serialization or deserialization processing; wherein the first address value is the address value of the device where the party is located that stores the data in the predetermined field; the party obtains the data of the predetermined field from the address pointed to by the first address value. The serialization operation performed by the information conversion library is described below. Figure 5 This is a flowchart illustrating the serialization process performed using the information conversion library according to embodiments of this application, such as... Figure 5 As shown, the operations performed by this information conversion library include the following steps.

[0061] Step S502: Obtain the data to be transmitted from one of the parties in the remote procedure call.

[0062] Step S504: Serialize the data in other fields of the data to be transmitted to obtain serialized data, wherein the other fields are fields in the data to be transmitted other than predetermined fields, and the predetermined fields are fields that meet predetermined conditions.

[0063] Step S506: Obtain a first address value, wherein the first address value is the address value of the device where the party is located storing the data in the predetermined field.

[0064] Step S508: The serialized data obtained by serializing the data in the other fields and the first address value are provided to the party; wherein, the first address value is used by the party to obtain the data in the predetermined field, and the data in the predetermined field and the serialized data are used to send to the other party of the remote procedure call; the data in the predetermined field has not been serialized.

[0065] Through the above steps, the information conversion library directly provides the first address value corresponding to the data in the predetermined field to the remote procedure caller during the serialization process. This means that the data in the predetermined field no longer needs to undergo serialization processing, thereby reducing memory copying during serialization and lowering the overhead of serialization. It should be noted that since the address value is directly provided for the data in the predetermined field, and memory copying of this data is no longer required, this process is also referred to as "zero-copy" in the following embodiments, and the information conversion library used to perform the above operation is also referred to as the "zero-copy information conversion library" in the following embodiments.

[0066] For the other party in the remote procedure call receiving data, it first saves the received serialized data and the data in the predetermined fields (the address where the data in the predetermined fields is saved in the other party's device is the second address value), and then performs deserialization processing. The other party in the remote call ultimately needs the data to be transmitted; therefore, it only needs to deserialize the other fields, and then directly obtain the data in the predetermined fields based on the second address value where the data in the predetermined fields is saved. That is, the data in the predetermined fields does not need to be deserialized, avoiding the memory copy overhead incurred during deserialization.

[0067] The other party in the remote procedure call will restore the data in the other fields and the data in the predetermined fields to the original data to be transmitted. As described above, this process may include the following steps: the other party obtains the data in the other fields and the data in the predetermined fields, wherein the data in the other fields is obtained by deserializing the serialized data. After obtaining the data in the other fields and the data in the predetermined fields, these two parts of data can be combined to obtain the original data to be transmitted.

[0068] The deserialization processing described above can be performed by the other party in a remote procedure call, or it can be executed by an information conversion library. In one optional implementation, an information conversion library is used. In this implementation, the other party calls the information conversion library to perform deserialization processing on the received data; the other party obtains data from other fields and a second address value provided by the information conversion library, wherein the second address value is the address value at which the device where the other party is located stores the data in the predetermined field; the other party obtains the data in the predetermined field based on the second address value. The deserialization operation performed by the information conversion library is described below. Figure 6 This is a flowchart illustrating the deserialization process performed using the information conversion library according to embodiments of this application, such as... Figure 6 As shown, the operations performed by this information conversion library include the following steps.

[0069] Step S602: Deserialize the serialized data and the data in the predetermined field received by the other party. The deserialization process includes: deserializing the serialized data to obtain the data in the other fields and obtaining a second address value; the data stored at the second address value is the data in the predetermined field that the other party saved after transmission over the network.

[0070] Step S604: Provide the data in the other fields and the second address value to the other party.

[0071] Through the above steps, the information conversion library only performs deserialization processing on the serialized data. For the data in the predetermined fields, the second address value is directly provided to the other party. That is, the information conversion library does not need to perform deserialization processing on the data in the predetermined fields, and therefore does not need to perform memory copying, reducing the overhead of memory copying.

[0072] The information conversion library can employ various methods for deserialization. In one optional method, the information conversion library distinguishes between serialized data and data in predetermined fields through memory partitioning. Specifically, in this optional method, deserialization processing based on the serialized data and data in predetermined fields received by the other party includes: partitioning the memory on the device where the other party resides, used to store the serialized data and the data in predetermined fields, to obtain memory for storing the serialized data and memory for storing the data in predetermined fields; allocating new memory based on the length of the serialized data, and storing the data in the other fields obtained after deserialization of the serialized data in the newly allocated memory; obtaining the address of the memory storing the data in predetermined fields, wherein the address of the memory storing the data in predetermined fields is the second address value.

[0073] In the above embodiments, the distinction between predetermined fields and other fields is involved. Since memory copying of large data fields during serialization and deserialization is quite costly, in an optional implementation, a predetermined field can be determined based on whether its length exceeds a threshold. That is, a predetermined field is a field whose data length exceeds a threshold.

[0074] The threshold can be an empirical value or it can be obtained through testing. For example, in a remote procedure call (RPC) system, the transmitted data includes eight fields with lengths ranging from len1 to len8. When the threshold is set to A1, three fields have a length exceeding A1; these three fields are considered predetermined fields. In this case, the latency of transmitting this data between the client and server programs is tested. Then, the threshold is set to A2; two fields have a length exceeding A2; these two fields are also considered predetermined fields. In this case, the latency of transmitting this data between the client and server programs is tested again. The threshold value is changed multiple times, and the transmission latency is recorded each time. The threshold corresponding to the optimal latency is selected as the threshold for the RPC system.

[0075] The above embodiments and implementation methods will be illustrated below with an example.

[0076] This example provides a zero-copy serialization and deserialization method for remote procedure call (RPC) systems. By implementing a zero-copy information conversion library and applying it to RPC, the latency of RPC is reduced. The main steps involved in this example of RPC based on the zero-copy information conversion library are as follows: The client program calls the zero-copy information conversion library to serialize the application's data structures. The serialization process involves the information conversion library allocating memory internally, converting smaller data items in the data structures into byte streams and saving them to the allocated memory (a memory copy occurs). For larger data items, the address value corresponding to that data in the application's data structure is used directly. Therefore, the information conversion library in this example provides two parts: one part stores the smaller data items in the application's data structures, and the other part stores the addresses of the larger data items. Then, the client program uses the RPC system to transmit the data to be transmitted, handing it over to the server program for processing. After receiving and saving the data, the server program calls the zero-copy information conversion library to deserialize the received byte stream data. The deserialization process is as follows: the information conversion library parses the received byte stream data, converts smaller data bytes into corresponding data structures (which involves memory copying), and directly provides the memory address of the larger data bytes to the server program. Then, the server program processes the received data and sends the results back to the client program following the same steps.

[0077] In order to Figure 1 and Figure 2 For comparison, in this example, it is assumed that the data transmitted from the client program to the server program includes eight fields, that is, the data structure of the data to be transmitted contains data values1,2,3,4,5,6,7, and8. Among them, the data length of values4 and6 exceeds N bytes, and the data length of the other values ​​is less than N bytes. It should be noted that N bytes is the threshold, that is, values4 and6 are the predetermined bytes described in the above embodiment, and values1,2,3,5,7, and8 are the other bytes described in the above embodiment.

[0078] Figure 7 This is a schematic diagram illustrating data serialization processing according to an embodiment of this application. The following is in conjunction with... Figure 7 The detailed data sending process of the client program is explained.

[0079] (1) The client program receives user-input data, which needs to be transmitted to the server program. This data has a data structure with multiple fields, and therefore will be referred to as the data structure below. In this example, assume that the data structure input by the client user is named RequestProto. This data structure contains fields value1, value2, value3, value4, value5, value6, value7, and value8. The data length of value4 and value6 exceeds N bytes, while the data length of the other fields is less than N bytes. It should be noted that N is a threshold used to distinguish the size of the byte data.

[0080] (2) Call the zero-copy information conversion library to serialize the data structure from the client program. After serialization, there are 5 memory blocks, namely buffer1, the data address of value4, buffer2, the data address of value6, and buffer3. The operations involved in (2) are explained in detail below.

[0081] First, let's count the data length of each field in this data structure. The results show that the data length of value4 and value6 exceeds N bytes, while the data length of other fields is less than N bytes.

[0082] Allocate 3 memory blocks (assuming the 3 memory blocks are buffer1, buffer2, and buffer3), with lengths len1, len2, and len3 respectively. Here, len1 is the total buffer space required after serializing value1, value2, and value3; len2 is the buffer space required after serializing value5; and len3 is the total buffer space required after serializing value7 and value8.

[0083] Serialize the fields value1, value2, and value3 in the RequestProto data structure, and save the serialized byte stream to buffer1.

[0084] The data in value4 is not serialized; instead, the address of the field is directly retained.

[0085] Serialize the value5 field and save it to buffer2.

[0086] The data in value6 is not serialized; instead, the address of the field is directly retained.

[0087] Serialize fields value7 and value8 and save them to buffer3.

[0088] (3) Use the RPC system to transfer the contents of these 5 memory blocks. In this step, the client program in the RPC system uses serialized messages to transfer the contents of these 5 memory blocks. Since the data in the value4 and value6 fields has not been serialized, the client program sends the data in the value4 and value6 fields directly to the server program.

[0089] Figure 8 This is a schematic diagram illustrating the deserialization process of a byte stream according to an embodiment of this application. The following is in conjunction with... Figure 8 The detailed process of receiving data on the server side is explained.

[0090] (1) When the RPC system server program receives data, it can save the received data in a continuous buffer.

[0091] (2) Call the zero-copy information conversion library to deserialize the received data. The deserialization operation performed by the zero-copy information conversion library is explained below.

[0092] First, we parse all the fields contained in the received data and count the length of each field. We found that the received data contains the fields value1, value2, value3, value4, value5, value6, value7, and value8. The data length of value4 and value6 exceeds N bytes, while the data length of the other fields is less than N bytes.

[0093] The server typically stores the received data in a contiguous block of memory (buffer). In this step, the received contiguous buffer can be divided into five memory blocks, with lengths of N1, N2, N3, N4, and N5 bytes respectively. Specifically, the serialized data corresponding to values ​​1, 2, and 3 are divided into the first memory block; the data in value 4 bytes are divided into the second memory block; the serialized data corresponding to value 5 bytes are divided into the third memory block; the data in value 6 bytes are divided into the fourth memory block; and the serialized data corresponding to values ​​7 and 8 bytes are divided into the fifth memory block.

[0094] Allocate memory again for value1, value2, and value3 (this newly allocated memory is used to store the data obtained after deserialization), and deserialize the first block of memory after the buffer is split into the memory corresponding to value1, value2, and value3.

[0095] The starting address of the second memory block after the buffer is split is retained and assigned to value4.

[0096] Allocate memory for value5, and deserialize the third block of memory after splitting the buffer into value5.

[0097] The starting address of the fourth memory block after the buffer is split is retained and assigned to value6.

[0098] Allocate memory again for value7 and value8 (this newly allocated memory is used to store the data obtained after deserialization), and deserialize the fifth block of memory after the buffer is split into the memory corresponding to value7 and value8.

[0099] (3) The server program obtains the deserialized data from the zero-copy information conversion library. The server program can also process the data in the two memory blocks by the address of the memory block where value4 and value6 are located. Therefore, in this step, the server program completes the processing of the deserialized data structure RequestProto and the data in the two memory blocks.

[0100] In this example, during the serialization and deserialization of the user's data structure, different processing is applied to the fields based on a set threshold N. Fields longer than N bytes undergo zero-copy serialization and deserialization to save additional memory allocation and copying. Fields shorter than N bytes are processed similarly to the current information conversion library, allocating and copying memory for these fields. This approach is necessary because using zero-copy for every field would require a large number of memory blocks for the network transmission module. A single client request would necessitate multiple data transfers, significantly increasing network overhead. Therefore, zero-copy is only used for fields with large amounts of data. The example above involves setting a threshold N to differentiate data size. This threshold N can be adjusted based on hardware performance, referring to the hardware used in both the client and server programs.

[0101] Through the above embodiments, for fields with large amounts of data in the user data structure, memory copying is avoided. Instead, the data address corresponding to the field is directly retained, and the data is retrieved directly using the corresponding data address during network transmission, thus saving the overhead of memory copying. Applying the information conversion library in the above embodiments to a remote procedure call system significantly reduces the overall remote procedure call latency, while also saving system memory and CPU overhead.

[0102] In this embodiment, an electronic device is provided, including a memory and a processor. The memory stores a computer program, and the processor is configured to run the computer program to perform the methods described in the above embodiments.

[0103] The aforementioned program can run on a processor or be stored in memory (or a computer-readable medium). Computer-readable media includes both permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0104] These computer programs may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes can be implemented using different modules, and different steps can be implemented using different modules.

[0105] This embodiment also provides a data processing system for remote procedure calls, including: one party and the other party in the remote procedure call, wherein the one party includes: a first acquisition module and a sending module, wherein the first acquisition module is used to acquire serialized data, wherein the serialized data is obtained by serializing a portion of the data to be transmitted; the sending module is used to send the serialized data and another portion of the data to be transmitted to the other party in the remote procedure call, wherein the other portion of the data is other data in the data to be transmitted besides the aforementioned portion of data, and the other portion of data has not been serialized; the other party includes a receiving module and a second acquisition module, wherein the receiving module is used to receive the serialized data and the other portion of data; the second acquisition module is used to acquire the data to be transmitted obtained by deserializing the serialized data to obtain the aforementioned portion of data, and based on the aforementioned portion of data and the other portion of data.

[0106] This system is designed to implement the functions of the methods in the above embodiments. Each module in the system corresponds to a step in the method, which has already been described in the method and will not be repeated here.

[0107] Optionally, an information conversion library can also be used in this system. This library is used to serialize data from one party and to deserialize serialized data from the other party. The steps performed by this information conversion library have been described in the above embodiments and will not be repeated here.

[0108] Through the above embodiments, a zero-copy information conversion library for remote procedure calls is proposed. By setting a threshold N, the amount of data fields that need to be zero-copy serialized and / or deserialized is controlled, thereby improving the serialization and deserialization performance in remote procedure calls, and thus improving the overall performance of remote procedure calls.

[0109] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A data processing method in a remote procedure call, comprising: One party in a remote procedure call obtains data to be transmitted, wherein the data to be transmitted includes at least one field; The party obtains serialized data and data in predetermined fields, wherein the serialized data is obtained by serializing the data in other fields of the data to be transmitted, the other fields being fields in the data to be transmitted other than predetermined fields, the predetermined fields being fields that meet predetermined conditions, and the data in the predetermined fields not being serialized; The first party sends the serialized data and the data in the predetermined fields to the other party of the remote procedure call, wherein the other party is a server program if the first party is a client program; or, the other party is a client program if the first party is a server program. The party that obtains the serialized data and the data in the predetermined fields includes: The first party calls the information conversion library to perform serialization processing on the process to be transmitted; The party obtains the serialized data and the first address value provided by the information conversion library, wherein the information conversion library is used for serialization processing or deserialization processing; wherein the first address value is the address value of the device where the party is located that stores the data in the predetermined field; The party obtains the data of the predetermined field from the address pointed to by the first address value.

2. The method according to claim 1, wherein, After one party sends the serialized data and the data in the predetermined fields to the other party of the remote procedure call, the method further includes: The other party obtains data from the other fields and data from the predetermined fields, wherein the data in the other fields is obtained by deserializing the serialized data.

3. The method according to claim 2, wherein, The other party obtaining the data in the other fields and the data in the predetermined fields includes: The other party calls an information conversion library to deserialize the received data; The other party obtains data from the other fields and the second address value provided by the information conversion library, wherein the data stored in the second address value is the data in the predetermined field that the other party saves after network transmission; The other party obtains the data in the predetermined field based on the second address value.

4. The method according to any one of claims 1 to 3, wherein, The predetermined field is a field in which the length of the data exceeds a threshold.

5. A data processing method in a remote procedure call, comprising: Retrieve the data to be transmitted from one of the parties in a remote procedure call; Serialized data is obtained by serializing the data in other fields of the data to be transmitted, wherein the other fields are fields in the data to be transmitted other than predetermined fields, and the predetermined fields are fields that meet predetermined conditions; Obtain a first address value, wherein the first address value is the address value of the device where the party is located storing the data in the predetermined field; The serialized data obtained by serializing the data in the other fields and the first address value are provided to the first party; wherein, the first address value is used by the first party to obtain the data in the predetermined field, and the data in the predetermined field and the serialized data are used to send to the other party of the remote procedure call; the data in the predetermined field has not been serialized, and if the first party is a client program, the other party is a server program; or, if the first party is a server program, the other party is a client program; The serialization process for other fields in the data to be transmitted includes: The information conversion library is invoked to serialize the data to be transmitted, and the information conversion library generates the serialized data and determines the first address value; The information conversion library is used for serialization or deserialization processing.

6. The method according to claim 5, wherein, Also includes: The serialized data and the data in the predetermined fields received by the other party are deserialized. The deserialization process includes: deserializing the serialized data to obtain the data in the other fields and obtaining a second address value; wherein the data stored at the second address value is the data in the predetermined fields that the other party has saved after transmission over the network. The data in the other fields and the second address value are provided to the other party, wherein the second address value is used by the other party to retrieve the data in the predetermined fields.

7. The method according to claim 6, wherein, Deserialization processing based on the serialized data received by the other party and the data in the predetermined field includes: The memory used by the device where the other party is located to store the serialized data and the data in the predetermined field is divided into the memory for storing the serialized data and the memory for storing the data in the predetermined field; Allocate new memory based on the length of the serialized data, and store the data in the other fields obtained after deserializing the serialized data in the newly allocated memory; Obtain the memory address where the data in the predetermined field is stored, wherein the memory address where the data in the predetermined field is stored is the second address value.

8. The method according to any one of claims 5 to 7, wherein, The predetermined field is a field in which the length of the data exceeds a threshold.

9. A data processing method in a remote procedure call, comprising: One party in a remote procedure call obtains the serialized data, wherein the serialized data is obtained by serializing a portion of the data to be transmitted. One party sends the serialized data and another part of the data to be transmitted to the other party of the remote procedure call, wherein the other part of the data to be transmitted is other data besides the serialized data, and the other part of the data has not been serialized; The other party receives the serialized data and the other part of the data, and obtains the part of the data by deserializing the serialized data; The data to be transmitted is obtained by the other party based on the partial data and the other partial data; Wherein, the acquisition of the serialized data by one party and the other part of the data includes: The party invokes an information conversion library to serialize the data to be transmitted. The party obtains the serialized data and the first address value provided by the information conversion library, wherein the information conversion library is used for serialization or deserialization processing; the first address value is the address value of the device where the party is located that stores the other part of the data; The first party obtains the other part of the data from the address pointed to by the first address value.

10. A data processing system for remote procedure calls, comprising: The remote procedure call involves one party and the other party, where the other party is a server program if the first party is a client program. Alternatively, if one party is a server program, the other party is a client program, wherein... The first party includes: a first acquisition module and a sending module, wherein the first acquisition module is used to acquire serialized data, wherein the serialized data is obtained by serializing a portion of the data to be transmitted; the sending module is used to send the serialized data and another portion of the data to be transmitted to the other party of the remote procedure call, wherein the other portion of the data is other data in the data to be transmitted besides the aforementioned portion of data, and the other portion of the data has not been serialized. The other party includes a receiving module and a second acquiring module, wherein the receiving module is used to receive the serialized data and the other part of the data; the second acquiring module is used to acquire the data to be transmitted obtained by deserializing the serialized data to obtain the other part of the data and the other part of the data; It also includes: an information conversion library for performing serialization and / or deserialization processing; wherein the information conversion library is used to perform the method of any one of claims 5 to 8 to perform the serialization and / or deserialization processing.

11. The system according to claim 10, wherein, The data to be transmitted includes multiple fields. The other part of the data is data in a predetermined field among the multiple fields. The other part of the data is data in other fields among the multiple fields. The predetermined field is a field that meets predetermined conditions. The other fields are fields in the data to be transmitted other than the predetermined field. The predetermined field is a field whose data length exceeds a threshold.

12. A readable storage medium having computer instructions stored thereon, wherein, When executed by a processor, the computer instructions implement the method steps of any one of claims 1 to 4, or the method steps of any one of claims 5 to 8.