Communication method and device for application data
By creating shared memory and resident agent processes in the central processor, decoupling processes and caches, low-occupancy transmission of application data is achieved, solving the problem of low application data communication efficiency in the existing technology, reducing CPU occupancy and Application server energy consumption.
Patent Information
- Application Number
- CN202410638870.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-09-17
AI Technical Summary
The communication efficiency of existing application data is low, resulting in high CPU usage of the central processing unit, which cannot meet the communication processing needs of high-performance systems, and greatly increases the communication energy consumption of the application server.
By creating a shared memory for storing application communication messages and a resident agent process for performing communication message transmission, the process and cache are decoupled to achieve low-occupancy transmission of messages. Specific steps include creating shared memory and resident agent processes in the central processor, splitting and storing messages through virtual communication channels and sending buffers, and transmitting messages to the preloading library through the resident agent process.
It greatly reduces the CPU occupancy rate and meets the communication processing needs of high-performance systems, thus reducing the communication energy consumption of the application server.
Smart Images

Figure CN118656231A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a communication method and device for application data. Background Art
[0002] As applications become more popular in all walks of life, data communication of applications is the process of sending data generated in applications to servers for processing, which is usually done using network protocols within the operating system and remote direct memory access technology.
[0003] At present, the communication of existing application data usually starts a preload library for each application, thereby occupying a central processing unit CPU. However, the use of a preload library will make the central processing unit CPU occupancy reach 100%, and the use of n preload libraries will make the central processing unit CPU occupancy reach n*100%, resulting in a high CPU occupancy rate, which cannot meet the communication processing requirements of high-performance systems, greatly reduces the data processing efficiency of the central processing unit CPU, and also greatly increases the communication energy consumption of the application server. Summary of the invention
[0004] In view of this, the present invention provides a method and device for communicating application data, the main purpose of which is to solve the problem of low efficiency of existing application data communication.
[0005] According to one aspect of the present invention, there is provided a method for communicating application data, comprising:
[0006] Creating a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages;
[0007] When different applications generate application data, each communication message carrying the application data is stored in the shared memory;
[0008] The target communication message to be transmitted in the shared memory is retrieved, and the target communication message carrying the target application data is transmitted to the preload library through the resident agent process for taking over, so that the target communication message is transmitted through the preload library.
[0009] Further, the creating a shared memory for storing communication messages of at least one application and a resident agent process for executing the communication message transmission includes:
[0010] Creating a virtual communication channel matching at least one application, each of the virtual communication channels being associated with a transceiver interface of the application;
[0011] Creating a shared memory in a central processing unit, and configuring each of the virtual communication channels with a memory file of the shared memory;
[0012] A resident agent process is created in the central processing unit, wherein the resident agent process includes at least one sending thread and at least one receiving thread.
[0013] Further, storing each communication message carrying the application data in the shared memory includes:
[0014] transmitting the communication message carrying the application data to a target memory file of the shared memory through the virtual communication channel;
[0015] The communication message and the application data are stored in a sending buffer area according to the target memory file.
[0016] Further, storing the communication message and the application data in the sending buffer area according to the target memory file includes:
[0017] When the data length of the application data is greater than the buffer length of the sending buffer area, the communication message and the application data are split to obtain at least two message headers corresponding to the communication message and at least two message fragments corresponding to the application data;
[0018] The message header and the message fragments are stored in the sending buffer area respectively according to the message type.
[0019] Further, storing the message header and the message fragments in the sending buffer area respectively according to the message type includes:
[0020] Determine the cache position where the message header and the message fragment are stored in the sending buffer area according to the message type and the data position offset modulo method of the sending buffer area, wherein the cache position has a cyclic coverage function;
[0021] The retrieving the target communication message to be transmitted in the shared memory comprises:
[0022] Communication messages are selected in sequence according to the buffer positions of the sending buffer area, and are combined based on the message header and the message fragment to determine the target communication message to be transmitted.
[0023] Further, the transmitting the target communication message to the preload library for taking over by the resident agent process includes:
[0024] Based on the sending thread in the resident agent process, the target communication message is transmitted to the preloading library, and the preloading library is instructed to send the target communication message carrying the target application data to the application server through the target network card.
[0025] Furthermore, the method further comprises:
[0026] When at least one feedback result corresponding to different application data is received through the preload library, the feedback result is stored in the receiving buffer area in the shared memory through the receiving thread in the resident agent process;
[0027] The target feedback result of the receiving buffer area is retrieved, and the target feedback result is fed back to the application.
[0028] According to another aspect of the present invention, there is provided a communication device for application data, comprising:
[0029] A creation module, used to create a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages;
[0030] A storage module, used for storing each communication message carrying the application data in the shared memory when different application programs generate application data;
[0031] The sending module is used to retrieve the target communication message to be transmitted in the shared memory, and transmit the target communication message carrying the target application data to the preload library through the resident agent process for taking over, so that the target communication message can be transmitted through the preload library.
[0032] Furthermore, the creation module is specifically used to create a virtual communication channel matching at least one application, each of the virtual communication channels is associated with the transceiver interface of the application; create a shared memory in the central processing unit, and configure each of the virtual communication channels with the memory file of the shared memory; create a resident agent process in the central processing unit, and the resident agent process includes at least one sending thread and at least one receiving thread.
[0033] Furthermore, the storage module includes:
[0034] A transmission unit, configured to transmit the communication message carrying the application data to a target memory file of the shared memory through the virtual communication channel;
[0035] A storage unit is used to store the communication message and the application data according to the sending buffer area of the target memory file.
[0036] Furthermore, the storage unit is specifically used to split the communication message and the application data when the data length of the application data is greater than the cache length of the sending buffer area, so as to obtain at least two message headers corresponding to the communication message and at least two message fragments corresponding to the application data; and store the message header and the message fragments in the sending buffer area according to the message type.
[0037] Further, the storage unit is specifically used to determine the cache position where the message header and the message fragment are stored in the sending buffer area according to the message type and the data position offset modulus of the sending buffer area, and the cache position has a cyclic coverage function;
[0038] The sending module is specifically configured to select communication messages in sequence according to the buffer positions of the sending buffer area, and combine the message headers and the message fragments to determine the target communication message to be transmitted.
[0039] Furthermore, the sending module is also used to transmit the target communication message to the preloading library based on the sending thread in the resident agent process, and instruct the preloading library to send the target communication message carrying the target application data to the application server through the target network card.
[0040] Furthermore, the device further comprises: a feedback module,
[0041] The storage module is further configured to store the feedback result in the receiving buffer area in the shared memory through the receiving thread in the resident agent process when at least one feedback result corresponding to different application data is received through the preload library;
[0042] The feedback module is used to retrieve the target feedback result of the receiving buffer area and feed the target feedback result back to the application.
[0043] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable message is stored in the storage medium, and the executable message enables a processor to execute an operation corresponding to the above-mentioned application data communication method.
[0044] According to another aspect of the present invention, there is provided a terminal, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0045] The memory is used to store at least one executable message, and the executable message enables the processor to execute an operation corresponding to the above-mentioned application data communication method.
[0046] By means of the above technical solution, the technical solution provided by the embodiment of the present invention has at least the following advantages:
[0047] The present invention provides a communication method and device for application data. Compared with the prior art, the embodiment of the present invention creates a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages; when different applications generate application data, each communication message carrying the application data is stored in the shared memory; the target communication message to be transmitted in the shared memory is retrieved, and the target communication message carrying the target application data is transmitted to a preload library through the resident agent process for taking over, so that the target communication message is transmitted through the preload library, and low-occupancy transmission of messages is achieved through decoupling between processes and caches, which greatly reduces the occupancy rate of the CPU and meets the communication processing requirements of high-performance systems, thereby greatly reducing the communication energy consumption of application servers.
[0048] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0050] Figure 1 A flow chart of a communication method for application data provided by an embodiment of the present invention is shown;
[0051] Figure 2 A schematic diagram of message splitting provided by an embodiment of the present invention is shown;
[0052] Figure 3 A communication message transmission flow chart provided by an embodiment of the present invention is shown;
[0053] Figure 4 A block diagram showing the composition of a communication device for application data provided by an embodiment of the present invention is shown;
[0054] Figure 5 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0055] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0056] The embodiment of the present invention provides a communication method for application data, such as Figure 1 As shown, the method includes:
[0057] 101. Create a shared memory for storing communication messages of at least one application and a resident agent process for executing transmission of the communication messages.
[0058] In the embodiment of the present invention, since the application refers to a computer program for completing one or more specific tasks, when the user performs interactive operations in the front-end interface of the application, application data will be generated. At this time, the front end will generate a communication message to send the application to the application server for processing. As the current execution end, it can be a mobile terminal on which the application is installed, such as a mobile phone, a tablet computer, etc., and the embodiment of the present invention does not make specific limitations. At this time, as the front-end device of the execution end, a shared memory is created in the current execution end to store the communication messages for data transmission after the application generates the application data. At the same time, a resident agent process for executing the communication message transmission is created. This resident agent process is dedicated to transmitting the communication messages of the application and does not perform other operations. The embodiment of the present invention does not make specific limitations.
[0059] 102. When different application programs generate application data, each communication message carrying the application data is stored in the shared memory.
[0060] In an embodiment of the present invention, in the current execution end, when different applications generate application data, communication messages that need to transmit the application will be generated. At this time, different applications correspond to different communication messages, and all communication messages are stored in the shared memory so as to serve as a memory environment for storing communication messages together. In addition, in the shared memory, different communication messages can be sorted and stored according to the order or time of storage, and stored cyclically by covering the sorting position, so as to achieve the purpose of efficient caching of the shared memory. Among them, the sorting position covering method is to set a specified number of storage positions, and then sort and store them from beginning to end. When the storage is to the last position, when the communication message is stored again, the data at the first position is overwritten and stored. At this time, the communication message at the first position has been transmitted, so as to achieve the purpose of low memory occupancy.
[0061] 103. Retrieve the target communication message to be transmitted in the shared memory, and transmit the target communication message carrying the target application data to the preload library through the resident agent process for taking over, so that the target communication message is transmitted through the preload library.
[0062] In an embodiment of the present invention, after storing the communication message, since all the communication messages to be transmitted are stored in the shared memory, in order to avoid the transmission of data causing congestion in the system transmission channel, the current execution end can sequentially retrieve the target communication message in the shared memory, and start the resident proxy process as the message to be transmitted to transmit the target communication message carrying the target application data to the preload library. Among them, the preload library is a database for realizing application data preloading, and can transmit the received target communication message through the Internet. Among them, the preload library can realize data transmission through the Internet provided by the high-performance network card, and the embodiment of the present invention does not make specific limitations.
[0063] The embodiment of the present invention provides a communication method for application data, which realizes low-occupancy transmission of messages by decoupling the process and the cache, greatly reduces the CPU occupancy rate, meets the communication processing requirements of high-performance systems, and thus greatly reduces the communication energy consumption of the application server.
[0064] In another embodiment of the present invention, for further definition and explanation, the step of creating a shared memory for storing communication messages of at least one application and a resident agent process for performing the transmission of the communication messages includes:
[0065] creating a matching virtual communication channel with at least one application;
[0066] Creating a shared memory in a central processing unit, and configuring each of the virtual communication channels with a memory file of the shared memory;
[0067] A resident agent process is created in the central processing unit.
[0068] Decouple the application from the proxy process, thereby reducing the system operation occupancy rate. When the current execution end creates the shared memory and the resident proxy process, specifically, first create a virtual communication channel in the current execution end. At this time, the virtual communication channel is used to represent the virtual path for the application to transmit to the shared memory, and the embodiment of the present invention does not make specific limitations. Among them, each virtual communication channel is associated with the transceiver interface of the application, that is, each channel is associated with the sending end of an application and the receiving end of an application, and an application can be associated with multiple channels. When creating a channel, the channel name can be used, or a service name with business value can be used as the file name of the created shared memory mmap, so that each channel corresponds to a shared memory mmap file, and communicates with the resident proxy process, so that the two applications use the same channel name to communicate, so that the resident proxy process can distinguish different data streams in different applications.
[0069] It should be noted that when creating shared memory, the current execution end selects a cache space in a central processing unit CPU to create shared memory, and at the same time, configures each virtual communication channel and the memory file of the shared memory, that is, each channel can correspond to an mmap file and be named separately, which is not specifically limited in the embodiment of the present invention. At the same time, a resident proxy process is created in the central processing unit CPU, including at least one sending thread and at least one receiving thread, a sending thread can be dedicated to the message sending of an application, a receiving thread can be dedicated to the message receiving of an application, and different applications correspond to a group of dedicated receiving threads and sending threads, which is not specifically limited in the embodiment of the present invention.
[0070] In another embodiment of the present invention, for further definition and explanation, the step of storing each communication message carrying the application data into the shared memory includes:
[0071] transmitting the communication message carrying the application data to a target memory file of the shared memory through the virtual communication channel;
[0072] The communication message and the application data are stored in a sending buffer area according to the target memory file.
[0073] Shared memory is the communication medium between the application and the resident agent process. In order to improve the efficiency of using shared memory for caching, when the current execution end stores the communication message in the shared memory, specifically, first determine the target memory file in the shared memory associated with the communication message of the generated application through the virtual communication channel. For example, the sending end of application a is associated with the virtual communication channel s, and when creating the shared memory, a memory file in the shared memory is named s. After application a generates application data, the communication message carrying the application data is stored in the memory file named s through the s channel.
[0074] In addition, in order to accurately distinguish between sending and receiving messages and thus improve the transmission efficiency of communication messages, the current execution end divides the cache area of the memory file into a sending cache area and a receiving cache area, so that when storing, the communication messages and application data are stored in the sending cache area to ensure the security of multi-threaded reading and writing.
[0075] It should be noted that when storing in the sending buffer area, it can be stored in sequence according to the timestamp or communication message identifier. At the same time, a fixed-size buffer area is set, and it is stored in a sorted position overwriting manner according to the timestamp or identifier. That is, after setting a specified number of storage positions, it is sorted and stored from the beginning to the end. When it is stored to the last position, when the communication message is stored again, the data at the first position is overwritten and stored, thereby forming a circular buffer area. The embodiment of the present invention does not make specific limitations.
[0076] In another embodiment of the present invention, for further definition and explanation, the step of storing the communication message and the application data in the sending buffer area of the target memory file includes:
[0077] When the data length of the application data is greater than the buffer length of the sending buffer area, the communication message and the application data are split to obtain at least two message headers corresponding to the communication message and at least two message fragments corresponding to the application data;
[0078] The message header and the message fragments are stored in the sending buffer area respectively according to the message type.
[0079] In order to improve the storage efficiency of application data in shared memory, due to the limited storage space of the buffer area, such as creating 2MB, and the transport layer adopts TCP and UDP protocols, when the message size exceeds the MTU (Maximum Transmission Unit) of the network layer, it is necessary to split and reassemble the network layer IP packet. However, the transport layer UDP protocol does not provide reliable guarantee of messages. When any IP packet is lost, it will cause the failure of sending the entire message, which is also called packet loss of UDP messages. Therefore, when the current execution end stores the application data and the corresponding communication message in the sending buffer area, it first determines whether the data length of the application data is greater than the buffer length of the sending buffer area. If it is greater, the communication message and the application data are split to obtain at least two message headers corresponding to the communication message and at least two message fragments corresponding to the application data. Among them, the message header-message fragment (header-body) mode is used in the current parent execution end to split and decorate the message, and the receiving end classifies and reassembles the message according to the message header, thereby completing a message transmission. Figure 2 As shown, when the data length is greater than the cache length of the sending buffer, the communication message and the application data are split to obtain at least two message headers corresponding to the communication message and at least two message fragments corresponding to the application data, so that the message header and the message fragment are stored in the sending buffer according to the message type, wherein the message type includes control messages and data messages, the control messages are used for connection establishment and status maintenance, and the data messages are used for actual message transmission, which is not specifically limited in the embodiments of the present invention.
[0080] In another embodiment of the present invention, for further definition and explanation, the step of storing the message header and the message fragment in the sending buffer area according to the message type includes:
[0081] The cache positions where the message header and the message fragments are stored in the sending buffer area are determined according to the message type and the data position offset modulo the sending buffer area.
[0082] In order to achieve low cache occupancy, when the message header and the message fragment are stored in the sending buffer area according to the message type, specifically, the cache position where the message header and the message fragment are stored in the sending buffer area is determined according to the message type and the data position offset modulus of the sending buffer area, wherein the cache position has a cyclic coverage function. In a specific application scenario, specifically, during the storage process, the purpose of cyclic use of a section of memory can be achieved by taking the modulus of the data offset position, such as configuring a 1MB (1024*1024B) cache area, for each application data of 1KB (1024B) in size, 1024 data can be buffered, and after the cache area is full, the cache position of the application data transmitted to is re-determined to 1, and the next 1024 data are re-circulated and covered. The embodiment of the present invention does not make specific limitations. At the same time, the cache area is also a tool for data sequence arrangement and packet loss detection. When there is only one sending thread and one receiving thread, the cache area can use atomic variables in the computer to identify the location of current data production and consumption, thereby ensuring that there is no thread safety problem for the two threads. In addition, since it is not necessary to apply for and release memory for each message, and it is not necessary to call the system to lock and unlock, the current execution end is very efficient in executing message storage. When there are multiple sending threads, CAS technology can also be used to make multiple attempts to update the location of production and messages through a while loop until success, so as to ensure the thread safety of multiple threads and improve the performance of system message transmission.
[0083] Correspondingly, the retrieving the target communication message to be transmitted in the shared memory includes:
[0084] Communication messages are selected in sequence according to the buffer positions of the sending buffer area, and are combined based on the message header and the message fragment to determine the target communication message to be transmitted.
[0085] At this time, when it is necessary to retrieve the target communication message for transmission, the communication message can be directly selected in sequence according to the cache position of the sending buffer area, and the target communication message to be transmitted can be determined based on the message header and the message fragment. The combination is performed to determine the target communication message to be transmitted, and the message is transmitted to the sending thread in the resident proxy process. In an embodiment of the present invention, the resident proxy process can interact with the shared memory, and can also interact with the network card through the preload library to achieve the transmission of the message. Among them, when selecting the target communication message, the currently established channel can also be determined by traversing the memory file, and then the sending message of each cache position in the cache area in the shared memory corresponding to the channel is obtained, the message type is parsed to perform the corresponding application data operation content, and the preload library is used to create a socket connection, send data, detect packet loss, request retransmission, send status messages and heartbeat messages, etc. to achieve the transmission of the message, which is not specifically limited in the embodiment of the present invention.
[0086] In another embodiment of the present invention, for further definition and explanation, the step of transmitting the target communication message to the preload library for taking over by the resident agent process includes:
[0087] Based on the sending thread in the resident agent process, the target communication message is transmitted to the preloading library, and the preloading library is instructed to send the target communication message carrying the target application data to the application server through the target network card.
[0088] Since the resident proxy process includes a sending thread and a receiving thread, in order to achieve efficient transmission of communication messages, when the current execution end transmits the target communication message through the resident proxy process, specifically, the target communication message is transmitted to the preload library based on the sending thread.
[0089] In another embodiment of the present invention, for further definition and description, the steps further include:
[0090] When at least one feedback result corresponding to different application data is received through the preload library, the feedback result is stored in the receiving buffer area in the shared memory through the receiving thread in the resident agent process;
[0091] The target feedback result of the receiving buffer area is retrieved, and the target feedback result is fed back to the application.
[0092] In order to realize the message receiving and sending functions of the application and reduce the system occupancy rate, the current execution end is pre-configured with a user-callable interface to achieve the purpose of creating channels, destroying channels, sending messages to channels, receiving messages from channels, etc. In a specific implementation scenario, after the communication message is transmitted to the application server through the preload library and the Internet, the feedback result can be received, and the feedback result can be stored in the receiving buffer area in the shared memory through the receiving thread in the resident proxy process, such as Figure 3 As shown. Among them, for the reception of communication messages, the created receiving thread is used for transmission, and the communication messages can be collected through a while loop. Different idle waiting strategies can also be adopted according to the latency requirements of the communication messages, etc., which are not specifically limited in the embodiments of the present invention. In addition, for scenarios with very high latency requirements, a mode of no waiting and always busy running can be adopted. In this mode, the receiving thread can be bound to an independent CPU and will occupy 100% of the CPU to achieve the lowest latency. When the latency requirements are low, or during non-business peak hours, the system can be called to wait through interfaces such as sleep, usleep, and nanosleep, thereby greatly reducing the use of the CPU.
[0093] It should be noted that for the receiving end of the application of the channel associated with the receiving buffer, the receiving port of different channels can be monitored to obtain the feedback result of the received message from the interface of the preloaded library, and then written into the shared memory buffer corresponding to the channel. At this time, since the responsibilities of the resident agent process are relatively simple, the code does not change frequently and is relatively stable. The resident agent process will not have a single point of problem caused by application crashes. In order to deal with extreme situations, the current execution end can be monitored by systemd or shell scripts. When the application stops running, it can be automatically restarted. At this time, all message states are saved in shared memory. Therefore, work can be resumed after restarting, which greatly improves the work efficiency of the system.
[0094] An embodiment of the present invention provides another communication method for application data. Compared with the prior art, the embodiment of the present invention creates a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages; when different applications generate application data, each communication message carrying the application data is stored in the shared memory; the target communication message to be transmitted in the shared memory is retrieved, and the target communication message carrying the target application data is transmitted to a preload library through the resident agent process for takeover, so that the target communication message is transmitted through the preload library, and through the decoupling between the process and the cache, low-occupancy transmission of the message is achieved, the CPU occupancy rate is greatly reduced, the communication processing requirements of the high-performance system are met, and the communication energy consumption of the application server is greatly reduced.
[0095] Furthermore, as a response to the above Figure 1 The embodiment of the present invention provides a communication device for application data, such as Figure 4 As shown, the device comprises:
[0096] A creation module 21, used to create a shared memory for storing communication messages of at least one application and a resident agent process for executing the communication message transmission;
[0097] The storage module 22 is used for storing each communication message carrying the application data in the shared memory when different application programs generate application data;
[0098] The sending module 23 is used to retrieve the target communication message to be transmitted in the shared memory, and transmit the target communication message carrying the target application data to the preload library through the resident agent process for taking over, so that the target communication message is transmitted through the preload library.
[0099] Furthermore, the creation module is specifically used to create a virtual communication channel matching at least one application, each of the virtual communication channels is associated with the transceiver interface of the application; create a shared memory in the central processing unit, and configure each of the virtual communication channels with the memory file of the shared memory; create a resident agent process in the central processing unit, and the resident agent process includes at least one sending thread and at least one receiving thread.
[0100] Furthermore, the storage module includes:
[0101] A transmission unit, configured to transmit the communication message carrying the application data to a target memory file of the shared memory through the virtual communication channel;
[0102] A storage unit is used to store the communication message and the application data according to the sending buffer area of the target memory file.
[0103] Furthermore, the storage unit is specifically used to split the communication message and the application data when the data length of the application data is greater than the cache length of the sending buffer area, so as to obtain at least two message headers corresponding to the communication message and at least two message fragments corresponding to the application data; and store the message header and the message fragments in the sending buffer area according to the message type.
[0104] Further, the storage unit is specifically used to determine the cache position where the message header and the message fragment are stored in the sending buffer area according to the message type and the data position offset modulus of the sending buffer area, and the cache position has a cyclic coverage function;
[0105] The sending module is specifically configured to select communication messages in sequence according to the buffer positions of the sending buffer area, and combine the message headers and the message fragments to determine the target communication message to be transmitted.
[0106] Furthermore, the sending module is also used to transmit the target communication message to the preloading library based on the sending thread in the resident agent process, and instruct the preloading library to send the target communication message carrying the target application data to the application server through the target network card.
[0107] Furthermore, the device further comprises: a feedback module,
[0108] The storage module is further configured to store the feedback result in the receiving buffer area in the shared memory through the receiving thread in the resident agent process when at least one feedback result corresponding to different application data is received through the preload library;
[0109] The feedback module is used to retrieve the target feedback result of the receiving buffer area and feed the target feedback result back to the application.
[0110] An embodiment of the present invention provides a communication device for application data. Compared with the prior art, the embodiment of the present invention creates a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages; when different applications generate application data, each communication message carrying the application data is stored in the shared memory; the target communication message to be transmitted in the shared memory is retrieved, and the target communication message carrying the target application data is transmitted to a preload library through the resident agent process for takeover, so that the target communication message is transmitted through the preload library, and through the decoupling between the process and the cache, low-occupancy transmission of the message is achieved, the CPU occupancy rate is greatly reduced, the communication processing requirements of the high-performance system are met, and the communication energy consumption of the application server is greatly reduced.
[0111] According to an embodiment of the present invention, a storage medium is provided, wherein the storage medium stores at least one executable message, and the computer executable message can execute the communication method of application data in any of the above method embodiments.
[0112] Figure 5 A schematic diagram of the structure of a terminal provided according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the terminal.
[0113] like Figure 5 As shown, the terminal may include: a processor (processor) 302 , a communication interface (Communications Interface) 304 , a memory (memory) 306 , and a communication bus 308 .
[0114] The processor 302 , the communication interface 304 , and the memory 306 communicate with each other via the communication bus 308 .
[0115] The communication interface 304 is used to communicate with other devices such as clients or other servers.
[0116] The processor 302 is used to execute the program 310, and specifically can execute the relevant steps in the above-mentioned application data communication method embodiment.
[0117] Specifically, the program 310 may include program code including computer operation messages.
[0118] The processor 302 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. The one or more processors included in the terminal may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0119] The memory 306 is used to store the program 310. The memory 306 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0120] The program 310 may be specifically configured to enable the processor 302 to perform the following operations:
[0121] Creating a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages;
[0122] When different applications generate application data, each communication message carrying the application data is stored in the shared memory;
[0123] The target communication message to be transmitted in the shared memory is retrieved, and the target communication message carrying the target application data is transmitted to the preload library through the resident agent process for taking over, so that the target communication message is transmitted through the preload library.
[0124] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0125] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A communication method for application data, characterized in that: include: Creating a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages; When different applications generate application data, each communication message carrying the application data is stored in the shared memory; The target communication message to be transmitted in the shared memory is retrieved, and the target communication message carrying the target application data is transmitted to the preload library through the resident agent process for taking over, so that the target communication message is transmitted through the preload library.
2. The method according to claim 1, characterized in that The step of creating a shared memory for storing communication messages of at least one application and a resident agent process for executing the communication message transmission includes: Creating a virtual communication channel matching at least one application, each of the virtual communication channels being associated with a transceiver interface of the application; Creating a shared memory in a central processing unit, and configuring each of the virtual communication channels with a memory file of the shared memory; A resident agent process is created in the central processing unit, wherein the resident agent process includes at least one sending thread and at least one receiving thread.
3. The method according to claim 2, characterized in that The storing each communication message carrying the application data into the shared memory comprises: transmitting the communication message carrying the application data to a target memory file of the shared memory through the virtual communication channel; The communication message and the application data are stored in a sending buffer area according to the target memory file.
4. The method according to claim 3, characterized in that The storing of the communication message and the application data in the sending buffer area of the target memory file comprises: When the data length of the application data is greater than the buffer length of the sending buffer area, the communication message and the application data are split to obtain at least two message headers corresponding to the communication message and at least two message fragments corresponding to the application data; The message header and the message fragments are stored in the sending buffer area respectively according to the message type.
5. The method according to claim 4, characterized in that The storing the message header and the message fragments in the sending buffer area respectively according to the message type includes: Determine the cache position where the message header and the message fragment are stored in the sending buffer area according to the message type and the data position offset modulo method of the sending buffer area, wherein the cache position has a cyclic coverage function; The retrieving the target communication message to be transmitted in the shared memory comprises: Communication messages are selected in sequence according to the buffer positions of the sending buffer area, and are combined based on the message header and the message fragment to determine the target communication message to be transmitted.
6. The method according to claim 2, characterized in that The transmitting of the target communication message to the preload library for taking over by the resident agent process includes: Based on the sending thread in the resident agent process, the target communication message is transmitted to the preloading library, and the preloading library is instructed to send the target communication message carrying the target application data to the application server through the target network card.
7. The method according to claim 1, characterized in that The method further comprises: When at least one feedback result corresponding to different application data is received through the preload library, the feedback result is stored in the receiving buffer area in the shared memory through the receiving thread in the resident agent process; The target feedback result of the receiving buffer area is retrieved, and the target feedback result is fed back to the application.
8. A communication device for application data, characterized in that: include: A creation module, used to create a shared memory for storing communication messages of at least one application and a resident agent process for executing the transmission of the communication messages; A storage module, used for storing each communication message carrying the application data in the shared memory when different application programs generate application data; The sending module is used to retrieve the target communication message to be transmitted in the shared memory, and transmit the target communication message carrying the target application data to the preload library through the resident agent process for taking over, so that the target communication message can be transmitted through the preload library.
9. A storage medium storing at least one executable message, wherein the executable message enables a processor to execute an operation corresponding to the method for communicating application data according to any one of claims 1 to 7.
10. A terminal, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable message, and the executable message enables the processor to execute an operation corresponding to the communication method for application data according to any one of claims 1 to 7.
