Message transmission method and device, equipment and storage medium
By using shared memory to transmit message feature information in the autonomous driving system, the problem of low efficiency in inter-process communication is solved, efficient cross-process data transmission is achieved, latency and computing resource consumption are reduced, and system performance is improved.
Patent Information
- Application Number
- CN202411660780.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-11-19
AI Technical Summary
In autonomous driving systems, low inter-process communication efficiency leads to high message transmission latency and high computational resource consumption, which affects system performance.
By writing message characteristic information, such as index information and storage address, of the notification message into the shared memory of the first and second processes, without serializing the message content, the second process can directly obtain the message content based on the message characteristic information, thus realizing cross-process data transmission.
It improves inter-process communication efficiency, reduces message transmission latency, saves computing resources, and ensures the overall performance of the system.
Smart Images

Figure CN119621368B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of data processing, and particularly relates to the technical field of automatic driving, auxiliary driving, automatic parking, intelligent transportation, etc. BACKGROUND
[0002] With the continuous development of automatic driving systems, the specifications of the sensors used are getting higher and higher, resulting in the size and complexity of sensor data increasing continuously. Therefore, distributed automatic driving systems emerge as the times require. The distributed automatic driving system provides a standardized communication interface, so that multiple processes can run on different hosts (or different cores of a host) and work cooperatively. In the cooperative engineering, inter-process communication (IPC) is involved, that is, message transmission between different processes. At this time, the efficiency of inter-process communication becomes one of the key factors of system performance. SUMMARY
[0003] The present disclosure provides a message transmission method, device, equipment and storage medium.
[0004] According to an aspect of the present disclosure, a message transmission method is provided, comprising:
[0005] writing, by a first process, message feature information of a notification message into a first shared memory; wherein the first shared memory is a memory space accessible to the first process and a second process which need to perform message transmission;
[0006] in a case where the second process needs to acquire the notification message, finding the message feature information of the notification message from the first shared memory, so as to make the second process acquire message content of the notification message by using the message feature information.
[0007] According to another aspect of the present disclosure, a message transmission device is provided, comprising:
[0008] an information writing unit, configured to write, by a first process, message feature information of a notification message into a first shared memory; wherein the first shared memory is a memory space accessible to the first process and a second process which need to perform message transmission;
[0009] an information reading unit, configured to, in a case where the second process needs to acquire the notification message, find the message feature information of the notification message from the first shared memory, so as to make the second process acquire message content of the notification message by using the message feature information.
[0010] According to another aspect of the present disclosure, an electronic device is provided, comprising:
[0011] at least one processor; and
[0012] a memory in communication with the at least one processor; wherein
[0013] The memory stores instructions executable 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 of any of 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 perform the method according to any of the embodiments of the present disclosure.
[0015] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method according to any of the embodiments of the present disclosure.
[0016] In this way, the scheme of the present disclosure can first write the message feature information of the notification message into the first shared memory by the first process, and then find out the message feature information of the notification message to be acquired from the first shared memory in the case that the second process needs to acquire the notification message, so that the second process acquires the message content of the notification message by using the message feature information 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 thereby effectively reducing the message transmission delay.
[0017] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0018] The accompanying drawings serve to better understand the present scheme and do not constitute limitations on the present disclosure. Among them:
[0019] Figures 1(a) to 1(c) is a schematic diagram of a cross-process message transmission framework in an automatic driving system;
[0020] Figure 1(d) is a schematic diagram of cross-process message transmission serialization and deserialization;
[0021] Figure 2 is a schematic flowchart of a message transmission method according to an embodiment of the present application;
[0022] Figure 3 is a schematic diagram of an interaction scenario for realizing message transmission between different processes by using a first shared memory according to an embodiment of the present application;
[0023] Figure 4is a schematic flow of a message transmission method according to an embodiment of the present application Figure Two ;
[0024] Fig. 5(a) is a schematic diagram of an interaction scenario for implementing message transmission between different processes by using a first shared memory according to an embodiment of the present application Figure Two ;
[0025] Fig. 5(b) is a schematic diagram of an interaction scenario for implementing message transmission between different processes by using a first shared memory according to an embodiment of the present application Figure Three ;
[0026] Fig. 6(a) is a schematic flow of a message transmission method according to an embodiment of the present application Figure Three ;
[0027] Fig. 6(b) is a schematic diagram of an interaction scenario for implementing message transmission between different processes by using a first shared memory and a second shared memory according to an embodiment of the present application
[0028] Figures 6(c) to 6(e) is a specific application scenario diagram of a mapping relationship between a shared memory space and a pointer according to an embodiment of the present application
[0029] Fig. 7(a) is a schematic flow of a message transmission method according to an embodiment of the present application Figure Four ;
[0030] Fig. 7(b) is a schematic diagram of an interaction scenario for implementing message transmission between different processes by using a first shared memory according to an embodiment of the present application Figure Four ;
[0031] Figure 8 is a schematic diagram of an application scenario of a message transmission method according to an embodiment of the present application in an example
[0032] Figure 9 is a structural schematic diagram of a message transmission apparatus according to an embodiment of the present application
[0033] Figure 10 is a block diagram of an electronic device for implementing the message transmission method according to an embodiment of the present application. DETAILED DESCRIPTION
[0034] Exemplary embodiments of the present disclosure are described herein with reference to the accompanying drawings, which are included to provide a thorough understanding of embodiments of the present disclosure by a person of ordinary skill in the art, and should be considered in connection with the following detailed description, but do not limit the scope of the present disclosure. Thus, those skilled in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, in the following description, descriptions of well-known functions and constructions are omitted for clarity and conciseness.
[0035] The term “and / or” used in the present document is only used to describe the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. The term “at least one” in the present document means any one of the plurality or any combination of at least two of the plurality, for example, at least one of A, B and C includes any one or more elements selected from the set consisting of A, B and C. The terms “first”, “second” in the present document mean to refer to a plurality of similar technical terms and to distinguish them, and do not mean to limit the order or mean to limit only two, for example, the first feature and the second feature refer to two categories / 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, a plurality of specific details are given in the specific embodiments below. Those skilled in the art should understand that the present disclosure can also be implemented without some specific details. In some examples, methods, means, elements and circuits well known to those skilled in the art are not described in detail in order to highlight the main idea of the present disclosure.
[0037] The related technologies of the embodiments of the present disclosure are described below. The following related technologies can be combined with the technical solutions of the embodiments of the present disclosure in any way as optional schemes, and all belong to the protection scope of the embodiments of the present disclosure.
[0038] Fig. 1(a) is a message transmission framework across processes in an autonomous driving system. As shown in Fig. 1(a), in the running framework of the autonomous driving system, such as the concept of Cybersecurity in Autonomous Vehicles, the communication between the first process (a process for writing data, which can be denoted as Writer) and the second process (a process for reading data, which can be denoted as Reader) is completed through a channel, which allows processes to exchange data in the form of message passing. In this way, message passing across processes can be achieved.
[0039] Here, it should be noted that in an example, one process of the present disclosure scheme can run in a processing node (such as a central processing unit (CPU) server) in a distributed autonomous driving system, for example, the first process and the second process described above can run in different processing nodes. Alternatively, in another example, one process can run in a processing core (i.e., the smallest processing unit running the process) in a processing node, for example, the first process and the second process described above can run in different processing cores in the same processing node.
[0040] Further, in an example, the communication process between processes is mainly completed by a transmitter for transmitting data, a dispatcher for data distribution, and a receiver for receiving data. For example, as shown in FIG. 1(b), the first process corresponds to a first transmitter and a first receiver, and the second process corresponds to a second transmitter and a second receiver; here, the first dispatcher is connected with the first receiver of the first process, and is used for distributing data for the first process; correspondingly, the second dispatcher is connected with the second receiver of the second process, and is used for distributing data for the second process.
[0041] Further, in the case that the first process needs to transmit data to the second process, the first process transmits the data through the first transmitter and the first transmission path, at this time, the second dispatcher in the first transmission path receives the data and distributes it to the second process, for example, through the second receiver in the second process to the space of the second process. Similarly, in the case that the second process needs to transmit data to the first process, the second process transmits the data through the second transmitter and the second transmission path, at this time, the first dispatcher in the second transmission path receives the data and distributes it to the first process, for example, through the first receiver in the first process to the space of the first process. In this way, the communication between the first process and the second process is completed.
[0042] Here, in an example, in the running framework of the automatic driving system, the inter-process communication can be realized by means of shared memory (SHM) and real-time publish-subscribe (RTPS), etc. For example, in the SHM mode, multiple processes are allowed to access the same memory area to quickly transmit a large amount of data such as sensor data or map information through shared memory. In the RTPS mode, processes between different computing nodes (also referred to as processing nodes) can be allowed to transmit data.
[0043] It can be understood that in actual application, a hybrid method of the above two methods can also be used, and the specific transmission method is not limited by the present disclosure.
[0044] Further, Fig. 1(c) is a schematic diagram of inter-process communication using shared memory. As shown in Fig. 1(c), for the first process (e.g., the writer), a first sending component of the first process can serialize a notification message in the first process and copy the serialized notification message into a first shared memory, such as copying index information of the notification message into blocks of the first shared memory and copying message content of the serialized notification message into blocks buffer of the first shared memory. Accordingly, the first sending component can also write the index information of the serialized notification message into a third shared memory; here, the third shared memory can specifically store a readable index list, which stores index information of messages that need to be transmitted between different processes.
[0045] For the second process, a second dispatcher of the second process can listen to the third shared memory to determine whether there is a notification message that needs to be sent to the second process; if so, the second dispatcher can parse the index information of the notification message that needs to be obtained, copy the message content of the notification message that matches the parsed index information from the first shared memory according to the parsed index information, deserialize the message content, and transmit the deserialized message content to the space of the second process via a second receiver of the second process.
[0046] Here, it should be noted that the first shared memory can mainly include three regions, which can be referred to as a first region, a second region, and a third region. The first region can be mainly used to store state information, such as state information of each memory block, such as whether it is currently being written, whether it is currently being read, a count of references by a current writer, and a count of references by a current reader, etc. The second region mainly includes a plurality of memory blocks for storing index information. The third region mainly includes a plurality of memory blocks for storing message content of messages that need to be transmitted, such as serialized message content, etc.
[0047] Further, Fig. 1(d) is a schematic diagram of serialization of the notification message; as shown in Fig. 1(d), the notification message is Struct structure data, which may, for example, include structured uint64_t idx_, Struct2*ptr_, and String st_, wherein each of the above data may be further structured data, for example, Struct2*ptr_ includes uint64_t a_ and uint64_t b_, and 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 tiling in a sequence to become a continuous byte stream for transmission. Correspondingly, deserialization may refer to restoring the above serialized byte stream to the original structure, such as restoring to the Struct structure.
[0048] According to the above process, it can be known that in inter-process communication, when the notification message is transmitted from one process to another process, at least two data copies are required, and serialization and deserialization of data are also involved; for a notification message of a complex type, serialization and deserialization need to convert each field contained in the notification message into a byte stream, which undoubtedly consumes additional computing resources, increases the performance burden of the CPU, increases the consumption of memory bandwidth, and also increases the delay of message transmission, thereby affecting the time of normal message processing of other modules. Moreover, the storage space occupied by the serialized data is also more, which further affects the overall operation of the system to some extent.
[0049] Based on this, the present application provides a message transmission method to improve the transmission efficiency of inter-process communication, thereby reducing the message transmission delay, and reducing the computing resources required for inter-process communication, ensuring the normal operation of other business modules, and thereby improving the performance of the overall system.
[0050] Specifically, Figure 2 is a schematic flowchart of a message transmission method according to an embodiment of the present application. The method may, for example, be applied in electronic devices such as personal computers, servers, server clusters, and the like.
[0051] Further, the method includes at least part of the following content. As shown in Figure 2 , it includes:
[0052] Step S201: writing, by a first process (which may also be referred to as a sender process, or a write process, for example, writer), message feature information of a notification message into a first shared memory.
[0053] Here, the first shared memory is a memory space accessible to the first process and the second process (also referred to as a receiver process, or a read process, for example, denoted as reader) that need to transmit messages.
[0054] Further, in an example, the memory space in the first shared memory is a continuous memory space, which facilitates the writing and reading efficiency of the processes.
[0055] Step S202: In a case where the second process needs to obtain the notification message, the message feature information of the notification message is found from the first shared memory, so that the second process obtains the message content of the notification message by using the message feature information.
[0056] In this way, the message feature information of the notification message is written into the first shared memory by the first process, and in a case where the second process needs to obtain the notification message, the message feature information of the notification message to be obtained is found from the first shared memory, so that the second process obtains the message content of the notification message by using the message feature information 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, by the first process, of the message feature information of the notification message into the first shared memory (for example, step S201) can specifically include: writing, by the first process, at least one of the following information of the notification message into the first shared memory: index information of the notification message, storage address of the notification message. In this way, strong support is provided for subsequently reducing the computing resources required for data transmission and improving the communication efficiency between processes.
[0058] For example, as shown in Figure 3 The first process writes the index information and the storage address of the notification message to be transmitted into the first shared memory by using the first sending component of the first process; accordingly, in a case where the second process needs to obtain the notification message, the second routing component responsible for the data distribution of the second process can obtain the storage address of the notification message to be obtained by the second process from the first shared memory, so as to make the second process 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. The above process does not need serialization and deserialization processing, which effectively improves the data transmission efficiency and saves the computing resources required for inter-process communication.
[0059] Figure 4 is a schematic flow of a message transmission method according to an embodiment of the present application Figure TwoThe method can be optionally applied to electronic devices such as personal computers, servers, server clusters, and the like. It can be understood that the above-mentioned related contents of the method shown in FIG. 1 to Figure 3 The method shown in FIG. 1 to
[0060] Further, the method includes at least part of the following contents. Specifically, as shown in Figure 4
[0061] Step S401: In the case where the first process needs to transmit a notification message, the first process writes message feature information of the notification message into a first shared memory.
[0062] Here, the first shared memory is a memory space accessible to the first process and the second process that need to transmit messages.
[0063] For example, in a specific example, the above-mentioned writing of the message feature information of the notification message into the first shared memory by the first process can specifically include: the first process serializes the storage address of the notification message and then writes it into the first shared memory, such as the first process serializes the storage address of the notification message and then writes it into a memory buffer in the first shared memory. In this way, the storage address can be quickly transmitted between the first shared memory and the first process and the second process, thereby improving the communication efficiency.
[0064] It should be noted that the present disclosure 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 data amount of the storage address is small and the data structure is simple, so compared with directly serializing the message content of the notification message, the present disclosure effectively improves the data processing efficiency, saves the computing resources required for inter-process communication, and thereby provides strong support for improving the communication efficiency between processes
[0065] In addition, it should be noted that in this example, since the storage address of the notification message stored in the first shared memory is serialized, after the serialized storage address of the notification message is found 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] Further, in another specific example, in a case where the first process needs to transmit the notification message, the first process can also write the index information of the notification message into the first shared memory, such as writing the index information of the notification message into the memory block in the first shared memory. In this way, the storage address can be quickly found subsequently, thereby providing strong support for subsequent improvement of communication efficiency.
[0067] Step S402: In a case where the second process needs to acquire the notification message, the message characteristic information of the notification message is found from the first shared memory, so as to make the second process acquire the message content of the notification message by using the message characteristic information.
[0068] In this way, in a case where a notification message needs to be transmitted, the message characteristic information of the notification message is written into the first shared memory, and in a case where the second process needs to acquire the notification message, the second process can receive the message content of the notification message by using the message characteristic information. In this way, the message passing between processes is realized, and strong support is provided for effectively improving the efficiency of data transmission and reducing the message transmission delay.
[0069] For example, as shown in FIG. 5(a), in a case where the first process needs to transmit the notification message, the first process can use the first sending component of itself to write the index information of the notification message into the memory block of the first shared memory, and 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 FIG. 5(b), in a case where the second process needs to acquire the notification message, the serialized storage address of the notification message is found from the first shared memory by using the second routing component, and after the serialized storage address is deserialized, the deserialized storage address is sent to the second process, such as the second receiving component of the second process, so that the second process acquires the message content of the notification message by using the second receiving component.
[0071] Here, it should be noted that in an example, the first shared memory can mainly include three regions, which can be a first region, a second region and a third region; as shown in FIG. 5(a) and FIG. 5(b), the first region can be mainly used to store state information, such as the state 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 reference, and the count of the current reader reference, etc.; the second region mainly contains a plurality of memory blocks for storing index information; and the third region mainly includes a plurality of memory buffers for storing the storage addresses of the messages needed to be transmitted, such as the serialized storage addresses, etc.
[0072] Further, in an example, the state information of the first shared memory can also indicate a starting position of the first shared memory.
[0073] Fig. 6(a) is a schematic flowchart of a message transmission method according to an embodiment of the present application. Figure Three The method can be optionally applied in electronic devices, such as personal computers, servers, server clusters, and the like. It can be understood that the above-mentioned method shown in Figs. 1 to 5 can also be applied in this example, and the associated content will not be described again.
[0074] Further, the method includes at least part of the following contents. Specifically, as shown in Fig. 6(a), the method includes:
[0075] Step S601: applying, by a first process, at least one memory buffer to a second shared memory.
[0076] Here, the at least one memory buffer is used to store at least message content of a notification message required to be sent by the first process.
[0077] Further, in this example, the second shared memory is a memory space accessible by the first process and the second process which need to perform message transmission.
[0078] That is, in this example, at least one memory buffer capable of storing message content of a notification message can be applied to the second shared memory in advance before the first process generates the notification message, so that the message content of the notification message can be written into the second shared memory in time by the first process after the notification message is generated, without being stored in the first process. In this way, the serialization and deserialization processes are effectively avoided, and strong support is provided for the second process to quickly obtain the message content of the notification message from the memory buffer applied 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: in the case where the first process generates the notification message, writing, by the first process, message content of the notification message into the at least one memory buffer.
[0080] That is, in the example, after the first process generates the notification message, the message content of the notification message, such as message data in a specific message format, can be directly written into the second shared memory, such as a memory buffer area in the pre-applied second shared memory, without the need to store the notification message in the first process, so as to effectively avoid the serialization and deserialization processes, avoid the additional consumption of computing resources due to serialization and deserialization, at the same time, reduce the occupied storage space, and further reduce the overall burden of the system, thereby effectively saving the time required in the entire communication process, and improving the communication efficiency between processes.
[0081] Step S603: In the case where the first process needs to transmit the notification message, the storage address of the notification message is serialized and written into the first shared memory by the first process.
[0082] Here, the first shared memory is a memory space that can be accessed by the first process and the second process that need to transmit messages.
[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 first process can also write the index information of the notification message into the first shared memory.
[0084] Further, in a specific example, the storage address of the notification message at least includes the memory address of the notification message in the second shared memory.
[0085] Further, in another specific example, the memory address of the notification message in the second shared memory at least includes 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, the second process can 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: In the case where the second process needs to obtain the notification message, the storage address (such as a pointer) of the notification message is found from the first shared memory, so that the second process obtains the message content of the notification message by using the storage address (such as a pointer).
[0087] For example, as shown in FIG. 6(b), the first process applies for a memory buffer in the second shared memory in advance and instantiates a message. Further, after the first process generates a notification message, the message content of the notification message is directly written into the memory buffer in the second shared memory pre-applied, such as directly writing the message configuration information of the notification message into the instantiation message to complete the writing of the message content. Further, in the case that the first process needs to transmit the notification message, the storage address (such as a pointer, which can indicate the memory address of the notification message in the second shared memory, i.e., the address of the memory buffer of the second shared memory where the notification message is located) of the notification message is serialized and written into the memory buffer of the first shared memory by using the first sending component of the first process, and the index information of the notification message can also be written into the memory block of the first shared memory. Further, in the case that the second process needs to obtain the notification message, the storage address (such as a pointer) of the notification message is obtained from the first shared memory by using the second routing component, and then the message content of the notification message is read from the second shared memory by using the storage address (such as a pointer) of the notification message, so that the second process obtains the message content of the notification message.
[0088] That is, in this example, since the structured message content of the notification message can be directly written into the second shared memory without serialization processing, and accordingly, deserialization processing is not needed in 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 in the subsequent reading and writing process, 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, the efficiency of cross-process data transmission is improved, and thus the overall performance of the system is improved while ensuring the normal operation of other business modules.
[0089] It should be noted that in actual application, for a complex type of notification message, inter-process communication can complete data transmission through a pointer. However, as shown in FIG. 6(c), the shared memory space can be further divided into multiple regions based on functions, and different processes can share the same segment of shared memory space containing multiple regions. Further, in actual application, for the same shared memory space, each process has its own address space, at this time, as shown in FIG. 6(d), the actual physical addresses of the same pointer in the same second shared memory can be different, such as pointer 1 or pointer 2, which are mapped to different addresses of the second shared memory, at this time, it can cause the pointer to be invalid and unable to access the message content of the notification message.
[0090] Based on this, the address spaces of different processes can be pre-configured to be mapped to the same address of the same shared memory, for example, in a specific example, the first process includes a first address space, and the second process includes a second address space. Further, the first address space and the second address space are mapped to the same address of the second shared memory. That is, when the first process and the second process share the same segment of the shared memory (i.e., the second shared memory), the address spaces they respectively own are mapped to the same actual physical location of the shared memory, so that the message content of the notification message can be successfully obtained from the second shared memory based on the pointer subsequently, laying a foundation for improving the communication efficiency between processes subsequently.
[0091] Further, 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 based on the same target address allocated by the allocator, in other words, the addresses pointed to by the first pointer instance and the second pointer instance are the same. That is, in this example, the allocator (such as a balanced binary tree-based allocator) can allocate the shared memory segment to the same address of different processes, so that the same pointer points to the same address, which is simple and efficient, and does not require the process to participate in address coordination. Only the process needs to set the address allocated by the allocator to its own pointer instance, so that the problem of pointer invalidation is effectively avoided, providing strong support for successfully obtaining the message content of the notification message from the second shared memory based on the pointer subsequently, and laying a foundation for improving the communication efficiency between processes subsequently.
[0092] For example, as shown in FIG. 6(e), for each channel (such as channel 1, channel 2, or channel 3), an address allocation request can be sent to the allocator, which carries a key value corresponding to the channel, such as a key value. In an example, the key values carried by different channels can be different. Further, the allocator allocates an address value to the channel based on the key value carried in the address allocation request (such as allocating 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 (such as writers and readers) corresponding to the channel, the respective pointer instances can be set based on the address value allocated by the allocator. 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 completely the same, thereby effectively avoiding the problem of pointer invalidation. It can be understood that the address allocated by the allocator in the above process can not depend on the specific process, but only on the order of the address allocation request received by the allocator.
[0093] It should be noted that the above is only a specific example, and other address allocation methods can also be used in actual applications, and the present disclosure does not limit this.
[0094] FIG. 7(a) is a schematic flow of a message transmission method according to an embodiment of the present application Figure Three The method can optionally be applied to electronic devices such as personal computers, servers, server clusters, and the like. It can be understood that the related content of the methods shown in FIGS. 1 to 6 above can also be applied to this example, and the associated content will not be described again.
[0095] Further, the method includes at least part of the following content. Specifically, as shown in FIG. 7(a), it includes:
[0096] Step S701: applying, by a first process, at least one memory buffer to a second shared memory.
[0097] Here, the at least one memory buffer is used to store at least the message content of a notification message to be sent by the first process. Further, in this example, the second shared memory is a memory space accessible by the first process and the second process that need to perform message transmission.
[0098] Here, the related examples of the second shared memory can be referred to the above description, which will not be described again.
[0099] Step S702: in the case that the first process generates a notification message, writing, by the first process, the message content of the notification message to the at least one memory buffer.
[0100] Step S703: in the case that the first process needs to transmit the notification message, serializing, by the first process, the storage address of the notification message and writing it to the first shared memory, and writing, by the first process, the index information of the notification message to the first shared memory.
[0101] That is, in this example, the first shared memory stores the index information and the storage address of the notification message.
[0102] Step S704: in the case that the first process needs to transmit the notification message, storing, by the first process, the index information of the notification message to the third shared memory.
[0103] Here, the third shared memory is used to store the index information of the message that needs to be transmitted between different processes.
[0104] For example, as shown in FIG. 7(b), in the case that the first process needs to transmit the notification message, the index information of the notification message and the serialized storage address can be written into the first shared memory by using the first sending component of the first process, and meanwhile, the index information of the notification message can be written into the third shared memory by using the first sending component, so as to facilitate subsequent monitoring of the third shared memory, so as to ensure that the second process obtains the required notification message.
[0105] Step S705: monitoring the third shared memory to determine whether there is a notification message that needs to be transmitted to the second process.
[0106] Step S706: in the case that the index information of the notification message that needs to be transmitted to the second process is monitored, the storage address (such as a pointer) corresponding to the monitored index information is found 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, in this example, it can be determined according to the monitoring of the third shared memory whether there is a notification message that needs to be transmitted to the second process, and in the case that it is determined that there is a notification message that needs to be transmitted to the second process, such as 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 found from the first shared memory, and the storage address is transmitted to the second process, so as to facilitate the second process to obtain the message content of the notification message from the second shared memory according to the storage address, so as to improve the efficiency of cross-process data transmission and reduce the data transmission delay.
[0109] Step S707: transmitting the storage address of the notification message to the second process.
[0110] Step S708: obtaining the message content of the notification message from the second shared memory by the second process and using the storage address of the notification message.
[0111] In this way, the present solution does not need to copy the message content of the notification message multiple times, and also does not need to serialize and deserialize, so as to realize cross-process data transmission, so as to effectively improve the data transmission efficiency between processes, reduce the data transmission delay, save the computing resources required for inter-process communication, reduce the occupied storage space, and further reduce the overall burden of the system, thereby providing strong support for effectively saving the time required in the entire communication process.
[0112] For example, as shown in FIG. 7(b), in the case that the first process needs to transmit the notification message, the index information of the notification message and the serialized storage address can be written into the first shared memory by using the first sending component of the first process, and meanwhile, the index information of the notification message can be written into the third shared memory by using the first sending component, so as to facilitate subsequent monitoring of the third shared memory, so as to ensure that the second process obtains the required notification message. 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-applied memory buffer in the second shared memory. Further, in the case where the first process determines that the notification message needs to be transmitted, the first sending component in the first process is used to write the index information of the notification message into the memory block of the first shared memory, and write the serialized pointer into the memory buffer of the first shared memory. At the same time, the first process also writes the index information of the notification message into the third shared memory. Further, the second routing component is used to listen to the third shared memory to determine whether there is a notification message that needs to be transmitted to the second process. Further, after listening to 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. After the serialized pointer is deserialized, the deserialized pointer is transmitted to the second process, such as being sent to the second receiving component in the second process, so that the second process acquires 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 scheme has the following advantages:
[0114] First, low latency. The message transmission of the disclosed scheme can be delivered across processes with zero-copy, saving the processes required for serialization, deserialization, and copying, effectively reducing the message transmission delay.
[0115] Second, the pointer invalidation problem is solved. The disclosed scheme can use an allocator (such as a memory allocator based on a balanced binary tree) to ensure that the address spaces of different processes are mapped to the same address of a shared memory, thus effectively solving the pointer invalidation problem caused by different pointers during message transmission, and providing strong support for efficient inter-process message transmission.
[0116] Third, it is more versatile. The disclosed scheme can quickly improve an existing data transmission function and transform it into the data transmission mode described in the disclosed scheme, achieving inter-process message transmission based on "zero-copy", so it is versatile.
[0117] The disclosed scheme also provides a message transmission device, as shown in Figure 9 The device comprises:
[0118] The information writing unit 901 is configured to write the message feature information of the notification message into the first shared memory by the first process. The first shared memory is a memory space that can be accessed by the first process and the second process that need to perform message transmission.
[0119] The information reading unit 902 is configured to, when the second process needs to acquire the notification message, find the message characteristic information of the notification message from the first shared memory, and use the message characteristic information to enable the second process to acquire the message content of the notification message.
[0120] In a specific example of the present disclosure, the information writing unit is specifically configured to:
[0121] When the first process needs to transmit the notification message, the information writing unit writes the message characteristic information of the notification message into the first shared memory through the first process.
[0122] In a specific example of the present disclosure, the information writing unit is specifically configured to:
[0123] The information writing unit serializes the storage address of the notification message and writes it into the first shared memory through the first process.
[0124] In a specific example of the present disclosure, the information writing unit is further configured to:
[0125] The information writing unit writes the index information of the notification message into the first shared memory through the first process.
[0126] In a specific example of the present disclosure, the information writing unit is further configured to:
[0127] The information writing unit applies at least one memory buffer to 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 required to be sent by the first process.
[0128] The second shared memory is a memory space that can be accessed by the first process and the second process that need to transmit messages.
[0129] In a specific example of the present disclosure, 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 present disclosure, 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 based on the same target address allocated by the allocator.
[0133] In a specific example of the present disclosure, the information writing unit is further configured to:
[0134] In a 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 present disclosure, the storage address of the notification message at least includes a memory address of the notification message in the second shared memory.
[0136] In a specific example of the present disclosure, the memory address of the notification message in the second shared memory at least includes a pointer of 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 present disclosure, the information reading unit is specifically configured to:
[0138] The storage address of the notification message is found from the first shared memory by using the index information of the notification message;
[0139] The storage address of the notification message is transmitted to the second process;
[0140] The message content of the notification message is obtained from the second shared memory by the second process and by using the storage address of the notification message.
[0141] In a specific example of the present disclosure, the information writing unit is further configured to:
[0142] In a case where the first process needs to transmit the notification message, the index information of the notification message is stored into a third shared memory by the first process, and the third shared memory is used to store the index information of a message which needs to be transmitted between different processes.
[0143] In a specific example of the present disclosure, the information reading unit is further configured to:
[0144] The third shared memory is listened to to determine whether there is a notification message which needs to be transmitted to the second process.
[0145] In a specific example of the present disclosure, the information reading unit is specifically configured to:
[0146] In a case where the index information of the notification message which needs to be transmitted to the second process is listened to, the storage address corresponding to the listened index information is found from the first shared memory.
[0147] The specific functions and examples of the units of the apparatus of the present disclosure are described in the above method embodiments, and the related descriptions of the corresponding steps are referred to, and will not be described here.
[0148] In the technical solutions of the present disclosure, the acquisition, storage and application of user personal information are in line with relevant laws and regulations and do not violate public order and good customs.
[0149] According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0150] Figure 10 A schematic block diagram of an example electronic device 1000 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present disclosure described and / or claimed in this document.
[0151] As shown in Figure 10 The electronic device 1000 includes a computing unit 1001 that can perform various appropriate actions and processes in accordance with 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. Various programs and data required for the operation of the electronic device 1000 can also be stored in the RAM 1003. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0152] Various components in the electronic 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.; the storage unit 1008, such as magnetic disks, optical disks, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the electronic 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 can be various general purpose and / or special purpose processing components having 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 specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 performs various methods and processes described above, such as the message transmission method. For example, in some embodiments, the message transmission method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 1008. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded onto the RAM 1003 and executed by the computing unit 1001, one or more steps of the message transmission method described above can be performed. Alternatively, in other embodiments, the computing unit 1001 can be configured to perform the message transmission method by any other suitable means, such as by means of firmware.
[0154] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0155] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or the block diagrams. The program code can be entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine or server, or entirely on a remote machine or server.
[0156] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0157] To provide for interaction with a user, the systems and techniques described here 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 a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, 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, speech, or tactile input.
[0158] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can 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] The computer system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can 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 flow shown above can be used to reorder, add, or delete steps. For example, the steps described in the present disclosure can be performed in parallel, in series, or in a different order, as long as the desired results of the technology disclosed in the present disclosure can be achieved, which is not limited herein.
[0161] The above detailed description does not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the principles of the present disclosure should be included in the protection scope of the present disclosure.
Claims
1. A message transmission method, comprising: in a case where a first process generates a notification message, writing, by the first process, message content of the notification message into a memory buffer of a second shared memory; the memory buffer of the second shared memory is instantiated after the message content is written, so as to write message configuration information of the notification message into the instantiated message after receiving the message content of the notification message, to complete the writing of the message content; writing, by the first process, message feature information of the notification message into a first shared memory; the message feature information comprises serialized storage address of the notification message and index information of the notification message; the first shared memory comprises a first area for storing state information, a second area for storing index information, and a third area for storing storage address of the notification message; in a case where a second process needs to acquire the notification message, finding, from the first shared memory, the serialized storage address of the notification message by using the index information of the notification message; after deserializing the serialized storage address of the notification message, transmitting the deserialized storage address to the second process; acquiring, by the second process, the message content of the notification message from the second shared memory by using the storage address of the notification message.
2. The method of claim 1, wherein, the writing, by the first process, of the message feature information of the notification message into the first shared memory comprises: in a case where the first process needs to transmit the notification message, serializing, by the first process, the storage address of the notification message and writing the serialized storage address into the first shared memory. 3.The method of claim 2, further comprising: writing, by the first process, the index information of the notification message into the first shared memory. 4.The method of claim 2 or 3, further comprising: applying, by the first process, at least one memory buffer to the second shared memory; the at least one memory buffer is used to store at least message content of a notification message required to be sent by the first process; wherein the second shared memory is a memory space accessible by the first process and the second process which need to transmit messages.
5. The method of claim 4, wherein, the first process comprises a first address space, and the second process comprises 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.
6. The method of claim 5, wherein, the first address space comprises a first pointer instance, and the second address space comprises a second pointer instance; the first pointer instance and the second pointer instance are based on a same target address allocated by an allocator.
7. The method of claim 1 or 2 or 3, wherein, the storage address of the notification message at least comprises a memory address of the notification message in the second shared memory.
8. The method of claim 7, wherein, the memory address of the notification message in the second shared memory at least comprises a pointer of the notification message; wherein the pointer is used to indicate the memory address of the notification message in the second shared memory. 9.The method of claim 1 or 2 or 3, further comprising: in a case where the first process needs to transmit the notification message, storing, by the first process, the index information of the notification message into a third shared memory; the third shared memory is used to store index information of messages required to be transmitted between different processes. 10.The method of claim 9, further comprising: listening to the third shared memory to determine whether there is a notification message that needs to be transmitted to the second process.
11. The method of claim 10, wherein, The index information of the notification message is used to find the serialized storage address of the notification message in the first shared memory, including: In the case of listening to the index information of the notification message that needs to be transmitted to the second process, the storage address corresponding to the listened index information is found in the first shared memory.
12. A message transmission device, comprising: An information writing unit, configured to write the message content of the notification message into the memory buffer of the second shared memory by the first process in the case of generating the notification message by the first process; The memory buffer of the second shared memory is instantiated after the message, so as to write the message configuration information of the notification message into the instantiated message after receiving the message content of the notification message, to complete the writing of the message content; The message feature information of the notification message is written into the first shared memory by the first process; The message feature information includes the serialized storage address of the notification message and the index information of the notification message; the first shared memory includes a first area for storing state information, a second area for storing index information, and a third area for storing the storage address of the notification message; in the case of needing to obtain the notification message by the second process, the serialized storage address of the notification message is found in the first shared memory by using the index information of the notification message; the serialized storage address of the notification message is deserialized and transmitted to the second process; the message content of the notification message is obtained from the second shared memory by the second process and using the storage address of the notification message; An information reading unit, configured to find the storage address of the notification message in the first shared memory by using the index information of the notification message in the case of needing to obtain the notification message by the second process; the storage address of the notification message is transmitted to the second process; the message content of the notification message is obtained from the second shared memory by the second process and using the storage address of the notification message.
13. The apparatus of claim 12, wherein, The information writing unit is specifically configured to: In the case of needing to transmit the notification message by the first process, the storage address of the notification message is serialized and written into the first shared memory by the first process.
14. The apparatus of claim 13, wherein, The information writing unit is further configured to: The index information of the notification message is written into the first shared memory by the first process.
15. The apparatus of claim 13 or 14, wherein, The information writing unit is further configured to: At least one memory buffer is applied to the second shared memory by the first process; the at least one memory buffer is used to store at least the message content of the notification message required to be sent by the first process; The second shared memory is a memory space that can be accessed by the first process and the second process that need to perform message transmission.
16. The apparatus of claim 15, 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.
17. The apparatus of claim 16, 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 based on the same target address allocated by the allocator.
18. The apparatus of claim 12 or 13 or 14, wherein, The storage address of the notification message at least includes a memory address of the notification message in the second shared memory.
19. The apparatus of claim 18, wherein, The memory address of the notification message in the second shared memory at least includes a pointer of the notification message, wherein the pointer is used to indicate the memory address of the notification message in the second shared memory.
20. The apparatus of claim 12 or 13 or 14, wherein, The information writing unit is further configured to: In a case where the first process needs to transmit the notification message, store index information of the notification message to a third shared memory by the first process, the third shared memory being used to store index information of a message needing to be transmitted between different processes.
21. The apparatus of claim 20, wherein, The information reading unit is further configured to: Listen to the third shared memory to determine whether there is a notification message needing to be transmitted to the second process.
22. The apparatus of claim 21, wherein, The information reading unit is specifically configured to: In a case where the index information of the notification message needing to be transmitted to the second process is listened to, find the storage address corresponding to the listened index information from the first shared memory. 23.An electronic device comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-11.
24. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method according to any one of claims 1-11. 25.A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-11.
Citation Information
Patent Citations
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