A method and device for accelerating network communication

By using dual-ring lock-free queues to exchange data in shared memory in a cloud computing environment, the problems of limited data transmission rate and insufficient bandwidth utilization in traditional network communications are solved, and efficient network acceleration and flexible communication switching are achieved.

CN118555162BActive Publication Date: 2024-09-27CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411025634.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-09-27
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

The data transmission rate of traditional network communications is greatly affected by network performance fluctuations, and Ethernet transmission limitations limit the size of a single message sent, making it impossible to effectively utilize network bandwidth.

Method used

Through the interconnection bus technology, a double-ring lock-free queue is used to exchange data in the shared memory. The sender module detects the arrival of data through an adaptive polling strategy, thereby achieving fast transmission and reception of data.

Benefits of technology

In a cloud computing environment, the interconnection bus replaces the traditional network to achieve network acceleration, improve system utilization, and switch back to traditional network communication in environments that do not support the interconnection bus.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118555162B
    Figure CN118555162B
Patent Text Reader

Abstract

The present invention relates to a method and device for accelerating network communication, the method comprising: a receiving module applies for a dual-loop lock-free queue of a receiving module from a daemon process module when bind; a sending module generates a port number when executing sendmsg, and sends the IP and port number of the sending module to the daemon process module to apply for a dual-loop lock-free queue of the sending module; when a thread of the sending module sends data to the receiving module, the data is written to the dual-loop lock-free queue of the receiving module; recvfrom of the receiving module executes that the receiving module thread reads the dual-loop lock-free queue of the receiving module and processes the data, and writes the data to be replied to the dual-loop lock-free queue corresponding to the port number of the sending module to be returned; and the sending module thread reads the dual-loop lock-free queue of the sending module to obtain the data of the receiving module. In the present invention, the receiving module writes the data into the shared memory, and the sending module reads the data from the shared memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of accelerating network communications, and in particular, relates to a method and device for accelerating network communications. Background Art

[0002] Traditional socket-based network communications, such as TCP and UDP communications, need to go through the seven-layer network model to send a piece of data. The data needs to go from user mode to kernel mode, and finally pass through the network card to send the data. Even through RDMA, the data needs to be written into the data buffer of the sender module first, and then transmitted to the data buffer of the receiver module. Finally, the application of the receiver module takes out the data from the receiving buffer for use. This leads to the following two problems. The first is that the rate of data transmission is greatly affected by the fluctuation of network performance. The second is that due to the electrical limitations of Ethernet transmission, the maximum transmission cannot exceed 1518 bytes. Therefore, the single message sent by traditional socket communication is generally not too large, because once it exceeds 1518 bytes, the bottom layer needs to be fragmented. In addition, taking UDP as an example, there are 2 bytes to represent the length of the single data sent, which limits the single data transmission to no more than 65535 bytes (plus the message header).

[0003] The use of interconnect bus technology (including but not limited to CXL, as long as it can support multiple machines reading and writing the same shared memory and supports cache consistency, this solution can be used) can enable virtual machines opened through cloud computing technology to share a specific large memory space. Then, through some special solutions, the traditional network can be replaced by reading and writing shared memory based on the interconnect bus. Therefore, the traditional network communication caused by the above two problems can have a lot of room for optimization in the field of cloud computing using the interconnect bus technology. Summary of the invention

[0004] In view of the above-mentioned deficiencies in the prior art, the purpose of the invention is to provide a method, device, electronic device and storage medium for accelerating network communication. The receiving module writes data into the shared memory, and the sending module detects the arrival of data through an adaptive polling strategy and reads the corresponding data from a specific shared memory address to complete the sending and receiving of data.

[0005] In a first aspect of the present invention, a method for accelerating network communication is provided, which is applied to a system including: a first machine and a second machine connected to a shared memory via an interconnect bus, wherein the first machine includes: a daemon module, a kernel monitoring module and a receiver module, and the second machine includes: a daemon module, a kernel monitoring module and a sender module, and the method includes:

[0006] Write a so file shared library containing bind, sendmsg and recvfrom functions;

[0007] When binding, the receiver module applies to the daemon module for the receiver module's double-ring lock-free queue in the shared memory;

[0008] When the sender module executes sendmsg, it generates a port number, sends the sender module IP and port number to the daemon module, and applies for the sender module double-ring lock-free queue in the shared memory;

[0009] When the thread of the sender module sends data to the receiver module, the data is written to the dual-loop lock-free queue of the receiver module;

[0010] The recvfrom of the receiving module executes the receiving module thread to read the receiving module dual-loop lock-free queue and process the data, and write the data to be replied to the sending module dual-loop lock-free queue corresponding to the port number of the sending module to be returned;

[0011] The sender module thread detects the arrival of data through the adaptive polling strategy of the kernel monitoring module, and then reads the sender module dual-loop lock-free queue to obtain the data of the receiver module.

[0012] Furthermore, the above method for accelerating network communication further includes:

[0013] The sender module polls the sender module dual-loop lock-free queue at the specified time to see if there is any data arriving;

[0014] If the polling result is that there is no data arriving in the dual-ring lock-free queue of the sender module, the receiver module is mounted into the polling linked list of the daemon module, and the daemon module performs unified polling.

[0015] Furthermore, the above method for accelerating network communication further includes:

[0016] Determine whether the daemon module releases contact polling according to pre-set rules;

[0017] The pre-set rules are set according to the data of the sender module and the receiver module and the timestamp corresponding to the data.

[0018] Furthermore, in the above method for accelerating network communication, the daemon module performs unified polling in one of the following two ways:

[0019] The first method: periodically poll the dual-loop lock-free queues corresponding to the recvfrom that needs to be polled in the polling linked list to determine whether there is data arriving; if the polling result is that data has arrived, notify the corresponding recvfrom, and enter sleep when not polling;

[0020] The second method is to divide a 128-bit shared area in the shared memory, and each recvfrom in the daemon module corresponds to one of them. When mounted to the daemon module, the daemon module allocates it and modifies the dual-loop lock-free queue part corresponding to each IP and port in the shared memory, adding the corresponding number of bits; when the receiving module writes data, the corresponding number of bits is updated and set to 1; periodically read whether there is a bit set to 1 in the shared area. If there is a bit set to 1, wake up the daemon module for unified polling.

[0021] Furthermore, in the above-mentioned method for accelerating network communication, the recvfrom of the receiving module executes that the receiving module thread reads the receiving module dual-loop lock-free queue and processes the data, and the sending module thread detects the arrival of data through the adaptive polling strategy of the kernel monitoring module, and then reads the sending module dual-loop lock-free queue to obtain the data of the receiving module, and also includes:

[0022] Whether the dual-ring lock-free queue is readable is determined based on the size relationship between the head and tail of the dual-ring lock-free queue.

[0023] Furthermore, the above method for accelerating network communication further includes: the daemon module records the result of applying for the dual-loop lock-free queue of the receiver module and the dual-loop lock-free queue of the sender module into the shared memory;

[0024] When the receiver module and the sender module apply for the dual-ring lock-free queue to the daemon module, the daemon module records the information of the receiver module and the sender module.

[0025] Furthermore, in the above method for accelerating network communication, the size of the memory area in the dual-ring lock-free queue is n*8 bytes.

[0026] In a second aspect of the present invention, a device for accelerating network communication is provided, which is applied to a system including: a first machine and a second machine connected to a shared memory via an interconnection bus, wherein the first machine includes: a daemon module, a kernel monitoring module and a receiver module, and the second machine includes: a daemon module, a kernel monitoring module and a sender module, and the device includes:

[0027] Writing module: used to write so file shared library containing bind, sendmsg and recvfrom functions;

[0028] The first application module: used for the receiver module to apply for the receiver module's dual-ring lock-free queue from the daemon module in the shared memory when binding;

[0029] The second application module: used to generate a port number when the sender module executes sendmsg, send the sender module IP and port number to the daemon module to apply for the sender module double-ring lock-free queue in the shared memory;

[0030] The first writing module: when the thread of the sending module sends data to the receiving module, it writes data to the double-ring lock-free queue of the receiving module;

[0031] The first reading module and the second writing module: the recvfrom for the receiving module executes the receiving module thread to read the receiving module dual-loop lock-free queue and process the data, and write the data to be replied to the sending module dual-loop lock-free queue corresponding to the port number of the sending module to be returned;

[0032] The second reading module is used for the sending module thread to read the sending module dual-ring lock-free queue to obtain the data of the receiving module after detecting the arrival of data through the adaptive polling strategy of the kernel monitoring module.

[0033] According to a third aspect of the present invention, an electronic device is provided, comprising: a processor and a memory;

[0034] The processor is used to execute a method for accelerating network communication as described in any of the above items by calling the program or instruction stored in the memory.

[0035] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a program or instruction, wherein the program or instruction enables a computer to execute a method for accelerating network communication as described in any one of the above items.

[0036] The beneficial effects of the present invention are as follows: The present invention uses an interconnect bus to replace a traditional network to implement a method for network acceleration, and can switch back to traditional network communication in an environment that does not support the interconnect bus. This interconnect bus technology-based multi-machine network communication replaces multi-machine network communication by reading and writing shared memory, and can be used directly without modifying the application. When network communication is performed between machines using the interconnect bus shared memory, the path transmission of this solution will be adopted. When network communication is performed between machines that do not use the interconnect bus shared memory, it can automatically switch to the traditional network mode. There is no need for a mechanism for fully exclusive CPU detection data. The CPU core will be adaptively preempted / released according to the density of communication data between the two parties, thereby improving the utilization rate of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The accompanying drawings are only used to illustrate specific embodiments and are not considered to limit the present invention. In the entire drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings.

[0038] Figure 1 A system diagram for accelerating network communication provided by an embodiment of the present invention;

[0039] Figure 2 A method for accelerating network communication provided by an embodiment of the present invention Figure 1 ;

[0040] Figure 3 A method for accelerating network communication provided by an embodiment of the present invention Figure 2 ;

[0041] Figure 4 A diagram of a device for accelerating network communication provided by an embodiment of the present invention;

[0042] Figure 5 A schematic block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should fall within the scope of protection of the present invention.

[0044] Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in the present invention.

[0045] In the description of the present invention, the terms "first", "second", and "third" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be internal communication between two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0046] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of methods and systems consistent with some aspects of the present invention as detailed in the appended claims.

[0047] Before introducing the embodiments of the present invention, professional terms involved in the present invention are first introduced.

[0048] Compute Express Link (CXL) is an industry-supported cache-coherent interconnect technology standard protocol that is an open industrial standard between processors and devices such as accelerators, memory buffers, intelligent network interfaces, persistent memory, and solid-state drives.

[0049] The dual-ring lock-free queue consists of two ring queues + 1 data storage area. The first ring queue is used to determine whether it is writable. When writing data, an element called the node number is taken out from it, and then the data is written to the memory corresponding to the node number. Then the node number is recorded in another ring queue. When reading data, the node number is taken out from another ring queue, and the data is taken out from the corresponding memory. Then the node number is written to the first ring queue to indicate that this position in the memory can be used again. Each ring queue has its own head and tail variables. Whether the ring queue is readable / writable is determined by comparing the size relationship between the head and the tail.

[0050] The present invention proposes a method, device, electronic device and storage medium for accelerating network communication. The receiving module writes data into a shared memory, and the sending module detects the arrival of data through an adaptive polling strategy and reads the corresponding data from a specific shared memory address to complete the sending and receiving of data.

[0051] Method Embodiment

[0052] Figure 1 A system diagram for accelerating network communications provided by an embodiment of the present invention.

[0053] Figure 2 A method for accelerating network communication provided by an embodiment of the present invention Figure 1 .

[0054] In a first aspect of the present invention, a method for accelerating network communication is provided, which is applied to a system including: a first machine A and a second machine B connected to a shared memory via an interconnect bus, Figure 1The first machine includes: a daemon module, a kernel monitoring module and a receiver module, and the second machine includes: a daemon module, a kernel monitoring module and a sender module, combined with Figure 2 The method includes six steps from S21 to S26:

[0055] S21: Write a shared library of so files containing bind, sendmsg and recvfrom functions.

[0056] Specifically, in the embodiment of the present invention, the so file shared library contains commonly used functions bind, sendmsg and recvfrom in socket communication, so that when the user's application is executed, it can be intercepted to execute the relevant functions expected by the user.

[0057] S22: When binding, the receiver module applies to the daemon module for a receiver module double-ring lock-free queue in the shared memory.

[0058] Specifically, in an embodiment of the present invention, the daemon process module is responsible for establishing its own lock-free queue for the receiving module and the sending module. Each receiving module has a lock-free queue, and each thread of the sending module has its own lock-free queue. Because the bind, sendmsg and recvfrom of the application are intercepted in the shared library, the receiving module can apply for its own lock-free queue from the daemon process module when bind.

[0059] S23: When the sender module executes sendmsg, it generates a port number and sends the sender module IP and port number to the daemon module to apply for a dual-ring lock-free queue of the sender module in the shared memory.

[0060] Specifically, in an embodiment of the present invention, when the sender module executes sendmsg, each thread generates its own port number before sending data, and then sends the sender module's own IP and port number to the daemon module to apply for a sender module's own dual-ring lock-free queue in the shared memory.

[0061] S24: When the thread of the sender module sends data to the receiver module, the thread writes data to the dual-ring lock-free queue of the receiver module.

[0062] Specifically, in the embodiment of the present invention, when the thread of the sending module sends data to the receiving module, the data is written to the dual-loop lock-free queue of the receiving module when the program is actually executed.

[0063] S25: The recvfrom of the receiving module executes that the receiving module thread reads the receiving module dual-loop lock-free queue and processes the data, and writes the data to be replied to the sending module dual-loop lock-free queue corresponding to the port number of the sending module to be returned.

[0064] Specifically, in the embodiment of the present invention, the recvfrom of the receiving module executes the receiving module thread to read the lock-free queue of the receiving module and process the data, and then writes the data to be replied to the dual-ring lock-free queue corresponding to the port number of the sending module to be returned.

[0065] S26: After the sender module thread detects the arrival of data through the adaptive polling strategy of the kernel monitoring module, it reads the sender module dual-loop lock-free queue to obtain the data of the receiver module.

[0066] Specifically, in the embodiment of the present invention, the corresponding sending module thread can obtain the data returned by the receiving module by reading its own dual-loop lock-free queue.

[0067] The kernel monitoring module is a kernel module. Its purpose is to avoid the need to continuously poll for data input in the recvfrom interception function. For example, the traditional RDMA strategy is faster than the traditional network in part because the interrupt trigger mode is changed to the full CPU polling mode. However, there is a problem with this, which is that it requires the use of additional cores to do the polling. When there is no data communication for a long time, it is a waste of resources. The following describes how to avoid long-term empty polling.

[0068] Figure 3 A method for accelerating network communication provided by an embodiment of the present invention Figure 2 .

[0069] Furthermore, the above method for accelerating network communication is combined with Figure 3 , and also includes two steps S31 to S32:

[0070] S31: The sender module polls the sender module dual-ring lock-free queue at a specified time to see if there is any data arriving;

[0071] S32: If the polling result is that no data has arrived in the dual-ring lock-free queue of the sender module, the receiver module is mounted to the polling linked list of the daemon module, and the daemon module performs unified polling.

[0072] Specifically, in an embodiment of the present invention, after the sender module is started, it continuously polls whether there is any data arriving in the dual-ring lock-free queue of the sender module at a specified time. If no data arrives at the specified time, the receiver module is mounted into the unified polling linked list of the daemon module, and the daemon module performs regular and unified polling.

[0073] Here, after being mounted to the daemon module, the daemon module will write this event to the / sys file system. The kernel monitoring module will periodically check the / sys file system through a high-precision timer. If it is found that the daemon module has written, it will start polling this specific area. Then, when a message is really received, it will write specific data to this specific area at the same time. The kernel monitoring module will know that the message has been received and can wake up the sender module.

[0074] The daemon module also needs to manage according to the following rules whether each sender module / receiver module needs to cancel the daemon module polling and instead continue to be polled by the sender module / receiver module itself.

[0075] Furthermore, the above method for accelerating network communication further includes:

[0076] Determine whether the daemon module releases contact polling according to pre-set rules;

[0077] The pre-set rules are set according to the data of the sender module and the receiver module and the timestamp corresponding to the data.

[0078] Specifically, in the embodiment of the present invention, because each message header of the network data sent out includes a request identification number, the receiving module can locally record the request identification number and timestamp sent after a period of time, and then find the same request identification number in the sending module, and use the new timestamp received by the sending module-the old timestamp to evaluate the time between the new timestamp and the old timestamp. If the time between the timestamp and the old timestamp is longer than the threshold, then the local daemon module is notified, and the local daemon module complains to the daemon module of the sending module, informing the corresponding recvfrom that the polling cannot be entrusted to the daemon module and that the polling work needs to be continued. If no complaint is received from the receiving module within the next time period, it will be considered that the corresponding recvfrom can be entrusted to the daemon module for unified polling.

[0079] Furthermore, in the above method for accelerating network communication, the daemon module performs unified polling in one of the following two ways:

[0080] The first method: periodically poll the dual-loop lock-free queues corresponding to the recvfrom that needs to be polled in the polling linked list to determine whether there is data arriving; if the polling result is that data has arrived, notify the corresponding recvfrom, and enter sleep when not polling;

[0081] The second method is to divide a 128-bit shared area in the shared memory, and each recvfrom in the daemon module corresponds to one of them. When mounted to the daemon module, the daemon module allocates it and modifies the dual-loop lock-free queue part corresponding to each IP and port in the shared memory, adding the corresponding number of bits; when the receiving module writes data, the corresponding number of bits is updated and set to 1; periodically read whether there is a bit set to 1 in the shared area. If there is a bit set to 1, wake up the daemon module for unified polling.

[0082] Furthermore, in the above-mentioned method for accelerating network communication, the recvfrom of the receiving module executes that the receiving module thread reads the receiving module dual-loop lock-free queue and processes the data, and the sending module thread detects the arrival of data through the adaptive polling strategy of the kernel monitoring module, and then reads the sending module dual-loop lock-free queue to obtain the data of the receiving module, and also includes:

[0083] Whether the dual-ring lock-free queue is readable is determined based on the size relationship between the head and tail of the dual-ring lock-free queue.

[0084] Specifically, in the embodiment of the present invention, when writing data, it is considered readable only when the data is truly written and the head of another circular queue is increased by 1. There will not be a situation where the head of the circular queue is changed but the data has not been written yet, and the other party detects the increase in the head and comes to read, resulting in incomplete data.

[0085] Furthermore, the above method for accelerating network communication further includes: the daemon module records the result of applying for the dual-loop lock-free queue of the receiving module and the dual-loop lock-free queue of the sending module into the shared memory.

[0086] Specifically, in the embodiment of the present invention, the daemon process module records the applied dual-loop lock-free queue of the receiver module and the dual-loop lock-free queue of the sender module into the shared memory, so that all daemon process modules can query them.

[0087] When the receiver module and the sender module apply for the dual-ring lock-free queue to the daemon module, the daemon module records the information of the receiver module and the sender module.

[0088] Specifically, in an embodiment of the present invention, the daemon module records information of the receiving module and the sending module. When the sending module wants to send data, it can query the daemon module to obtain whether the receiving module is connected to the shared memory to determine whether to switch to traditional network communication.

[0089] Furthermore, in the above method for accelerating network communication, the size of the memory area in the dual-ring lock-free queue is n*8 bytes.

[0090] Specifically, in the embodiment of the present invention, what is stored in the dual-ring lock-free queue is the memory block address (8 bytes) where the data is actually written, so the size of the memory area in the dual-ring lock-free queue is n*8 bytes, and the content in the dual-ring lock-free queue points to the address of the memory area where the data is actually written, because the same physical address corresponds to different virtual addresses in different processes, in order to ensure that this memory address can be used in different processes / multi-machine processes, what is actually written here is the difference between this address and the starting address of the shared memory, so that when applying for the memory area of ​​the lock-free queue, there is no need to consider the length of the data that the receiving module needs to send, and it will not cause subsequent discovery that the memory of the dual-ring lock-free queue is insufficient or the application is too large to cause memory waste. The header of this actually used memory area fixedly stores the metadata of this data, such as the IP and port of the receiving module, the number of bytes of transmitted data, etc., and then the data that is actually transmitted.

[0091] The above method was tested by simulating the cxl environment mcached and libmemcached. The simulation environment created two virtual machines in a host machine according to the modified qemu that supports simulating CXL. The two virtual machines have different IPs and can communicate with each other. Memcached is started in one and libmemcached is started in the other. The key-value is stored and queried in memcached through libmemcached, and a total of 1 million tests (100,000 sets and 900,000 gets) were performed. The actual completion time of 1 million times by the method in this application is less than 10 seconds, while the traditional socket network takes 140 seconds, and the performance is improved by more than 15 times.

[0092] Device Embodiment

[0093] Figure 4 A diagram of a device for accelerating network communications provided by an embodiment of the present invention.

[0094] In a second aspect of the present invention, a device for accelerating network communication is provided, which is applied to a system including: a first machine and a second machine connected to a shared memory via an interconnection bus, wherein the first machine includes: a daemon module, a kernel monitoring module and a receiver module, and the second machine includes: a daemon module, a kernel monitoring module and a sender module, and the device includes:

[0095] Writing module 41: used to write a so file shared library containing bind, sendmsg and recvfrom functions.

[0096] Specifically, in the embodiment of the present invention, the so file shared library written by the writing module 41 contains the commonly used functions bind, sendmsg and recvfrom in socket communication, so that it can be intercepted when the user's application is executed to execute the relevant functions expected by the user.

[0097] The first application module 42 is used for the receiver module to apply for the receiver module's dual-ring lock-free queue from the daemon process module in the shared memory when the receiver module binds.

[0098] Specifically, in the embodiment of the present invention, the daemon module is responsible for establishing its own lock-free queue for the receiving module and the sending module. Each receiving module has a lock-free queue, and each thread of the sending module has its own lock-free queue. Because the bind, sendmsg and recvfrom of the application are intercepted in the shared library, the first application module 42 of the receiving module can apply for its own lock-free queue from the daemon module when binding.

[0099] The second application module 43 is used for generating a port number when the sender module executes sendmsg, and sending the sender module IP and port number to the daemon module to apply for the sender module double-ring lock-free queue in the shared memory.

[0100] Specifically, in the embodiment of the present invention, when the second application module 43 of the sender module executes sendmsg, each thread generates the sender module's own port number before sending data, and then sends the sender module's own IP and port number to the daemon module to apply for a sender module's own dual-ring lock-free queue.

[0101] The first writing module 44 is used for writing data into the dual-ring lock-free queue of the receiving module when the thread of the sending module sends data to the receiving module.

[0102] Specifically, in the embodiment of the present invention, when the thread of the sending module sends data to the receiving module, the first writing module 44 writes data to the dual-ring lock-free queue of the receiving module when the program is actually executed.

[0103] The first reading module 45 and the second writing module 46: the recvfrom for the receiving module executes the receiving module thread to read the receiving module dual-loop lock-free queue and process the data, and write the data to be replied to the sending module dual-loop lock-free queue corresponding to the port number of the sending module to be returned.

[0104] Specifically, in the embodiment of the present invention, the recvfrom of the receiving module executes the first reading module 45 of the receiving module thread to read the lock-free queue of the receiving module and process the data, and then the second writing module 46 writes the data to be replied to the dual-ring lock-free queue corresponding to the port number of the sending module to be returned.

[0105] The second reading module 47 is used for the sending module thread to read the sending module dual-loop lock-free queue to obtain the data of the receiving module after detecting the arrival of data through the adaptive polling strategy of the kernel monitoring module.

[0106] Specifically, in the embodiment of the present invention, the second reading module 47 of the corresponding sending module thread obtains the data returned by the receiving module by reading its own dual-loop lock-free queue.

[0107] According to a third aspect of the present invention, an electronic device is provided, comprising: a processor and a memory;

[0108] The processor is used to execute a method for accelerating network communication as described in any of the above items by calling the program or instruction stored in the memory.

[0109] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a program or instruction, wherein the program or instruction enables a computer to execute a method for accelerating network communication as described in any one of the above items.

[0110] Figure 5 It is a schematic block diagram of an electronic device provided by an embodiment of the present invention.

[0111] like Figure 5 As shown, the electronic device includes: at least one processor 501, at least one memory 302 and at least one communication interface 503. The various components in the electronic device are coupled together through a bus system 504. The communication interface 503 is used to transmit information between external devices. It can be understood that the bus system 504 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 504 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 504 .

[0112] It can be understood that the memory 502 in this embodiment can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories.

[0113] In some implementations, the memory 502 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system and application programs.

[0114] The operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. A program that implements any method of a method for accelerating network communication provided in an embodiment of the present invention can be included in the application.

[0115] In an embodiment of the present invention, the processor 501 calls a program or instruction stored in the memory 502, specifically, a program or instruction stored in an application, and the processor 501 is used to execute the steps of each embodiment of a method for accelerating network communication provided in an embodiment of the present invention.

[0116] Write a so file shared library containing bind, sendmsg and recvfrom functions;

[0117] When binding, the receiver module applies to the daemon module for the receiver module's double-ring lock-free queue in the shared memory;

[0118] When the sender module executes sendmsg, it generates a port number, sends the sender module IP and port number to the daemon module, and applies for the sender module double-ring lock-free queue in the shared memory;

[0119] When the thread of the sender module sends data to the receiver module, the data is written to the dual-loop lock-free queue of the receiver module;

[0120] The recvfrom of the receiving module executes the sending module thread to read the receiving module dual-loop lock-free queue and process the data, and write the data to be replied to the sending module dual-loop lock-free queue corresponding to the port number of the sending module to be returned;

[0121] The sender module thread detects the arrival of data through the adaptive polling strategy of the kernel monitoring module, and then reads the sender module dual-loop lock-free queue to obtain the data of the receiver module.

[0122] Any method in a method for accelerating network communication provided in an embodiment of the present invention can be applied to the processor 501, or implemented by the processor 501. The processor 501 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 501 or an instruction in the form of software. The above processor 501 can be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0123] The steps of any method in the method for accelerating network communication provided by the embodiment of the present invention can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software units in the decoding processor. The software unit can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 502, and the processor 501 reads the information in the memory 502 and completes the steps of the method in combination with its hardware.

[0124] Those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present invention and to form different embodiments.

[0125] Those skilled in the art will appreciate that the description of each embodiment has its own emphasis, and for parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0126] Although the embodiments of the present invention are described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations all fall within the scope defined by the appended claims. The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

[0127] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for accelerating network communication, characterized in that: Applied to a system including: a first machine and a second machine connected to a shared memory via an interconnect bus, wherein the first machine includes: a daemon module, a kernel monitoring module and a receiver module, and the second machine includes: a daemon module, a kernel monitoring module and a sender module, the method includes: Write a so file shared library containing bind, sendmsg and recvfrom functions; When binding, the receiver module applies to the daemon module for the receiver module's double-ring lock-free queue in the shared memory; When the sender module executes sendmsg, it generates a port number, sends the sender module IP and port number to the daemon module, and applies for the sender module double-ring lock-free queue in the shared memory; When the thread of the sender module sends data to the receiver module, the data is written to the dual-loop lock-free queue of the receiver module; The recvfrom of the receiver module executes the receiver module thread to read the receiver module dual-loop lock-free queue and process the data, and write the data to be replied to the sender module dual-loop lock-free queue corresponding to the port number of the sender module to be returned; The sender module thread detects the arrival of data through the kernel monitoring module's adaptive polling strategy, and then reads the sender module's dual-loop lock-free queue to obtain the receiver module's data; The sender module polls the sender module dual-loop lock-free queue at the specified time to see if there is any data arriving; If the polling result is that there is no data in the dual-ring lock-free queue of the sender module, the receiver module is mounted to the polling list of the daemon module, and the daemon module performs unified polling; Determine whether the daemon module releases contact polling according to pre-set rules; The pre-set rules are set based on the data of the sender module and the receiver module and the timestamp corresponding to the data; The daemon module performs unified polling in one of two ways: The first method: periodically poll the dual-loop lock-free queues corresponding to the recvfrom that needs to be polled in the polling linked list to determine whether there is data arriving; if the polling result is that data has arrived, notify the corresponding recvfrom, and enter sleep when not polling; The second method is to divide a 128-bit shared area in the shared memory, and each recvfrom in the daemon module corresponds to one of them. When mounted to the daemon module, the daemon module allocates it and modifies the dual-loop lock-free queue part corresponding to each IP and port in the shared memory, adding the corresponding number of bits; when the receiving module writes data, the corresponding number of bits is updated and set to 1; periodically read the shared area to see if there is a bit set to 1. If there is a bit set to 1, wake up the daemon module for unified polling.

2. A method for accelerating network communication according to claim 1, characterized in that: The recvfrom of the receiving module executes the receiving module thread to read the receiving module dual-loop lock-free queue and process the data, and the sending module thread detects the arrival of data through the adaptive polling strategy of the kernel monitoring module, and then reads the sending module dual-loop lock-free queue to obtain the data of the receiving module, and also includes: Whether the dual-ring lock-free queue is readable is determined based on the size relationship between the head and tail of the dual-ring lock-free queue.

3. A method for accelerating network communication according to claim 1, characterized in that: The method further comprises: the daemon module records the result of applying for the dual-loop lock-free queue of the receiving module and the dual-loop lock-free queue of the sending module into the shared memory; When the receiver module and the sender module apply for the dual-ring lock-free queue to the daemon module, the daemon module records the information of the receiver module and the sender module.

4. The method for accelerating network communication according to claim 1, characterized in that: The size of the memory area in the dual-ring lock-free queue is n*8 bytes.

5. A device for accelerating network communication, characterized in that: Applicable to a system including: a first machine and a second machine connected to a shared memory via an interconnection bus, wherein the first machine includes: a daemon module, a kernel monitoring module and a receiver module, and the second machine includes: a daemon module, a kernel monitoring module and a sender module, and the device includes: Writing module: used to write so file shared library containing bind, sendmsg and recvfrom functions; The first application module: used for the receiver module to apply for the receiver module's dual-ring lock-free queue from the daemon module in the shared memory when binding; The second application module: used to generate a port number when the sender module executes sendmsg, send the sender module IP and port number to the daemon module to apply for the sender module double-ring lock-free queue in the shared memory; The first writing module: when the thread of the sending module sends data to the receiving module, it writes data to the double-ring lock-free queue of the receiving module; The first reading module and the second writing module: the recvfrom for the receiving module executes the receiving module thread to read the receiving module dual-loop lock-free queue and process the data, and write the data to be replied to the sending module dual-loop lock-free queue corresponding to the port number of the sending module to be returned; The second reading module is used for the sender module thread to read the sender module double-loop lock-free queue to obtain the data of the receiver module after detecting the arrival of data through the adaptive polling strategy of the kernel monitoring module; The sender module polls the sender module dual-loop lock-free queue at the specified time to see if there is any data arriving; If the polling result is that there is no data in the dual-ring lock-free queue of the sender module, the receiver module is mounted to the polling list of the daemon module, and the daemon module performs unified polling; Determine whether the daemon module releases contact polling according to pre-set rules; The pre-set rules are set based on the data of the sender module and the receiver module and the timestamp corresponding to the data; The daemon module performs unified polling in one of two ways: The first method: periodically poll the dual-loop lock-free queues corresponding to the recvfrom that needs to be polled in the polling linked list to determine whether there is data arriving; if the polling result is that data has arrived, notify the corresponding recvfrom, and enter sleep when not polling; The second method is to divide a 128-bit shared area in the shared memory, and each recvfrom in the daemon module corresponds to one of them. When mounted to the daemon module, the daemon module allocates it and modifies the dual-loop lock-free queue part corresponding to each IP and port in the shared memory, adding the corresponding number of bits; when the receiving module writes data, the corresponding number of bits is updated and set to 1; periodically read the shared area to see if there is a bit set to 1. If there is a bit set to 1, wake up the daemon module for unified polling.

6. An electronic device, characterized in that: include: Processor and memory; The processor is used to execute the method for accelerating network communication as described in any one of claims 1 to 4 by calling the program or instruction stored in the memory.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or instruction, and the program or instruction enables a computer to execute a method for accelerating network communication as claimed in any one of claims 1 to 4.