Message transmission method and device, equipment and storage medium
By writing message feature information of notification messages into the first shared memory of the autonomous driving system, data transmission across processes is realized, and the problem of inefficient communication between processes is solved, the message transmission delay is reduced and the system performance is improved.
Patent Information
- Application Number
- CN202411660780.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-11-19
AI Technical Summary
In autonomous driving systems, with the increase of sensor data, the efficiency of inter-process communication becomes one of the key factors in system performance. The prior art has inefficiency and delay problems in inter-process message transmission.
By writing message characteristic information of notification messages in the first shared memory, the first process and the second process can transmit message content across processes, avoiding the serialization and deserialization process, and directly using the storage address for data transmission.
It realizes cross-process data transmission, effectively improves the efficiency of inter-process communication, reduces message transmission delay, saves computing resources, ensures the normal operation of other business modules, and improves the overall system performance.
Smart Images

Figure CN119621368A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to technical fields such as autonomous driving, assisted driving, automatic parking, and intelligent transportation. Background Art
[0002] With the continuous development of autonomous driving systems, the specifications of the sensors used are getting higher and higher, resulting in the increasing size and complexity of sensor data. Therefore, distributed autonomous driving systems have emerged. Distributed autonomous driving systems provide standardized communication interfaces so that multiple processes can run and work together on different hosts (or different cores of the host). In collaborative engineering, interprocess communication (IPC) is involved, that is, message transmission between different processes. At this time, the efficiency of interprocess communication becomes one of the key factors in system performance. Summary of the invention
[0003] The present disclosure provides a message transmission method, apparatus, device and storage medium.
[0004] According to one aspect of the present disclosure, there is provided a message transmission method, comprising:
[0005] Writing the message feature information of the notification message into the first shared memory through the first process; wherein the first shared memory is a memory space accessible to both the first process and the second process that need to perform message transmission;
[0006] When the second process needs to obtain the notification message, the message characteristic information of the notification message is found from the first shared memory, so as to enable the second process to obtain the message content of the notification message by using the message characteristic information.
[0007] According to another aspect of the present disclosure, there is provided a message transmission device, comprising:
[0008] An information writing unit, used to write the message feature information of the notification message into a first shared memory through a first process; wherein the first shared memory is a memory space accessible to both the first process and the second process that need to perform message transmission;
[0009] The information reading unit is used to find the message characteristic information of the notification message from the first shared memory when the second process needs to obtain the notification message, so as to use the message characteristic information to enable the second process to obtain the message content of the notification message.
[0010] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0011] at least one processor; and
[0012] a memory communicatively connected to the at least one processor; wherein,
[0013] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any method in the embodiments of the present disclosure.
[0014] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any method according to the embodiments of the present disclosure.
[0015] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements any method according to the embodiments of the present disclosure when executed by a processor.
[0016] In this way, the disclosed scheme can first write the message characteristic information of the notification message into the first shared memory through the first process, and then when the second process needs to obtain the notification message, find the message characteristic information of the notification message to be obtained from the first shared memory, so that the second process can use the message characteristic information of the notification message to obtain the message content of the notification message, thereby realizing cross-process data transmission. The above process provides strong support for effectively improving the communication efficiency between processes and effectively reducing the message transmission delay.
[0017] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0019] Figure 1(a) to Figure 1(c) This is a schematic diagram of the cross-process message transmission framework in the autonomous driving system;
[0020] Figure 1(d) is a schematic diagram of the serialization and deserialization scenarios during cross-process message transmission;
[0021] Figure 2 is a schematic flow chart 1 of a message transmission method according to an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of an interactive scenario for implementing message transmission between different processes using a first shared memory according to an embodiment of the present application;
[0023] Figure 4This is a schematic flow chart of a message transmission method according to an embodiment of the present application. Figure 2 ;
[0024] FIG. 5( a ) is a schematic diagram of an interactive scenario of using a first shared memory to implement message transmission between different processes according to an embodiment of the present application. Figure 2 ;
[0025] FIG. 5( b ) is a schematic diagram of an interactive scenario of using a first shared memory to implement message transmission between different processes according to an embodiment of the present application. Figure 3 ;
[0026] FIG6(a) is a schematic flow chart of a message transmission method according to an embodiment of the present application. Figure 3 ;
[0027] FIG6( b ) is a schematic diagram of an interactive scenario for implementing message transmission between different processes using a first shared memory and a second shared memory according to an embodiment of the present application;
[0028] Figure 6(c) to Figure 6(e) It is a schematic diagram of a specific application scenario of the mapping relationship between the shared memory space and the pointer according to an embodiment of the present application;
[0029] FIG. 7( a) is a schematic flow chart of a message transmission method according to an embodiment of the present application. Figure 4 ;
[0030] FIG. 7( b ) is a schematic diagram of an interactive scenario of using a first shared memory to implement message transmission between different processes according to an embodiment of the present application. Figure 4 ;
[0031] Figure 8 This is a schematic diagram of an application scenario of a message transmission method in an example according to an embodiment of the present application;
[0032] Fig. 9 is a structural diagram of a message transmission device according to an embodiment of the present application;
[0033] Fig.10 It is a block diagram of an electronic device used to implement the message transmission method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0034] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0035] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The term "at least one" in this article means any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C. The terms "first" and "second" in this article refer to multiple similar technical terms and distinguish them. They do not mean to limit the order or to limit them to only two. For example, the first feature and the second feature refer to two types / two features. The first feature can be one or more, and the second feature can also be one or more.
[0036] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the specific embodiments below. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present disclosure.
[0037] The following is a description of the related technologies of the embodiments of the present disclosure. The following related technologies are optional solutions that can be arbitrarily combined with the technical solutions of the embodiments of the present disclosure, and they all belong to the protection scope of the embodiments of the present disclosure.
[0038] FIG1(a) is a cross-process message transmission framework in an autonomous driving system. As shown in FIG1(a), in the operating framework of an autonomous driving system, such as the concept of cybersecurity in autonomous vehicles, the communication between a first process (a process for writing data, which may be denoted as a Writer) and a second process (a process for reading data, which may be denoted as a Reader) is accomplished through a channel, which allows processes to exchange data by means of message passing, thereby achieving cross-process message passing.
[0039] Here, it should be noted that, in one example, a process described in the disclosed solution may be run in a processing node (e.g., a central processing unit (CPU) server) in a distributed autonomous driving system, for example, the first process and the second process described above may be run in different processing nodes. Alternatively, in another example, a process may be run in a processing core (i.e., the smallest processing unit for running a process) in a processing node, for example, the first process and the second process described above may be run in different processing cores in the same processing node.
[0040] Furthermore, in one example, the communication process between processes is mainly completed by a sending component (transmitter) for sending data, a routing component (dispatcher) for data distribution, and a receiving component (receiver) for receiving data. For example, as shown in FIG1(b), the first process corresponds to a first sending component and a first receiving component, and the second process corresponds to a second sending component and a second receiving component; here, the first routing component is connected to the first receiving component of the first process, and is used to distribute data for the first process; correspondingly, the second routing component is connected to the second receiving component of the second process, and is used to distribute data for the second process.
[0041] Furthermore, when the first process needs to transmit data to the second process, the first process sends the data through the first transmission path through the first sending component. At this time, after the second routing component in the first transmission path receives the data, it distributes it to the second process, for example, it transmits it to the space of the second process through the second receiving component in the second process. Similarly, when the second process needs to transmit data to the first process, the second process sends the data through the second transmission path through the second sending component. At this time, after the first routing component in the second transmission path receives the data, it distributes it to the first process, for example, it transmits it to the space of the first process through the first receiving component in the first process. In this way, the communication between the first process and the second process is completed.
[0042] Here, in one example, in the operating framework of the autonomous driving system, inter-process communication can be achieved through shared memory (SHM) and real-time publish-subscribe (RTPS). For example, in the SHM method, multiple processes are allowed to access the same memory area to quickly transmit large amounts of data, such as sensor data or map information, through shared memory. In the RTPS method, processes in different computing nodes (also called processing nodes) can be allowed to transmit data.
[0043] It is understandable that, in practical applications, a hybrid method of the above two methods may also be adopted, and the disclosed solution does not limit the specific transmission method.
[0044] Further, FIG1(c) is a schematic diagram of using shared memory for inter-process communication. As shown in FIG1(c), for a first process (e.g., writer), it can use its own first sending component to serialize the notification message in its own space, and copy the serialized notification message to the first shared memory, for example, copy the index information of the notification message to the memory blocks in the first shared memory, and copy the message content of the serialized notification message to the memory buffer in the first shared memory. Correspondingly, the first sending component can also write the index information of the serialized notification message to the third shared memory; here, the third shared memory can specifically store a readable index list, and the readable index list stores the index information of the message that needs to be transmitted between different processes.
[0045] For the second process, the second routing component (dispatcher) can be used to monitor the third shared memory to determine whether there is a notification message that needs to be sent to the second process; if so, the index information of the notification message to be obtained is parsed by the second routing component, and based on the parsed index information, the message content of the notification message matching the parsed index information is copied from the first shared memory, and after deserialization, it is transmitted to the space of the second process via the second receiving component (receiver) in the second process.
[0046] Here, it should be noted that the first shared memory can mainly include three areas, which can be respectively referred to as the first area, the second area and the third area, wherein the first area can be mainly used to store status information, for example, to store the status information of each memory buffer, such as whether it is currently being written, whether it is currently being read, the count of current references by the writer, and the count of current references by the reader; the second area mainly includes multiple memory blocks for storing index information; the third area mainly includes multiple memory buffers for storing the message content of the message to be transmitted, such as serialized message content.
[0047] Further, FIG1(d) is a schematic diagram of notification message serialization; as shown in FIG1(d), the notification message is Struct structure data, for example, it may include structured uint64_t idx_, Struct2*ptr_ and String st_, wherein the above data may further be structured data, for example, Struct2*ptr includes uint64_t a_ and uint64_t b_, String st_ includes char*buf_ and size_t size_; for the above Struct structure data, serialization may refer to converting each member data in the Struct structure data into a byte stream, and flattening it in the form of a sequence to become a continuous byte stream for easy transmission. Correspondingly, deserialization may refer to restoring the above serialized byte stream to restore it to the original structure, such as restoring it to the Struct structure.
[0048] According to the above process, in inter-process communication, when a notification message is passed from one process to another, it needs to go through at least two data copies, and it also involves data serialization and deserialization; for complex types of notification messages, serialization and deserialization need to convert each field contained in the notification message into a byte stream. These operations undoubtedly consume additional computing resources, increase the performance burden of the CPU, increase the consumption of memory bandwidth, and at the same time, increase the delay in message transmission, thereby affecting the normal message processing time of other modules. Moreover, the serialized data occupies more storage space, which further affects the overall operation of the system to a certain extent.
[0049] Based on this, the disclosed scheme provides a message transmission method to improve the transmission efficiency of inter-process communication, thereby reducing the delay in message transmission, and reducing the computing resources required for inter-process communication, ensuring the normal operation of other business modules, thereby improving the performance of the overall system.
[0050] Specifically, Figure 2 1 is a schematic flow chart of a message transmission method according to an embodiment of the present application. The method can be optionally applied to electronic devices, such as personal computers, servers, server clusters and other electronic devices.
[0051] Further, the method includes at least part of the following contents. Figure 2 As shown, including:
[0052] Step S201: writing the message feature information of the notification message into the first shared memory through a first process (also referred to as a sender process, or a writing process, for example, may be recorded as a writer).
[0053] Here, the first shared memory is a memory space that can be accessed by both the first process and the second process (also referred to as a receiving process, or a reading process, for example, recorded as a reader) that need to perform message transmission.
[0054] Furthermore, in one example, the memory space in the first shared memory is a continuous memory space, which facilitates improving the writing and reading efficiency of the process.
[0055] Step S202: when the second process needs to obtain the notification message, the message characteristic information of the notification message is searched from the first shared memory, so as to enable the second process to obtain the message content of the notification message by using the message characteristic information.
[0056] In this way, the disclosed scheme can first write the message characteristic information of the notification message into the first shared memory through the first process, and then when the second process needs to obtain the notification message, find the message characteristic information of the notification message to be obtained from the first shared memory, so that the second process can use the message characteristic information of the notification message to obtain the message content of the notification message, thereby realizing cross-process data transmission. The above process provides strong support for effectively improving the communication efficiency between processes and effectively reducing the message transmission delay.
[0057] Further, in a specific example, the above-mentioned writing the message characteristic information of the notification message into the first shared memory through the first process (for example, step S201) may specifically include: writing at least one of the following of the notification message into the first shared memory through the first process: index information of the notification message, storage address of the notification message. In this way, it provides strong support for subsequently reducing the computing resources required for data transmission and thus improving the communication efficiency between processes.
[0058] For example, if Figure 3 As shown, the first process uses its own first sending component to write the index information and storage address of the notification message to be transmitted into the first shared memory; accordingly, when the second process needs to obtain the notification message, the second routing component responsible for data distribution of the second process can obtain the storage address of the notification message that the second process needs to obtain from the first shared memory, so that the second process can obtain the message content of the notification message according to the storage address of the notification message. In this way, inter-process message communication is realized, and the above process does not require serialization and deserialization processing, which effectively improves the data transmission efficiency and saves the computing resources required for inter-process communication.
[0059] Figure 4 This is a schematic flow chart of a message transmission method according to an embodiment of the present application. Figure 2The method can optionally be applied to electronic devices, such as personal computers, servers, server clusters, and other electronic devices. It can be understood that the above FIG. 1 to FIG. Figure 3 The relevant contents of the method shown can also be applied to this example, and the relevant contents will not be described in detail in this example.
[0060] Further, the method includes at least part of the following contents. Specifically, Figure 4 As shown, including:
[0061] Step S401: when the first process needs to transmit a notification message, the message feature information of the notification message is written into the first shared memory through the first process.
[0062] Here, the first shared memory is a memory space that can be accessed by both the first process and the second process that need to perform message transmission.
[0063] For example, in a specific example, the above-mentioned writing the message characteristic information of the notification message into the first shared memory through the first process may specifically include: serializing the storage address of the notification message through the first process and writing it into the first shared memory, for example, serializing the storage address of the notification message through the first process and writing it into the memory buffer in the first shared memory. In this way, the storage address is quickly transmitted between the first shared memory, the first process, and the second process, thereby improving communication efficiency.
[0064] It should be noted that the disclosed solution does not need to serialize the complete message content, but serializes the storage address. It can be understood that compared with the message content, the storage address has a small amount of data and a simple data structure. Therefore, compared with directly serializing the message content of the notification message, the disclosed solution effectively improves the data processing efficiency and saves the computing resources required for inter-process communication, thereby providing strong support for improving the efficiency of inter-process communication.
[0065] In addition, it should be pointed out that, in this example, since the storage address of the notification message stored in the first shared memory is serialized, after finding the serialized storage address of the notification message from the first shared memory, the serialized storage address needs to be deserialized to restore the storage address to the original structure (also referred to as the deserialized storage address), thereby facilitating the subsequent use of the deserialized storage address to enable the second process to obtain the message content of the notification message.
[0066] Furthermore, in another specific example, when the first process needs to transmit a notification message, the index information of the notification message can also be written into the first shared memory through the first process, such as writing the index information of the notification message into a memory block in the first shared memory. In this way, it is convenient to quickly find the storage address later, thereby providing strong support for improving communication efficiency later.
[0067] Step S402: when the second process needs to obtain the notification message, the message characteristic information of the notification message is searched from the first shared memory, so as to use the message characteristic information to enable the second process to obtain the message content of the notification message.
[0068] In this way, when the notification message needs to be transmitted, the disclosed solution writes the message characteristic information of the notification message into the first shared memory, and then when the second process needs to obtain the notification message, the message characteristic information is used to enable the second process to receive the message content of the notification message. In this way, message transmission between processes is realized. At the same time, it also provides strong support for effectively improving the efficiency of data transmission and reducing message transmission delay.
[0069] For example, as shown in Figure 5(a), when the first process needs to transmit a notification message, the first process can use its own first sending component to write the index information of the notification message into the memory block of the first shared memory, and at the same time, serialize the storage address of the notification message and write it into the memory buffer of the first shared memory.
[0070] Further, as shown in Figure 5(b), when the second process needs to obtain the notification message, the second routing component is used to find the serialized storage address of the notification message from the first shared memory, and after deserializing the serialized storage address, the deserialized storage address is sent to the second process, for example, to the second receiving component of the second process, so that the second process can obtain the message content of the notification message using the second receiving component.
[0071] Here, it should be noted that, in one example, the first shared memory can mainly include three areas, which can be respectively the first area, the second area and the third area; wherein, as shown in FIG5(a) and FIG5(b), the first area can be mainly used to store status information, for example, to store the status information of each memory buffer, such as whether it is currently being written, whether it is currently being read, the count of the current writer's references, and the count of the current reader's references; the second area mainly includes multiple memory blocks for storing index information; the third area mainly includes multiple memory buffers for storing the storage addresses of the messages to be transmitted, such as storing the serialized storage addresses.
[0072] Furthermore, in an example, the state information of the first shared memory may also indicate a starting position of the first shared memory.
[0073] FIG6(a) is a schematic flow chart of a message transmission method according to an embodiment of the present application. Figure 3 The method may optionally be applied to electronic devices, such as personal computers, servers, server clusters, and other electronic devices. It is understandable that the relevant contents of the method shown in Figures 1 to 5 above may also be applied to this example, and the relevant contents will not be repeated in this example.
[0074] Further, the method includes at least part of the following contents. Specifically, as shown in FIG6(a), it includes:
[0075] Step S601: applying for at least one memory buffer from a second shared memory through a first process.
[0076] Here, the at least one memory buffer is used to store at least the message content of the notification message that the first process needs to send.
[0077] Furthermore, in this example, the second shared memory is a memory space that can be accessed by both the first process and the second process that need to perform message transmission.
[0078] That is to say, in this example, before the first process generates a notification message, it can apply in advance to the second shared memory for at least one memory buffer that can be used to store the message content of the notification message. In this way, after the notification message is generated, the message content of the notification message can be written to the second shared memory in a timely manner through the first process without storing it in the first process. In this way, the serialization and deserialization processes are effectively avoided. At the same time, it also provides strong support for the subsequent second process to quickly obtain the message content of the notification message from the memory buffer applied for by the first process, thereby effectively reducing the time required for the entire communication process and improving the communication efficiency between processes.
[0079] Step S602: when the first process generates the notification message, the message content of the notification message is written into the at least one memory buffer through the first process.
[0080] That is to say, in this example, after the first process generates the notification message, the message content of the notification message, for example, message data with a specific message format, can be directly written into the second shared memory, for example, written into the memory buffer area in the pre-applied second shared memory, without storing the notification message in the first process. In this way, the serialization and deserialization processes are effectively avoided, and the additional computing resources consumed due to serialization and deserialization are avoided. At the same time, the occupied storage space is reduced, thereby reducing the overall burden of the system, providing strong support for effectively saving the time required for the entire communication process and improving the communication efficiency between processes.
[0081] Step S603: when the first process needs to transmit the notification message, the storage address of the notification message is serialized by the first process and then written into the first shared memory.
[0082] Here, the first shared memory is a memory space that can be accessed by both the first process and the second process that need to perform message transmission.
[0083] Here, in an example, while the storage address of the notification message is serialized and written into the first shared memory by the first process, the index information of the notification message can also be written into the first shared memory by the first process.
[0084] Furthermore, in a specific example, the storage address of the notification message mentioned above at least includes: a memory address of the notification message in the second shared memory.
[0085] Furthermore, in another specific example, the memory address of the notification message in the second shared memory includes at least: a pointer of the notification message; here, the pointer is used to indicate the memory address of the notification message in the second shared memory. In this way, it is convenient for the second process to quickly obtain the message content of the notification message according to the storage address of the notification message, thereby improving the communication efficiency between processes.
[0086] Step S604: When the second process needs to obtain the notification message, the storage address (e.g., pointer) of the notification message is found from the first shared memory, so that the second process can obtain the message content of the notification message by using the storage address (e.g., pointer).
[0087] For example, as shown in FIG6(b), a memory buffer is applied for in advance to the second shared memory by the first process, and a message is instantiated. Further, after the first process generates a notification message, the message content of the notification message is directly written into the pre-applied memory buffer in the second shared memory, such as directly writing the message configuration information of the notification message into the instantiated message to complete the writing of the message content. Further, in the case where the first process needs to transmit the notification message, the storage address of the notification message (for example, a pointer, which can indicate the memory address of the notification message in the second shared memory, that is, the address of the memory buffer of the second shared memory where the notification message is located) is serialized and written into the memory buffer of the first shared memory using the first sending component of the first process itself, and at the same time, the index information of the notification message can also be written into the memory block of the first shared memory. Furthermore, when the second process needs to obtain the notification message, the second routing component is used to obtain the storage address (such as a pointer) of the notification message from the first shared memory, and then the storage address (such as a pointer) of the notification message is used to read the message content of the notification message from the second shared memory, so that the second process obtains the message content of the notification message.
[0088] That is to say, in this example, since the structured message content of the notification message can be directly written into the second shared memory without serialization, there is no need for deserialization during the reading process. In other words, in this example, in order to effectively avoid the steps of copying, serialization and deserialization, the message content of the entire notification message occurs in the second shared memory during the subsequent reading and writing processes. Therefore, the efficiency of data writing and reading is effectively improved. At the same time, the computing resources required for inter-process communication are saved, and the efficiency of cross-process data transmission is improved, thereby improving the overall performance of the system while ensuring the normal operation of other business modules.
[0089] It should be noted that, in actual applications, for complex notification messages, inter-process communication can complete data transmission through pointers. However, as shown in Figure 6(c), the shared memory space can be further divided into multiple areas based on functions, and different processes can share the same shared memory space containing multiple areas; further, in actual applications, for the same shared memory space, each process has its own address space. In this case, as shown in Figure 6(d), the actual physical address mapped to the same second shared memory by the same pointer may be different. For example, pointer 1 or pointer 2 may be mapped to different addresses in the second shared memory. In this case, the pointer may become invalid and the message content of the notification message cannot be accessed.
[0090] Based on this, the address spaces between different processes can be pre-set so that the addresses mapped to the same shared memory are the same. For example, in a specific example, the first process includes a first address space, and the second process includes a second address space. Furthermore, the first address space and the second address space are mapped to the same address of the second shared memory. In other words, when the first process and the second process share the same shared memory (that is, the second shared memory), the actual physical location of the address space they each own is mapped to the shared memory is the same. In this way, it is convenient to successfully obtain the message content of the notification message from the second shared memory based on the pointer, which lays the foundation for improving the communication efficiency between processes in the future.
[0091] Furthermore, in a specific example, the first address space includes a first pointer instance, and the second address space includes a second pointer instance; the first pointer instance and the second pointer instance are obtained based on the same target address allocated by the allocator, in other words, the first pointer instance and the second pointer instance point to the same address. That is to say, in this example, the shared memory segment can be allocated to the same address of different processes by an allocator (such as an allocator based on a balanced binary tree), so that the address pointed to by the same pointer is the same. This method is simple and efficient, and does not require the process to participate in address coordination. The process only needs to set the address allocated by the allocator to its own pointer instance. In this way, the problem of pointer invalidation is effectively avoided, which provides strong support for the subsequent successful acquisition of the message content of the notification message from the second shared memory based on the pointer, and at the same time, it also lays the foundation for the subsequent improvement of the communication efficiency between processes.
[0092] For example, as shown in FIG6(e), for each channel (e.g., channel 1, channel 2, or channel 3), an address allocation request may be sent to the distributor respectively, and the address allocation request carries a key value corresponding to the channel, e.g., a key value. Here, in one example, the key values carried by different channels may be different. Further, the distributor allocates an address value to the channel based on the key value carried by the address allocation request (e.g., allocates address value 1, address value 2, and address value 3 to channel 1, channel 2, and channel 3, respectively). Further, for a group of processes corresponding to the channel (e.g., writer and reader), respective pointer instances may be set based on the address value allocated by the distributor. Thus, for a group of processes, i.e., a group of processes corresponding to the same channel, the address pointed to by the same pointer is exactly the same, thereby effectively avoiding the problem of pointer invalidation. It can be understood that the address allocated by the distributor in the above process may not depend on the specific process, but only on the order of the address allocation requests received by the distributor.
[0093] It should be noted that the above is only a specific example. In actual applications, other address allocation methods may also be used, and the present disclosure does not limit this.
[0094] FIG. 7( a) is a schematic flow chart of a message transmission method according to an embodiment of the present application. Figure 3 The method may optionally be applied to electronic devices, such as personal computers, servers, server clusters, and other electronic devices. It is understandable that the relevant contents of the method shown in Figures 1 to 6 above may also be applied to this example, and the relevant contents will not be repeated in this example.
[0095] Further, the method includes at least part of the following contents. Specifically, as shown in FIG7(a), it includes:
[0096] Step S701: applying for at least one memory buffer from the second shared memory through the first process.
[0097] Here, the at least one memory buffer is used to store at least the message content of the notification message to be sent by the first process. Further, in this example, the second shared memory is a memory space that can be accessed by both the first process and the second process that need to perform message transmission.
[0098] Here, for relevant examples of the second shared memory, please refer to the above description, which will not be repeated here.
[0099] Step S702: when the first process generates a notification message, the message content of the notification message is written into the at least one memory buffer through the first process.
[0100] Step S703: when the first process needs to transmit the notification message, the storage address of the notification message is serialized by the first process and written into the first shared memory, and the index information of the notification message is written into the first shared memory by the first process.
[0101] That is to say, in this example, the index information and storage address of the notification message are stored in the first shared memory.
[0102] Step S704: when the first process needs to transmit the notification message, the index information of the notification message is stored in the third shared memory through the first process.
[0103] Here, the third shared memory is used to store index information of messages that need to be transmitted between different processes.
[0104] For example, when the first process needs to transmit the notification message, as shown in Figure 7(b), the first sending component of the first process itself can be used to write the index information of the notification message and the serialized storage address into the first shared memory. At the same time, the first sending component can also be used to write the index information of the notification message into the third shared memory. This facilitates subsequent monitoring of the third shared memory to ensure that the second process obtains the required notification message.
[0105] Step S705: monitor the third shared memory to determine whether there is a notification message that needs to be transmitted to the second process.
[0106] Step S706: when the index information of the notification message that needs to be transmitted to the second process is monitored, a storage address (eg, a pointer) corresponding to the monitored index information is searched from the first shared memory.
[0107] Here, the found storage address is the storage address of the notification message that needs to be transmitted to the second process.
[0108] That is to say, in this example, it is possible to determine whether there is a notification message that needs to be transmitted to the second process based on the monitoring of the third shared memory, and when it is determined that there is a notification message that needs to be transmitted to the second process, for example, when the index information of the notification message that needs to be transmitted to the second process is monitored, the storage address corresponding to the monitored index information is searched from the first shared memory, and the storage address is transmitted to the second process, so that the second process can obtain the message content of the notification message from the second shared memory according to the storage address. In this way, the efficiency of cross-process data transmission is improved and the data transmission delay is reduced.
[0109] Step S707: Transmit the storage address of the notification message to the second process.
[0110] Step S708: Obtain the message content of the notification message from the second shared memory through the second process and by using the storage address of the notification message.
[0111] In this way, this solution does not need to copy the message content of the notification message multiple times, and at the same time, it does not need serialization and deserialization to achieve cross-process data transmission. In this way, the data transmission efficiency between processes is effectively improved and the data transmission delay is reduced. At the same time, it also saves the computing resources required for inter-process communication and reduces the occupied storage space, thereby reducing the overall burden of the system and providing strong support for effectively saving the time required for the entire communication process.
[0112] For example, if Figure 8As shown, a memory buffer is pre-applied to the second shared memory by the first process, and after the first process generates a notification message, the message content of the generated notification message is written into the pre-prepared memory buffer in the second shared memory; further, when the first process determines that the notification message needs to be transmitted, the index information of the notification message is written into the memory block of the first shared memory by using the first sending component in the first process, and the serialized pointer is written into the memory buffer of the first shared memory, and at the same time, the index information of the notification message is also written into the third shared memory by the first process; further, the third shared memory is monitored by the second routing component to determine whether there is a notification message that needs to be transmitted to the second process; further, after monitoring the index information of the notification message that needs to be transmitted to the second process, the index information of the notification message is parsed, and the serialized pointer corresponding to the index information is found from the first shared memory, and the serialized pointer is deserialized, and the deserialized pointer is transmitted to the second process, for example, sent to the second receiving component in the second process, so that the second process obtains the message content of the notification message from the second shared memory according to the received pointer. In this way, inter-process communication is realized.
[0113] In summary, the disclosed solution has the following advantages:
[0114] First, low latency: The message transmission of the disclosed solution can be transmitted across processes with zero copy, saving the processes required for serialization, deserialization and copying, and effectively reducing the message transmission latency.
[0115] Second, the problem of pointer invalidation is solved. The disclosed solution can ensure that the address spaces of different processes are mapped to the same shared memory address through an allocator (such as a memory allocator based on a balanced binary tree), thus effectively solving the problem of pointer invalidation caused by different pointers pointing to different points during message transmission, thereby providing strong support for efficient message transmission between processes.
[0116] Third, it is more versatile. The disclosed solution can quickly improve an existing data transmission function and transform the data transmission mode described in the disclosed solution to realize message transmission between processes on the basis of "zero copy", so it is more versatile.
[0117] The disclosed solution also provides a message transmission device, such as Fig. 9 As shown, including:
[0118] An information writing unit 901 is used to write the message feature information of the notification message into a first shared memory through a first process; wherein the first shared memory is a memory space that can be accessed by both the first process and the second process that need to perform message transmission;
[0119] The information reading unit 902 is used to find the message characteristic information of the notification message from the first shared memory when the second process needs to obtain the notification message, so as to use the message characteristic information to enable the second process to obtain the message content of the notification message.
[0120] In a specific example of the disclosed solution, the information writing unit is specifically used to:
[0121] In the case that the first process needs to transmit the notification message, the message feature information of the notification message is written into the first shared memory through the first process.
[0122] In a specific example of the disclosed solution, the information writing unit is specifically used to:
[0123] The storage address of the notification message is serialized by the first process and then written into the first shared memory.
[0124] In a specific example of the disclosed solution, the information writing unit is further used to:
[0125] The index information of the notification message is written into the first shared memory through the first process.
[0126] In a specific example of the disclosed solution, the information writing unit is further used to:
[0127] Applying for at least one memory buffer from the second shared memory through the first process; the at least one memory buffer is used to store at least the message content of the notification message to be sent by the first process;
[0128] The second shared memory is a memory space that can be accessed by both the first process and the second process that need to transmit messages.
[0129] In a specific example of the disclosed solution, the first process includes a first address space, and the second process includes a second address space; wherein,
[0130] The first address space and the second address space are mapped to the same address of the second shared memory.
[0131] In a specific example of the disclosed solution, the first address space includes a first pointer instance, and the second address space includes a second pointer instance;
[0132] The first pointer instance and the second pointer instance are obtained based on the same target address allocated by the allocator.
[0133] In a specific example of the disclosed solution, the information writing unit is further used to:
[0134] In the case where the first process generates the notification message, the message content of the notification message is written into the at least one memory buffer by the first process.
[0135] In a specific example of the disclosed solution, the storage address of the notification message includes at least: a memory address of the notification message in the second shared memory.
[0136] In a specific example of the disclosed solution, the memory address of the notification message in the second shared memory includes at least: a pointer to the notification message; wherein the pointer is used to indicate the memory address of the notification message in the second shared memory.
[0137] In a specific example of the disclosed solution, the information reading unit is specifically used to:
[0138] Using the index information of the notification message, searching for the storage address of the notification message from the first shared memory;
[0139] transmitting the storage address of the notification message to the second process;
[0140] The message content of the notification message is acquired from the second shared memory through the second process and by using the storage address of the notification message.
[0141] In a specific example of the disclosed solution, the information writing unit is further used to:
[0142] In the case where the first process needs to transmit the notification message, the index information of the notification message is stored in the third shared memory through the first process, and the third shared memory is used to store the index information of the message that needs to be transmitted between different processes.
[0143] In a specific example of the disclosed solution, the information reading unit is further used to:
[0144] The third shared memory is monitored to determine whether there is a notification message that needs to be transmitted to the second process.
[0145] In a specific example of the disclosed solution, the information reading unit is specifically used to:
[0146] When the index information of the notification message that needs to be transmitted to the second process is monitored, the storage address corresponding to the monitored index information is searched from the first shared memory.
[0147] For the description of the specific functions and examples of each unit of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.
[0148] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0149] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0150] Fig.10 A schematic block diagram of an example electronic device 1000 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0151] like Fig.10 As shown, the device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0152] A number of components in the device 1000 are connected to the I / O interface 1005, including: an input unit 1006, such as a keyboard, a mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1008, such as a disk, an optical disk, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the device 1000 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0153] The computing unit 1001 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1001 performs the various methods and processes described above, such as the message transmission method. For example, in some embodiments, the message transmission method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1000 via ROM 1002 and / or communication unit 1009. When the computer program is loaded into RAM 1003 and executed by the computing unit 1001, one or more steps of the message transmission method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to perform the message transmission method in any other appropriate manner (e.g., by means of firmware).
[0154] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0155] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0156] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0157] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0158] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0159] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0160] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0161] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A message transmission method, comprising: Writing the message feature information of the notification message into the first shared memory through the first process; wherein the first shared memory is a memory space accessible to both the first process and the second process that need to perform message transmission; When the second process needs to obtain the notification message, the message characteristic information of the notification message is found from the first shared memory, so as to enable the second process to obtain the message content of the notification message by using the message characteristic information.
2. The method according to claim 1, wherein: Writing the message characteristic information of the notification message into the first shared memory through the first process includes: In the case that the first process needs to transmit the notification message, the message feature information of the notification message is written into the first shared memory through the first process.
3. The method according to claim 2, wherein: Writing the message characteristic information of the notification message into the first shared memory through the first process includes: The storage address of the notification message is serialized by the first process and then written into the first shared memory.
4. The method according to claim 3, further comprising: The index information of the notification message is written into the first shared memory through the first process.
5. The method according to claim 3 or 4, further comprising: Applying for at least one memory buffer from the second shared memory through the first process; the at least one memory buffer is used to store at least the message content of the notification message to be sent by the first process; The second shared memory is a memory space that can be accessed by both the first process and the second process that need to transmit messages.
6. The method according to claim 5, wherein: The first process includes a first address space, and the second process includes a second address space; wherein, The first address space and the second address space are mapped to the same address of the second shared memory.
7. The method according to claim 6, wherein: The first address space includes a first pointer instance, and the second address space includes a second pointer instance; The first pointer instance and the second pointer instance are obtained based on the same target address allocated by the allocator.
8. The method according to any one of claims 5 to 7, further comprising: In the case where the first process generates the notification message, the message content of the notification message is written into the at least one memory buffer by the first process.
9. The method according to claim 8, wherein: The storage address of the notification message includes at least: a memory address of the notification message in the second shared memory.
10. The method according to claim 9, wherein: The memory address of the notification message in the second shared memory includes at least: a pointer to the notification message; wherein the pointer is used to indicate the memory address of the notification message in the second shared memory.
11. The method according to claim 8, wherein: The step of searching the first shared memory for the message characteristic information of the notification message, so as to enable the second process to obtain the message content of the notification message by using the message characteristic information, includes: Using the index information of the notification message, searching for the storage address of the notification message from the first shared memory; transmitting the storage address of the notification message to the second process; The message content of the notification message is acquired from the second shared memory through the second process and by using the storage address of the notification message.
12. The method according to claim 11, further comprising: In the case where the first process needs to transmit the notification message, the index information of the notification message is stored in the third shared memory through the first process, and the third shared memory is used to store the index information of the message that needs to be transmitted between different processes.
13. The method according to claim 12, further comprising: The third shared memory is monitored to determine whether there is a notification message that needs to be transmitted to the second process.
14. The method according to claim 13, wherein: The using the index information of the notification message to search for the storage address of the notification message from the first shared memory includes: When the index information of the notification message that needs to be transmitted to the second process is monitored, the storage address corresponding to the monitored index information is searched from the first shared memory.
15. A message transmission device, comprising: An information writing unit, used to write the message feature information of the notification message into a first shared memory through a first process; wherein the first shared memory is a memory space accessible to both the first process and the second process that need to perform message transmission; The information reading unit is used to find the message characteristic information of the notification message from the first shared memory when the second process needs to obtain the notification message, so as to use the message characteristic information to enable the second process to obtain the message content of the notification message.
16. The device according to claim 15, wherein: The information writing unit is specifically used for: In the case that the first process needs to transmit the notification message, the message feature information of the notification message is written into the first shared memory through the first process.
17. The device according to claim 16, wherein: The information writing unit is specifically used for: The storage address of the notification message is serialized by the first process and then written into the first shared memory.
18. The device according to claim 17, wherein: The information writing unit is further used for: The index information of the notification message is written into the first shared memory through the first process.
19. The device according to claim 17 or 18, wherein: The information writing unit is further used for: Applying for at least one memory buffer from the second shared memory through the first process; the at least one memory buffer is used to store at least the message content of the notification message to be sent by the first process; The second shared memory is a memory space that can be accessed by both the first process and the second process that need to transmit messages.
20. The device according to claim 19, wherein The first process includes a first address space, and the second process includes a second address space; wherein, The first address space and the second address space are mapped to the same address of the second shared memory.
21. The device according to claim 20, wherein: The first address space includes a first pointer instance, and the second address space includes a second pointer instance; The first pointer instance and the second pointer instance are obtained based on the same target address allocated by the allocator.
22. The device according to any one of claims 19 to 21, wherein: The information writing unit is further used for: In the case where the first process generates the notification message, the message content of the notification message is written into the at least one memory buffer by the first process.
23. The device according to claim 22, wherein: The storage address of the notification message includes at least: a memory address of the notification message in the second shared memory.
24. The device according to claim 23, wherein: The memory address of the notification message in the second shared memory includes at least: a pointer to the notification message; wherein the pointer is used to indicate the memory address of the notification message in the second shared memory.
25. The device according to claim 22, wherein: The information reading unit is specifically used for: Using the index information of the notification message, searching for the storage address of the notification message from the first shared memory; transmitting the storage address of the notification message to the second process; The message content of the notification message is acquired from the second shared memory through the second process and by using the storage address of the notification message.
26. The device according to claim 25, wherein The information writing unit is further used for: In the case where the first process needs to transmit the notification message, the index information of the notification message is stored in the third shared memory through the first process, and the third shared memory is used to store the index information of the message that needs to be transmitted between different processes.
27. The device according to claim 26, wherein: The information reading unit is further used for: The third shared memory is monitored to determine whether there is a notification message that needs to be transmitted to the second process.
28. The device according to claim 27, wherein The information reading unit is specifically used for: When the index information of the notification message that needs to be transmitted to the second process is monitored, the storage address corresponding to the monitored index information is searched from the first shared memory.
29. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 14.
30. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-14.
31. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Inter-process communication method and system, storage medium and computer equipment
CN114518969A
Zero-copy-based DDS (Direct Digital Synthesizer) communication method and system
CN116521394A
Inter-process data sharing method and device and electronic equipment
CN117033028A
Financial quotation subscription method and device based on shared memory message queue and medium
CN117608871A
Data transmission method and related device
CN117931465A