Data storage method, device and equipment and computer readable storage medium

By obtaining the idle length of the data storage area in the communication system and determining the target data storage area, the problem of waste of free space in the data storage area is solved, and resource utilization and data storage efficiency are improved.

CN119922156APending Publication Date: 2025-05-02HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311424812.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-30
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In communication systems, the waste of idle space in the data storage area is severe, resulting in low resource utilization.

Method used

When receiving data, the idle length of the data storage area is obtained, and the target data storage area is determined based on the idle length and data length to optimize the utilization of the data storage area.

Benefits of technology

It effectively reduces the waste of free space in the data storage area, improves the utilization rate of the data storage area, and improves the efficiency of data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119922156A_ABST
    Figure CN119922156A_ABST
Patent Text Reader

Abstract

The invention discloses a data storage method, device and equipment and a computer readable storage medium, and belongs to the technical field of communication. The method comprises the following steps: receiving first data with a first length; obtaining a first free length of a first data storage area in the first receiving unit, wherein the first free length is the length of a free space in the first data storage area; based on the first idle length and the first length, a target data storage area used for storing the first data is determined, the target data storage area comprises a first data storage area or a second data storage area of a second receiving unit, and the second receiving unit and the first receiving unit are different receiving units in the same receiving queue; and storing the first data to the target data storage area. The first data is stored based on the first free length and the first length, and waste of free space in the data storage area can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a data storage method, device, equipment and a computer-readable storage medium. Background Art

[0002] In a communication system, two nodes communicate and interact by sending and receiving messages. The node on the sending side sends a message to the node on the receiving side, and the node on the receiving side can receive the message through the generated receiving unit and store the data in the message so that other processing can be performed on the stored data later. Summary of the invention

[0003] The present application provides a data storage method, apparatus, device and computer-readable storage medium to reduce the waste of free space in a data storage area. The technical solution is as follows:

[0004] In a first aspect, a data storage method is provided, the method comprising: receiving first data, the length of the first data being a first length; obtaining a first free length of a first data storage area in a first receiving unit, the first free length being the length of free space in the first data storage area; based on the first free length and the first length, determining a target data storage area for storing the first data, the target data storage area comprising the first data storage area or the second data storage area of ​​a second receiving unit, the second receiving unit and the first receiving unit being different receiving units in the same receiving queue; and storing the first data in the target data storage area.

[0005] The target data storage area determined by the present application based on the first idle length and the first length may be a data storage area whose space is partially occupied, which can reduce the waste of idle space in the data storage area and improve the utilization rate of the data storage area.

[0006] In a possible implementation, the first receiving unit further includes a first information storage area, and the first idle length is stored in the first information storage area. By storing the first idle length in the first information storage area in the first receiving unit, the efficiency of obtaining the first idle length can be improved, the time required for determining the target data storage area can be reduced, and the efficiency of data storage can be improved.

[0007] In a possible implementation, receiving the first data includes: receiving a first message, the first message including the first data and a first length of the first data; and obtaining the first data and the first length from the first message. By receiving the first message, the first data and the first length can be obtained synchronously, thereby improving the efficiency of obtaining the first data and the first length.

[0008] In a possible implementation, determining a target data storage area for storing the first data based on the first free length and the first length includes: comparing the first free length and the first length to obtain a comparison result, the comparison result indicating whether the free space of the first data storage area can be used to store the first data; and determining the target data storage area according to the comparison result. Determining whether the free space of the first data storage area is sufficient to store the first data according to the comparison result can provide an effective basis for determining the target data storage area.

[0009] In a possible implementation, after determining the target data storage area for storing the first data, it also includes: obtaining the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, the occupied length being the length of the space in which data has been stored in the target data storage area, and the starting address being the first address of the target data storage area; determining the storage starting address of the first data according to the starting address and the occupied length; storing the first data in the target data storage area, including: storing the first data starting from the position in the target data storage area indicated by the storage starting address. According to the starting address and the occupied length, a more accurate storage starting address can be determined, thereby improving the accuracy of storing the first data.

[0010] In a possible implementation, after determining the target data storage area for storing the first data, it also includes: obtaining the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, the occupied length being the length of the space in which data has been stored in the target data storage area, and the starting address being the first address of the target data storage area; determining the storage starting address of the first data according to the starting address and the occupied length; determining the storage ending address of the first data according to the storage starting address and the first length; storing the first data in the target data storage area, including: storing the first data with the position in the target data storage area indicated by the storage starting address as the starting point and the position in the target data storage area indicated by the storage ending address as the end point. Determining the storage starting address and storage ending address of the first data can make the storage of the first data more detailed and accurate.

[0011] In a possible implementation, when the comparison result is that the first length is less than or equal to the first free length, the target data storage area is the first data storage area, the starting address is the starting address of the first data storage area, and the occupied length is the occupied length of the first data storage area. If the first length is less than or equal to the first free length, it means that the free space of the first data storage area is sufficient to store the first data, and the first data storage area can be determined as the target data storage area, thereby reducing the waste of free space in the first data storage area and improving the utilization rate of the first data storage area.

[0012] In a possible implementation, when the comparison result is that the first length is greater than the first free length, the target data storage area is the second data storage area, the starting address is the starting address of the second data storage area, and the occupied length is the occupied length of the second data storage area. If the first length is greater than the first free length, and the free space of the first data storage area is insufficient to store the first data, the second data storage area can be determined as the target data storage area. Based on the starting address of the second data storage area and the occupied length of the second data storage area, the storage start address of the first data is determined, which can ensure more accurate storage of the first data.

[0013] In a possible implementation, after comparing the first idle length and the first length to obtain the comparison result, the method further includes: removing the first receiving unit from the receiving queue. If the first length is greater than the first idle length and the free space of the first data storage area is insufficient to store the first data, the first receiving unit to which the first data storage area belongs can be removed from the receiving queue, thereby reducing the number of receiving units in the receiving queue and improving the efficiency of subsequently determining the target data storage area for other data.

[0014] In a possible implementation, after storing the first data in the target data storage area, the method further includes: determining a second idle length of the target data storage area, the second idle length being the length of the idle space after the target data storage area stores the first data; and removing the receiving unit to which the target data storage area belongs from the receiving queue based on the second idle length being less than or equal to the idle threshold. If the length of the idle space in the target data storage area after storing the first data is less than the idle threshold, it can be considered that the target data storage area can no longer continue to store other data received subsequently, and removing the receiving unit to which the target data storage area belongs from the receiving queue can improve the efficiency of the target data storage area for determining other data subsequently.

[0015] In a possible implementation, after storing the first data in the target data storage area, it also includes: generating first completion information, the first completion information is used to indicate that the first data has been stored, the first completion information includes at least one of the storage start address, storage end address, second free length and removal mark of the first data, the removal mark indicates whether there is a receiving unit removed from the receiving queue in the first receiving unit or the second receiving unit, and the first completion information is used to determine whether to add a third receiving unit to the receiving queue. The first completion information generated according to the storage situation of the first data can be used to determine whether to add a new third receiving unit to the receiving queue to ensure that the receiving units in the receiving queue can meet the storage requirements of the subsequently received data.

[0016] In a possible implementation, after generating the first completion information, the method further includes: receiving supplementary information, the supplementary information being determined based on the first completion information; and adding a third receiving unit to the receiving queue according to the supplementary information. Adding a new third receiving unit to the receiving queue according to the received supplementary information can ensure that the receiving units in the receiving queue can meet the storage requirements of the subsequently received data.

[0017] In a possible implementation, the first idle length is greater than the idle threshold. If the first idle length of the first data storage area is less than or equal to the idle threshold, it means that the first receiving unit to which the first data storage area belongs is a receiving unit that needs to be removed from the receiving queue, and the first data storage area cannot be used as the target data storage area for the first data, that is, there is no need to compare the first idle length with the first length, so as to avoid performing subsequent operations such as invalid comparison and wasting processing resources. In addition, the method is executed while ensuring that the first idle length of the first data storage area is greater than the idle threshold, so as to perform subsequent determination and storage operations.

[0018] In a second aspect, a data storage device is provided, the device comprising: a receiving module, used to receive first data, the length of the first data being a first length; an acquiring module, used to acquire a first free length of a first data storage area in a first receiving unit, the first free length being the length of the free space in the first data storage area; a determining module, used to determine a target data storage area for storing the first data based on the first free length and the first length, the target data storage area comprising the first data storage area or the second data storage area of ​​the second receiving unit, the second receiving unit and the first receiving unit being different receiving units in the same receiving queue; a storage module, used to store the first data in the target data storage area.

[0019] In a possible implementation manner, the first receiving unit further includes a first information storage area, and the first idle length is stored in the first information storage area.

[0020] In a possible implementation, the receiving module is configured to receive a first message, where the first message includes first data and a first length of the first data; and obtain the first data and the first length from the first message.

[0021] In a possible implementation, the determination module is used to compare the first free length and the first length to obtain a comparison result, which indicates whether the free space in the first data storage area can be used to store the first data; and determine the target data storage area according to the comparison result.

[0022] In a possible implementation, the acquisition module is further used to obtain the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, where the occupied length is the length of the space in which data has been stored in the target data storage area, and the starting address is the first address of the target data storage area; the determination module is further used to determine the storage starting address of the first data based on the starting address and the occupied length; the storage module is used to store the first data starting from the position in the target data storage area indicated by the storage starting address.

[0023] In a possible implementation, the acquisition module is further used to obtain the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, the occupied length being the length of the space in which data has been stored in the target data storage area, and the starting address being the first address of the target data storage area; the determination module is further used to determine the storage starting address of the first data according to the starting address and the occupied length; determine the storage ending address of the first data according to the storage starting address and the first length; the storage module is used to store the first data with the position in the target data storage area indicated by the storage starting address as the starting point and the position in the target data storage area indicated by the storage ending address as the end point.

[0024] In a possible implementation, when the comparison result is that the first length is less than or equal to the first free length, the target data storage area is the first data storage area, the starting address is the starting address of the first data storage area, and the occupied length is the occupied length of the first data storage area.

[0025] In a possible implementation, when the comparison result is that the first length is greater than the first free length, the target data storage area is the second data storage area, the start address is the start address of the second data storage area, and the occupied length is the occupied length of the second data storage area.

[0026] In a possible implementation, the device further includes a removing module, which is configured to remove the first receiving unit from the receiving queue.

[0027] In one possible implementation, the determination module is also used to determine a second free length of the target data storage area, where the second free length is the length of the free space after the target data storage area stores the first data; the removal module is also used to remove the receiving unit to which the target data storage area belongs from the receiving queue based on the second free length being less than or equal to the free threshold.

[0028] In one possible implementation, the device also includes a generation module, which is used to generate first completion information, the first completion information is used to indicate that the first data has been stored, the first completion information includes at least one of the storage start address, storage end address, second free length and removal flag of the first data, the removal flag indicates whether there is a receiving unit removed from the receiving queue in the first receiving unit or the second receiving unit, and the first completion information is used to determine whether to add a third receiving unit to the receiving queue.

[0029] In a possible implementation, the receiving module is further used to receive supplementary information, where the supplementary information is determined based on the first completion information; the device also includes an adding module, where the adding module is used to add a third receiving unit to the receiving queue according to the supplementary information.

[0030] In a possible implementation, the first idle length is greater than an idle threshold.

[0031] In a third aspect, a communication device is provided, the device comprising: a network interface, a memory, and a processor. The network interface, the memory, and the processor communicate with each other through an internal connection path, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to control the network interface to receive signals and control the network interface to send signals, and when the processor executes the instructions stored in the memory, the processor executes the method in the first aspect or any possible implementation of the first aspect.

[0032] Optionally, there are one or more processors and one or more memories.

[0033] Optionally, the memory may be integrated with the processor, or the memory may be provided separately from the processor.

[0034] In a fourth aspect, a data storage system is provided, which includes a sending device and a receiving device, the receiving device is used to execute the data storage method in the above-mentioned first aspect or any possible implementation of the first aspect, and the sending device is used to send data to the receiving device.

[0035] In a fifth aspect, a data storage device is provided, the device including a processor coupled to a memory; at least one instruction is stored in the memory, and at least one instruction is loaded and executed by the processor so that the data storage device implements the data storage method in the above-mentioned first aspect or any possible implementation method of the first aspect.

[0036] In a sixth aspect, a communication system is provided, the system comprising the device in the above-mentioned second aspect or any possible implementation manner of the second aspect.

[0037] In a seventh aspect, a computer program (product) is provided, the computer program (product) comprising: a computer program code, when the computer program code is executed by a computer, the computer executes the method in the first aspect or any possible implementation manner of the first aspect.

[0038] In an eighth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a program or instruction. When the program or instruction runs on a computer, the method in the above-mentioned first aspect or any possible implementation of the first aspect is executed.

[0039] In a ninth aspect, a chip is provided, comprising a processor for calling and executing instructions stored in a memory, so that a computer equipped with the chip executes the method in the first aspect or any possible implementation of the first aspect.

[0040] In the tenth aspect, another chip is provided, comprising: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, a computer equipped with the chip executes the method in the above-mentioned first aspect or any possible implementation of the first aspect.

[0041] It should be understood that the beneficial effects achieved by the technical solutions of the second to tenth aspects of the present application and the corresponding possible implementation methods can be found in the above-mentioned technical effects of the first aspect and its corresponding possible implementation methods, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 A schematic diagram of a communication process in a communication scenario of a Kitty Hawk protocol mode provided in an embodiment of the present application;

[0043] Figure 2 A schematic diagram of a communication process in a communication scenario of a dating protocol mode provided in an embodiment of the present application;

[0044] Figure 3 A schematic diagram of a communication process of a related technology provided in an embodiment of the present application;

[0045] Figure 4 A schematic diagram of an implementation scenario provided for an embodiment of the present application;

[0046] Figure 5 A schematic diagram of an implementation scenario based on a network card provided in an embodiment of the present application;

[0047] Figure 6 A schematic diagram of a data storage method provided in an embodiment of the present application;

[0048] Figure 7 A schematic diagram of a receiving unit of a receiving end and its corresponding memory provided in an embodiment of the present application;

[0049] Figure 8 A schematic diagram of another receiving unit of a receiving end and its corresponding memory provided in an embodiment of the present application;

[0050] Fig. 9 A schematic diagram of the structure of a receiving unit provided in an embodiment of the present application;

[0051] Fig.10 A storage schematic diagram of a receiving end provided in an embodiment of the present application;

[0052] Fig.11 A schematic diagram of data storage in a data storage area in a related technology provided in an embodiment of the present application;

[0053] Fig.12 A schematic diagram of storing data in a data storage area of ​​the present application provided in an embodiment of the present application;

[0054] Fig.13 A schematic diagram of a process for implementing an additional write operation using a related technology provided in an embodiment of the present application;

[0055] Fig.14 A schematic diagram of a process for implementing an additional write operation in the present application provided in an embodiment of the present application;

[0056] Fig.15 A schematic diagram of the structure of a data storage device provided in an embodiment of the present application;

[0057] Fig.16 A schematic diagram of the structure of a data storage device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.

[0059] In a communication system, two nodes communicate and interact by sending and receiving messages. For example, a data center network is a communication network in a communication system. In a data center network, two nodes can send messages to each other based on the transport layer protocol of remote direct memory access (RDMA) technology to achieve communication and interaction. Among them, RDMA is a technology that can bypass the kernel of the remote host operating system to access data in memory. Since RDMA technology does not go through the operating system when accessing data, and unloads the protocol stack through the network card hardware, achieving zero-copy and kernel-bypass data transmission, RDMA technology not only saves a lot of central processing unit (CPU) resources and reduces CPU usage, but also improves system throughput and reduces system network communication latency, which can meet the demands of data center network computing or storage-intensive application data. Therefore, RDMA technology is widely used in large-scale parallel computer clusters in data center networks.

[0060] The transport layer protocol of RDMA technology can be a protocol based on infinite broadband (IB) network, or a protocol supporting Ethernet. The transport layer protocol of RDMA technology can be called RDMA protocol, including but not limited to RDMA over converged ethernet (RoCE) protocol based on Ethernet, second generation RDMA over converged ethernet version 2 (RoCEv2) protocol based on Ethernet or IB protocol. RDMA includes two communication modes, namely bilateral communication mode and unilateral communication mode, wherein the operation in the unilateral communication mode can be, for example, write / read (Write / Read) operation, and the operation in the bilateral communication mode can be, for example, send-receive (Send-Recv) operation.

[0061] Regardless of whether it is a unilateral communication mode or a bilateral communication mode, in the RoCE, RoCEv2 or IB protocol, the transmission unit for interaction between the sender and the receiver can be a message (msg), and one message corresponds to a transmission request of an application supported by the sender and the receiver. The length of each message can be different, and the maximum length of the message can be set based on the transmission capacity of the sender and the receiver, for example, it can be 2 gigabytes (GB). When the length of the message exceeds the length of the maximum transmission unit (MTU) of the path, the message can be divided into multiple messages, and the sender sends the multiple messages to the receiver in sequence to achieve complete transmission of the message.

[0062] The bilateral communication mode uses the send-receive (SEND-Recv) bilateral communication primitive when transmitting messages, which requires the participation of both parties in the communication, that is, the sender and the receiver need to participate in the communication. The bilateral communication mode has a large number of applications in different RDMA technology scenarios. For example, it can be applied in the scenario of the message passing interface (MPI) protocol mode. The MPI protocol mode includes but is not limited to the Eager protocol mode and the Rendezvous protocol mode. In the Eager protocol mode, when the sender sends a message, it assumes that the receiver can store the data. In the Rendezvous protocol mode, the sender needs the confirmation of the receiver before starting to send data. Whether in the Eager mode or the Rendezvous mode, when using the MPI communication library, the SEND-Recv bilateral communication primitive is frequently used in the communication process to perform the SEND-Recv operation.

[0063] For example, see Figure 1 , shows a schematic diagram of the communication process in a communication scenario of the Eager protocol mode. In the MPI Eager protocol mode, the requester sends a message to the responder, so that both the requester and the responder participate in the communication process, realizing bilateral communication between the requester and the responder. Among them, the requester is the sender, and the responder is the receiver.

[0064] See also Figure 2 , shows a schematic diagram of the communication process in a communication scenario of the Rendezvous protocol mode. In the MPI Rendezvous protocol mode, after the request end sends a message to the responder, the responder sends a read request (read request) to the request end based on the message, and the request end returns a read response (read response) to the responder based on the read request, thereby realizing bilateral communication between the request end and the responder.

[0065] In a possible implementation, in a bilateral communication scenario of SEND-Recv based on RDMA, before the sender and the receiver communicate, that is, before the sender sends a message to the receiver, the sender and the receiver can respectively establish a work queue (WQ), and the receiving action of the receiver must be executed before the sending (SEND) action of the sender, and then the sender can send data to the receiver. The work queue established by the sender is a send queue (SQ), and the work queue established by the receiver is a receive queue (RQ). The receive queue and the send queue can be called a queue pair (QP), and different queue pairs are distinguished by different queue pair identification numbers (queue pair numbers, QPN). The send queue can include multiple send queue elements (SQE), and the send queue element can also be called a send unit. The receive queue can include multiple receive queue elements (RQE), and the receive queue element can also be called a receive unit.

[0066] Taking the establishment process of RQE as an example, the receiving end can send or place multiple RQEs to RQ through ibv_post_recv (an interface for placing work requests in a receiving queue), and the receiving end can register the memory corresponding to each RQE. The registered memory region (memory region, MR) is used to store the data to be received and the information corresponding to the RQE. Among them, the memory region used to store data can be called a data storage region, and the data storage region can be located in the buffer of the receiving end. The memory region used to store the information corresponding to the RQE can be called an information storage region, and the information storage region can be located in the buffer or in other memory areas of the receiving end.

[0067] After both the sender and the receiver have established work queues, the sender can send a message to the receiver. Each message carries data, which can be in a data packet in the message. The sender can send a message by sending a message to the receiver. The message contains a base transport header (BTH) and a direct memory access (DMA) payload. The DMA payload is used to carry data, and the basic transport header carries the packet sequence number (PSN) of the data packet. Different connections are established between the sender and different receivers. The number of data packets sent can be calculated independently for different connections, and a packet sequence number is assigned to each data packet. After a data packet is sent for each connection, the packet sequence number is increased by one. If a failure occurs when sending a data packet and the data packet needs to be retransmitted, the retransmitted data packet has the same packet sequence number as the first time the data packet was sent.

[0068] Since the sender may send data of inconsistent length during one or more communications, each RQE sent by the receiver can use the maximum length of the data sent by the sender as the length of the data storage area in the memory area of ​​the RQE to avoid data overflow caused by the length of the data being greater than the length of the receiving memory of the data storage area, thereby causing data storage failure.

[0069] In the related art, the receiving mechanism of the receiving end is that no matter whether the length of the data in the SQE sent by the sending end is the maximum length, the RQE sent by the receiving end and the SQE sent by the sending end will correspond one to one. Every time the receiving end receives an SQE sent by the sending end, it will use an unused RQE to receive the SQE and store the data in the SQE, thereby realizing a one-to-one consumption of RQE and SQE.

[0070] In the related art, the receiving end consumes the RQE in the receiving queue at a fast speed, and the demand for RQE is large. It is necessary to continuously replenish the RQE to the receiving queue to achieve the reception of a large number of SQEs, which consumes a large amount of CPU resources of the receiving end. In addition, if the length of the data sent by the sending end is less than the maximum length of the data, the remaining memory in the RQE storing the data will not be used, resulting in a waste of memory resources.

[0071] See also Figure 3, showing a schematic diagram of the communication process of a related technology. The maximum length of data that can be sent by the sending end is 64 kilobytes (KB), so the length of the data storage area in each RQE sent by the receiving end can be 64KB. The lengths of the data in the multiple SQEs sent by the sending end to the receiving end are 16KB, 32KB, 8KB and 64KB respectively. The RQE sent by the receiving end is consumed in a one-to-one ratio with the SQE. When the length of the data is less than 64KB, part of the memory space used to store data in the RQE is used (indicated by the black rectangle) and part is left (indicated by the white rectangle). The remaining memory space cannot store data, resulting in memory waste.

[0072] The present application embodiment provides a data storage method that can reduce memory waste. The method can be applied but not limited to communication scenarios based on RDMA technology. For example, see Figure 4 , shows a schematic diagram of an implementation scenario. The implementation scenario includes a transmitter 41 and a receiver 42, and the transmitter 41 and the receiver 42 are connected to each other by wire or wireless communication. The transmitter 41 and the receiver 42 can be deployed on the same device or on different devices. The transmitter 41 can interact with one or more receivers 42, and the receiver 42 can also interact with one or more transmitters 41. The transmitter 41 can send a message to the receiver 42, and the receiver 42 can receive the message sent by the transmitter 41 and store the data in the message.

[0073] In a possible implementation, the sending end 41 and the receiving end 42 may be communication nodes or computer devices. Exemplarily, the sending end 41 and the receiving end 42 may be communication nodes or computer devices deployed with a network interface card (NIC), such as a server deployed with a network interface card. The network interface card may also be referred to as a network card, and the network card may be a host channel adapter (HCA), that is, an RDMA network card (RNIC) that supports RDMA transmission. Optionally, the network card may be a network card with a hardware unloading transport layer protocol stack function. A network card with a hardware unloading transport layer protocol stack function can unload the data processing function of the transport layer protocol stack to the network card, that is, the data processing function of the transport layer protocol stack is no longer executed by software, but is executed by the network card hardware.

[0074] See also Figure 5, shows a schematic diagram of an implementation scenario based on a network card. Two communication nodes deployed with NICs are respectively a sending end and a receiving end, and the sending end and the receiving end are connected through a transmission network to achieve communication. The transmission network may include one or more communication devices capable of implementing a forwarding function, and the communication device may be, for example, a switch or a top-of-rack (ToR) switch.

[0075] Both NICs may be NICs with a function of hardware offloading a transport layer protocol stack. The transport layer protocol stack targeted by the NICs includes a physical (PHY) layer, a media access control (MAC) layer, an internet protocol (IP) layer, and a transport (Transport) layer.

[0076] The data storage method provided in the embodiment of the present application can be applied to Figure 4 or Figure 5 The receiving end of the implementation scenario shown. Figure 6 , shows a flow chart of a data storage method, which includes but is not limited to the following S601 to S604.

[0077] S601, receiving first data, where the length of the first data is a first length.

[0078] The first data is data to be stored by the receiving end, and can be sent from the sending end to the receiving end. Exemplarily, taking the RDMA communication scenario as an example, when the RQE of the receiving end is ready, the sending end can send a message carrying the data to be stored to the receiving end. For example, the RDMA program of the sending end sends SQE by calling the ibv_post_send interface (an interface for sending SQE), and the network card of the sending end is processed and transmitted to the receiving end. The receiving end receives the first data by receiving the message sent by the sending end.

[0079] The embodiment of the present application does not limit the method for determining the length of the first data. Optionally, the transmitting end can add the first length of the first data in the first message carrying the first data, so that the receiving end can obtain the first data and the first length of the first data from the first message after receiving the first message. In the process of obtaining the first data and the first length from the first message, the first data and the first length can be obtained synchronously to improve the efficiency of obtaining the first data and the first length. Alternatively, the first data and the first length can also be obtained separately at different times, which is not limited by the present application.

[0080] In another way of obtaining the first length, the receiving end may also autonomously calculate the length of the first data after obtaining the first data to obtain the first length. Since the first data may be lost during the process of being transmitted from the sending end to the receiving end, autonomously calculating the first length of the first data can ensure the accuracy of the obtained first data.

[0081] S602: Obtain a first free length of a first data storage area in a first receiving unit, where the first free length is the length of free space in the first data storage area.

[0082] In a possible implementation, after the sender and the receiver complete the link establishment, the receiver can register the memory for storing data in advance, and send the RQE bound to the memory to the RQ through the ibv_post_recv interface. Figure 7 , shows a schematic diagram of a receiving unit of a receiving end and its corresponding memory. If the maximum length of data that can be sent by the sending end is 8KB, that is, the maximum length of data carried by the message of bilateral communication is 8KB, the user program can push the RQE with a length of 8KB to the RQ through the ibv_post_recv interface.

[0083] See also Figure 8 , shows a schematic diagram of another receiving unit of a receiving end and its corresponding memory. Figure 8 The method of sending RQE to the receiving queue in Figure 7 Similarly, the user program can also push RQE to RQ through the ibv_post_recv interface, and the related interface functions remain unchanged, but the length of the memory bound to the sent RQE can be larger than the maximum length of the message data during communication. The receiving end can achieve continuous data reception by sending a larger RQE. For example, if the maximum length is still 8KB, the length of the memory bound to RQE can be larger than 8KB, such as 16KB.

[0084] In a possible implementation, each receiving unit in the receiving queue may include a data storage area and an information storage area, the data storage area is used to store received data, and the information storage area is used to store information corresponding to the receiving unit. The information storage area may include different information domains, and different information domains are used to store different types of information. Accordingly, the first receiving unit may further include a first information storage area on the basis of including the first data storage area, and the first idle length may be stored in the first information storage area.

[0085] For example, see Fig. 9, showing a schematic diagram of the structure of a receiving unit. Taking the receiving unit as RQE1 as an example, the receiving unit includes two areas, a data storage area and an information storage area, and the data storage area and the information storage area are two independent storage areas. The data storage area can be located in a buffer for storing data. The information storage area and the data storage area can be located in different memory locations, and the information storage area can store various information of the receiving unit, such as a work request identity document (wr_id), a scatter / gather list (sg_list), the number of scatter / gather elements (num_sge), the occupied length of the used space and the free length of the free space, and different information is stored in different information domains of the information storage area. For example, the occupied length can be stored in the used domain, and the free length can be stored in the free domain. In a possible implementation, the first free length of the first data storage area in the first receiving unit can be stored in the free domain of the first information storage area in the first receiving unit.

[0086] Among them, wr is sent by the user, and wr is converted into a work queue at the receiving end through the driver. Each wr has a corresponding wr_id to distinguish different wrs. sg_list is an array. An sg_list includes one or more sges, and an sge is a data segment. The number of sges is indicated by num_sge. sg_list can also indicate the starting address of the data storage area of ​​the receiving unit.

[0087] Used space can also be called occupied space or occupied space (e.g. Fig. 9 The memory space represented by the black rectangle in the figure refers to the memory space in the data storage area that has stored other data. The occupied length refers to the length of the space in the data storage area that has stored data, that is, the size of the space used in the data storage area. Free space (e.g. Fig. 9 The memory space represented by the white rectangle in the figure refers to the memory space in the data storage area that does not store any data or any information and is in an idle state, that is, the memory space that is not occupied by any data or any information. The free length refers to the size of the memory in the data storage area that does not store data, that is, the length of the free space in the data storage area. The sum of the occupied length and the free length of any data storage area is the total length of the data storage area. The embodiment of the present application identifies the usage of the memory of the data storage area of ​​the receiving unit by adding a used field and a free field in the information storage area of ​​the receiving unit.

[0088] The embodiment of the present application does not limit the first receiving unit. Optionally, the first receiving unit may be the first or last receiving unit in the receiving queue, or may be the receiving unit with the smallest free space among the receiving units in the receiving queue. In a possible implementation, before receiving the first data, the first data storage area of ​​the first receiving unit may have stored other data, and part of the memory space in the first data storage area is occupied, so that the first data storage area has occupied space and free space, and the length of the free space in the first data storage area is the first free length.

[0089] Optionally, a receiving unit removal mechanism may be provided in the embodiment of the present application. For example, an idle threshold may be set, and based on the relative size of the idle length of the data storage area in each receiving unit and the idle threshold, it is determined whether each receiving unit needs to be removed from the receiving queue. If the idle length of the data storage area in any receiving unit is less than or equal to the idle threshold, the receiving unit may be removed from the receiving queue. The size of the idle threshold may be set based on experience or user needs, and the idle threshold may be, for example, 4KB or 0.

[0090] In the case where there is a receiving unit removal mechanism, if the first idle length is less than or equal to the idle threshold, the first data storage area in the first receiving unit can no longer continue to store other data received subsequently, resulting in the first receiving unit being removed from the receiving queue. Therefore, the first idle length needs to be greater than the idle threshold. If the first idle length of the first data storage area is less than or equal to the idle threshold, it means that the first receiving unit to which the first data storage area belongs is a receiving unit that needs to be removed from the receiving queue, and the first data storage area cannot be used as the target data storage area for the first data, that is, there is no need to compare the first idle length with the first length, so as to avoid performing subsequent operations such as invalid comparison and wasting processing resources. The first idle length and the first length are compared in size while ensuring that the first idle length of the first data storage area is greater than the idle threshold, so as to perform subsequent determination and storage operations.

[0091] In one possible implementation, even if there is a receiving unit removal mechanism and the first idle length is less than or equal to the idle threshold, the receiving end may have received the first data before the first receiving unit is removed from the receiving queue. In this case, the first idle length of the first receiving unit may also be less than or equal to the idle threshold.

[0092] S603, based on the first idle length and the first length, determine a target data storage area for storing the first data, the target data storage area including the first data storage area or the second data storage area of ​​the second receiving unit, the second receiving unit and the first receiving unit being different receiving units in the same receiving queue.

[0093] The embodiment of the present application does not limit the method for determining the target data storage area based on the first free length and the first length. For example, the first free length and the first length can be compared to obtain a comparison result, and the target data storage area can be determined based on the comparison result. The comparison result can indicate whether the free space of the first data storage area can be used to store the first data. Determining whether the free space of the first data storage area is sufficient to store the first data based on the comparison result can provide an effective basis for determining the target data storage area.

[0094] Exemplarily, if the comparison result is that the first length is less than or equal to the first free length, the comparison result indicates that the free space of the first data storage area can be used to store the first data, and the first data storage area can be determined as the target data storage area, thereby reducing the waste of free space in the first data storage area and improving the utilization rate of the first data storage area.

[0095] If the comparison result is that the first length is greater than the first free length, the comparison result indicates that the free space of the first data storage area cannot be used to store the first data, and a second receiving unit can be determined in the receiving queue to which the first receiving unit belongs, and the second data storage area of ​​the second receiving unit can be determined as the target data storage area.

[0096] Optionally, if the first receiving unit is the first receiving unit in the receiving queue, and the receiving units in the receiving queue are consumed in the order of arrangement, the second receiving unit in the receiving queue can be determined as the second receiving unit. If the first receiving unit is the last receiving unit in the receiving queue, and the receiving units in the receiving queue are consumed in the reverse order of arrangement, the second to last receiving unit in the receiving queue can be determined as the second receiving unit.

[0097] If the first receiving unit is the receiving unit with the smallest free length in the receiving queue, the free length of the data storage area in each receiving unit in the receiving queue can be obtained to determine one or more data storage areas with free lengths greater than or equal to the first length. When the number of data storage areas with free lengths greater than or equal to the first length determined is one, the receiving unit to which the data storage area belongs can be determined as the second receiving unit. When the number of data storage areas with free lengths greater than or equal to the first length determined is multiple, the receiving unit with the smallest free length among the multiple receiving units can be determined as the second receiving unit. Regardless of the method by which the second receiving unit is determined, the second data storage area in the second receiving unit can be determined as the target data storage area.

[0098] In a possible implementation, after determining the target data storage area, the position where the first data starts to be stored in the target data storage area and the address corresponding to the position can be further determined. According to the starting address of the target data storage area and the occupied length of the target data storage area, a more accurate storage starting address of the first data can be determined, thereby improving the accuracy of storing the first data. The starting address of any data storage area can be the first address of any data storage area.

[0099] Exemplarily, the starting address and occupied length of the target data storage area may be obtained from the information storage area corresponding to the target data storage area, and the storage start address of the first data may be determined according to the starting address and the occupied length.

[0100] According to different comparison results, the determined target data storage area is different, and thus the determined storage start address is also different. The following takes case 1 and case 2 as examples to illustrate the process of determining the storage start address.

[0101] Case 1: When the comparison result is that the first length is less than or equal to the first free length, the target data storage area is the first data storage area, the starting address is the starting address of the first data storage area, and the occupied length used to calculate the storage start address of the first data is the occupied length of the first data storage area. In this case, the starting address of the first data storage area and the occupied length of the first data storage area can be obtained from the first information storage area. For example, based on the above Fig. 9 It can be seen from the description that the starting address of the first data storage area can be obtained in the sg_list field of the first information storage area, and the occupied length of the first data storage area can be obtained in the used field of the first information storage area.

[0102] After obtaining the occupied length and the starting address of the first data storage area, the sum of the starting address of the first data storage area and the occupied length of the first data storage area can be calculated, and the sum can be determined as the storage start address. For example, if the starting address (address, addr) of the first data storage area is 0xffff0100, the occupied length of the first data storage area is 0xffff0100, and the sum of the occupied length and the starting address is 0xffff0200, 0xffff0200 can be used as the storage start address of the first data.

[0103] In a possible implementation, the starting address of the first data storage area can be used as the reference address, the occupied length of the first data storage area can be used as the offset, and the offset address can be determined based on the reference address and the offset. The determined offset address is the storage start address of the first data.

[0104] Case 2, when the comparison result is that the first length is greater than the first free length, the target data storage area is the second data storage area, the starting address is the starting address of the second data storage area, and the occupied length used to calculate the storage starting address is the occupied length of the second data storage area. In this case, the method for determining the storage starting address is the same as the method for determining the storage starting address when the comparison result is that the first length is less than or equal to the first free length, and will not be repeated here. Optionally, if no data is stored in the second data storage area, the occupied length of the second data storage area can be zero.

[0105] In one possible implementation, the first length is greater than the first free length, indicating that the first data storage area cannot be used to store the first data. In this case, the first receiving unit can be removed from the receiving queue to reduce the number of receiving units in the receiving queue, thereby improving the efficiency of subsequently determining the target data storage area for other data.

[0106] Regardless of whether the comparison result corresponds to case 1 or case 2, after determining the storage start address, the storage end address of the first data can be determined according to the storage start address and the first length. Then, the first data can be stored with the position in the target data storage area indicated by the storage start address as the starting point and the position in the target data storage area indicated by the storage end address as the end point.

[0107] For example, if the storage start address of the first data is 0xffff0200 and the first length is 0xffff0100, the storage end address may be the sum of the storage start address and the first length, that is, 0xffff0300. Optionally, the action of determining the storage end address may be performed before or after storing the first data, which is not limited in the embodiments of the present application.

[0108] The storage end address and the storage start address may indicate a space in the target data storage area for storing the first data, and may make the storage situation of the first data more detailed and accurate.

[0109] S604: Store the first data in the target data storage area.

[0110] After determining the storage start address, the first data can be stored in the target data storage area according to the storage start address. Exemplarily, the first data can be stored starting from the position in the target data storage area indicated by the determined storage start address.

[0111] In a possible implementation, after the storage of the first data is completed, it is also possible to determine whether the receiving unit used to store the first data needs to be removed from the receiving queue after the first data is stored according to the receiving unit removal mechanism. Exemplarily, the second idle length of the target data storage area can be determined, and based on the second idle length being less than or equal to the idle threshold, the receiving unit to which the target data storage area belongs is removed from the receiving queue. The second idle length is the length of the idle space after the target data storage area stores the first data.

[0112] The embodiment of the present application does not limit the method for determining the second idle length. Exemplarily, the difference between the idle length of the data storage area used to store the first data before storing the first data and the first length of the first data can be determined as the second idle length. For example, if the data storage area storing the first data is the first data storage area, the difference between the first idle length and the first length can be determined as the second idle length. If the data storage area storing the first data is the second data storage area, the difference between the idle length of the second data storage area before storing the first data and the first length can be determined as the second idle length.

[0113] If the second idle length is less than or equal to the idle threshold, it can be considered that the target data storage area cannot continue to store the next received data. In this case, the receiving unit to which the target data storage area belongs can be removed from the receiving queue, thereby reducing the number of unavailable receiving units in the receiving queue and improving the efficiency of determining the target data storage area for subsequently received data.

[0114] In a possible implementation, after the first data is stored in the target data storage area, first completion information may be generated, and the first completion information is used to indicate that the first data has been completed. The first completion information may be stored in a completion queue element (CQE) or a completion unit, and after the first completion information is generated, the first completion information may be added to the completion queue.

[0115] Optionally, the first completion information includes at least one of the storage start address, storage end address, second free length and removal flag of the first data. Different information in the first completion information can be stored in different information fields in the CQE. For example, the storage start address of the first data can be stored in the Addr field, the second free length can be stored in the Free field, and the removal flag can be stored in the is_pop field.

[0116] The removal flag in the first completion information indicates whether there is a receiving unit to be removed from the receiving queue in the first receiving unit or the second receiving unit. If the first free length of the first data storage area is less than the first length of the first data but greater than the free threshold, that is, the first data storage area cannot be used to store the first data, then the first receiving unit can be determined as a receiving unit to be removed, regardless of whether the operation of removing the first receiving unit from the receiving queue is completed when the storage of the first data is completed, the removal flag can indicate the existence of a receiving unit to be removed from the receiving queue.

[0117] If the first idle length is not only smaller than the first length but also smaller than the idle threshold, it means that the first receiving unit has been determined as a receiving unit that needs to be removed from the receiving queue after completing the storage of the previous data, that is, the need for the first receiving unit to be removed from the receiving queue is not determined during the process of storing the first data. In this case, although the first receiving unit is removed during the process of storing the first data, the fact that the first receiving unit should be removed is determined by the storage situation corresponding to the previous data, rather than based on the storage situation of the first data. Therefore, if during the process of storing the first data, the receiving unit to which the target data storage area belongs is not determined as a receiving unit that needs to be removed, the removal flag in the first completion information can still indicate that there is no receiving unit that should be removed during the process of storing the first data.

[0118] Regardless of whether the target data storage area is the first data storage area or the second data storage area, if the second idle length of the target data storage area is less than or equal to the idle threshold, it means that in the process of storing the first data, a receiving unit that needs to be removed from the receiving queue is determined. Therefore, the removal flag in the first completion information corresponding to the first data can indicate the existence of a receiving unit that is removed from the receiving queue.

[0119] For example, see Fig.10, showing a storage schematic diagram of a receiving end. RQ includes RQE1 and RQE2, and the idle threshold is 0. The length of the data storage area of ​​RQE1 is 0x400, and the data storage area of ​​RQE1 corresponds to the data stored in SQE1, SQE2 and SQE3. The data length (length, Len) in SQE1 is 0x100, and the storage start address in the buffer is 0xffff0100. Since no data has been stored in the data storage area of ​​RQE1 before the data in SQE1 is stored, the data in SQE1 is the first data stored in the data storage area of ​​RQE1, so the storage start address of the data in SQE1 is the same as the starting address of the data storage area of ​​RQE1. After storing the data in SQE1, the length of the remaining free space in the data storage area of ​​RQE1 becomes 0x300, and the length of the free space is greater than the idle threshold, so there is no need to remove RQE1 from the receiving queue. After completing the data storage of SQE1, CQE1 corresponding to SQE1 is generated. CQE1 includes the storage start address Addr: 0xffff0100 of the data of SQE1, the free length free: 0x300 and the removal flag Is_pop: 0, indicating that no receiving unit is removed.

[0120] The data length in SQE2 is 0x200, and the storage start address in the buffer is 0xffff0200. The storage start address of the data in SQE2 is the sum of the starting address of the data storage area of ​​RQE1 0xffff0100 and the length of the data in SQE1 0x100. After storing the data in SQE2, the length of the remaining free space in the data storage area of ​​RQE1 becomes 0x100. The length of the free space is greater than the free threshold, and there is no need to remove RQE1 from the receiving queue. After completing the data storage of SQE2, CQE2 corresponding to SQE2 is generated. CQE2 includes the storage start address Addr of SQE2 data: 0xffff0200, free length free: 0x100, and removal flag Is_pop: 0, indicating that no receiving unit has been removed.

[0121] The data length in SQE3 is 0x100, and the storage start address in the buffer is 0xffff0400. The storage start address of the data in SQE2 is the sum of the starting address of the data storage area of ​​RQE1 0xffff0100 and the occupied length of the data storage area in SQE1 0x300. After storing the data in SQE3, the length of the remaining free space in the data storage area of ​​RQE1 becomes 0, and the length of the free space is equal to the free threshold, so RQE1 can be removed from the receiving queue. After completing the data storage of SQE3, CQE3 corresponding to SQE3 is generated. CQE3 includes the storage start address Addr of the data of SQE3: 0xffff0400, the free length free: 0, and the removal flag Is_pop: 1, indicating that after completing the data storage in SQE3, RQE1 needs to be removed from the receiving queue.

[0122] In a possible implementation, each completion message can be used by a user to determine the consumption of receiving units in the receiving queue according to the removal identifier in each completion message, so as to determine whether to add a third receiving unit to the receiving queue to ensure that the receiving units in the receiving queue can meet the storage requirements of the subsequently received data. The third receiving unit can be a new receiving unit that has not been used, that is, the data storage area of ​​the third receiving unit has not stored any data.

[0123] For example, the number of receiving units removed from the receiving queue can be determined based on each completion message. If the number of receiving units removed from the receiving queue is greater than or equal to the removal threshold, supplementary information can be sent to the receiving end, and the supplementary information can instruct the receiving end to add a third receiving unit to the receiving queue. The supplementary information can be generated based on the first completion message, or based on multiple completion messages including the first completion message. The removal threshold is used to indicate the maximum number of receiving units that can be removed from the receiving queue. The removal threshold can be set based on experience or user needs, such as 3 or 5.

[0124] Afterwards, the receiving end may receive the supplementary information and, based on the supplementary information, add a third receiving unit to the receiving queue to ensure that the receiving units in the receiving queue are sufficient to store the subsequently received data. Optionally, the supplementary information may include the number of third receiving units, and the receiving end may add third receiving units based on the number. The embodiment of the present application does not limit the number of third receiving units added, and the number of third receiving units may be the same as the number of receiving units removed from the receiving queue, or may be set independently by the user.

[0125] Below, the effect of the data storage method provided in the embodiment of the present application is further explained by comparing with the related technology.

[0126] See also Fig.11 , showing a schematic diagram of data storage in a data storage area in a related art. The SQ on the sending side includes SQE1, SQE2 and SQE3, and the RQ on the receiving side includes RQE1, RQE2 and RQE3. SQE corresponds to RQE one by one, and the length of the data storage area of ​​each RQE is 16KB. The length of the data in SQE1 is 8KB, and 8KB of memory in the data storage area of ​​RQE1 is used to store the data of SQE1, and the remaining 8KB of memory in the data storage area of ​​RQE1 is free space (indicated by a black rectangle). The length of the data in SQE2 is 8KB, and 8KB of memory in the data storage area of ​​RQE2 is used to store the data of SQE2, and the remaining 8KB of memory in the data storage area of ​​RQE2 is free space. The length of the data in SQE3 is 16KB, and 16KB of memory in the data storage area of ​​RQE3 is used to store the data of SQE3, and the remaining memory in the data storage area of ​​RQE3 is 0. The free space in RQE1 and RQE2 cannot be utilized, resulting in memory waste.

[0127] In the same scenario, the data storage method provided by the embodiment of the present application can reduce memory waste. Fig.12 , showing a schematic diagram of data storage in the data storage area of ​​the present application. The SQ on the sending side includes SQE1, SQE2 and SQE3, and the RQ on the receiving side includes RQE1, RQE2 and RQE3, and the length of the data storage area of ​​each RQE is 16KB. The length of the data in SQE1 and SQE2 is 8KB, and 8KB of memory in the data storage area of ​​RQE1 is used to store the data of SQE1, and another 8KB of memory is used to store the data of SQE2, and the remaining memory in the data storage area of ​​RQE1 is 0. The length of the data in SQE3 is 16KB, and 16KB of memory in the data storage area of ​​RQE2 is used to store the data of SQE3, and the remaining memory in the data storage area of ​​RQE2 is 0. The memory space of RQE1 and RQE2 is both utilized, and there is no memory waste, and the 16KB memory (represented by the black rectangle) of the data storage area of ​​RQE3 is not occupied and can be used to store data received later.

[0128] In addition, for the append write operation, the implementation method of the present application embodiment is also different from that of the related art. Fig.13, shows a schematic diagram of a related technology for implementing an append write operation. The related technology for implementing an append write operation can be divided into four steps, from step a1 to step a4. Step a1: The user end sends a request to the storage node through the SEND interface, notifying the length of the data 1 to be written to the storage node, and waits. The user end can also be called a client, the storage node can also be called a server or service device, and the length of the data 1 can be, for example, Fig.13 Step a2: The storage node returns the determined virtual address (VA) of the memory write and the remote key (rkey) corresponding to the virtual address to the user end through the SEND interface. The virtual address can be, for example, Fig.13 The Addr shown in: 0xffff0100. rkey can be a check code corresponding to the virtual address, which is used to verify the accuracy of the virtual address. For example, rkey can be xx. Step a3: The user end writes data 1 to the memory location indicated by the virtual address through the WRITE operation. The length of data 1 written to the memory is the same as the length of data 1 sent by the user end. Step a4: After completing the storage of data 1, the storage node returns an acknowledgment (ACK) message to the user end, indicating that the additional write operation is completed. The time T1 for completing the task of the additional write operation in the related technology is: 2*SEND time + data transmission (write) time + ACK time.

[0129] See also Fig.14 , showing a schematic diagram of the process of implementing an additional write operation in the present application. The process of implementing an additional write operation in the present application may include two steps, step b1 and step b2. Step b1: The user end may send the additional write data 2 and the length of data 2 to the storage node through SEND. The length of data 2 may be, for example, 0x200. Since the storage node has issued the data storage area of ​​the RQE with a larger memory in advance, the user end does not need to send the length of data 2 to the storage node first and wait for the storage node's reply. Step b2: The storage node queries the values ​​in the used and free fields of the information storage area of ​​the RQE, determines the storage start address, and writes the data to the storage start address to complete the additional write task. For example, data 2 may be written to the tail of the address of the last written data 1. After completing the additional write task, the storage node sends a confirmation message to the user end. In the embodiment of the present application, the process of implementing the additional write operation and the data write operation is the same. The time T2 to complete the additional write task is: data transmission time + ACK time. Compared with the related art, the time of SEND is reduced once. Compared with T1, it can be seen that the completion time of the additional write operation is shortened.

[0130] In summary, the data storage method provided by the present application can improve the memory usage rate of the data storage area in the receiving unit, reduce the overall memory waste of the data storage area, and thus reduce memory overhead. In addition, the data storage method provided by the present application corresponds to the consumption mode of the new receiving unit, and a data storage area can be used to store data in multiple or more sending units, and the receiving unit and the sending unit will not be consumed one-to-one. Increasing the number of sending units that can be received by the receiving unit can reduce the number of times the receiving end replenishes the receiving unit, thereby reducing the pressure on the receiving end CPU.

[0131] In addition, the present application adds an information field to the information storage area in the receiving unit to record the memory usage of the data storage area of ​​the receiving unit. By obtaining the free length and occupied length of the data storage area from the information storage area, the efficiency of determining the target data storage area and storage can be improved, and the data storage can be made more accurate.

[0132] The above describes the data storage method provided by the embodiment of the present application. Corresponding to the above method, the embodiment of the present application also provides a data storage device. The device is applied to Figure 4 or Figure 5 The device is used to receive Fig.15 The modules shown above perform the Figure 6 The data storage method in . Fig.15 As shown, the data storage device provided in the embodiment of the present application includes the following modules.

[0133] A receiving module 1501 is used to receive first data, where the length of the first data is a first length; an acquiring module 1502 is used to acquire a first free length of a first data storage area in a first receiving unit, where the first free length is the length of free space in the first data storage area; a determining module 1503 is used to determine a target data storage area for storing the first data based on the first free length and the first length, where the target data storage area includes the first data storage area or the second data storage area of ​​the second receiving unit, where the second receiving unit and the first receiving unit are different receiving units in the same receiving queue; a storing module 1504 is used to store the first data in the target data storage area.

[0134] In a possible implementation manner, the first receiving unit further includes a first information storage area, and the first idle length is stored in the first information storage area.

[0135] In a possible implementation, the receiving module 1501 is configured to receive a first message, where the first message includes first data and a first length of the first data; and obtain the first data and the first length from the first message.

[0136] In a possible implementation, the determination module 1503 is used to compare the first free length and the first length to obtain a comparison result, which indicates whether the free space in the first data storage area can be used to store the first data; and determine the target data storage area according to the comparison result.

[0137] In a possible implementation, the acquisition module 1502 is further used to obtain the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, where the occupied length is the length of the space in which data has been stored in the target data storage area, and the starting address is the first address of the target data storage area; the determination module 1503 is further used to determine the storage starting address of the first data based on the starting address and the occupied length; the storage module 1504 is used to store the first data starting from the position in the target data storage area indicated by the storage starting address.

[0138] In a possible implementation, the acquisition module 1502 is further used to obtain the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, where the occupied length is the length of the space in which data has been stored in the target data storage area, and the starting address is the first address of the target data storage area; the determination module 1503 is further used to determine the storage starting address of the first data based on the starting address and the occupied length; determine the storage ending address of the first data based on the storage starting address and the first length; the storage module 1504 is used to store the first data with the position in the target data storage area indicated by the storage starting address as the starting point and the position in the target data storage area indicated by the storage ending address as the end point.

[0139] In a possible implementation, when the comparison result is that the first length is less than or equal to the first free length, the target data storage area is the first data storage area, the starting address is the starting address of the first data storage area, and the occupied length is the occupied length of the first data storage area.

[0140] In a possible implementation, when the comparison result is that the first length is greater than the first free length, the target data storage area is the second data storage area, the start address is the start address of the second data storage area, and the occupied length is the occupied length of the second data storage area.

[0141] In a possible implementation, the device further includes a removing module, which is configured to remove the first receiving unit from the receiving queue.

[0142] In one possible implementation, the determination module 1503 is also used to determine a second free length of the target data storage area, where the second free length is the length of the free space after the target data storage area stores the first data; the removal module is also used to remove the receiving unit to which the target data storage area belongs from the receiving queue based on the second free length being less than or equal to the free threshold.

[0143] In one possible implementation, the device also includes a generation module, which is used to generate first completion information, the first completion information is used to indicate that the first data has been stored, the first completion information includes at least one of the storage start address, storage end address, second free length and removal flag of the first data, the removal flag indicates whether there is a receiving unit removed from the receiving queue in the first receiving unit or the second receiving unit, and the first completion information is used to determine whether to add a third receiving unit to the receiving queue.

[0144] In a possible implementation, the receiving module 1501 is further used to receive supplementary information, where the supplementary information is determined based on the first completion information; the device also includes an adding module, where the adding module is used to add a third receiving unit to the receiving queue according to the supplementary information.

[0145] In a possible implementation, the first idle length is greater than an idle threshold.

[0146] It should be understood that the above Fig.15 The device provided has the following beneficial effects when achieving its function: Figure 6 The data storage method provided has the same beneficial effects, which will not be described here. Fig.15 When the device provided realizes its functions, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0147] See also Fig.16 , Fig.16 A schematic structural diagram of an exemplary data storage device 1600 of the present application is shown. The data storage device 1600 includes at least one processor 1601 , a memory 1603 , and at least one network interface 1604 .

[0148] Processor 1601 is, for example, a general-purpose central processing unit, a digital signal processor (DSP), a network processor (NP), a GPU, a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits or application-specific integrated circuits (ASICs) for implementing the solution of the present application, a programmable logic device (PLD), other general-purpose processors or other programmable logic devices, discrete gates, transistor logic devices, discrete hardware components, or any combination thereof. PLD is, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. A general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting an advanced RISC machines (ARM) architecture. It may implement or execute various logic blocks, modules, and circuits described in conjunction with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and so on.

[0149] Optionally, the data storage device 1600 further includes a bus 1602. The bus 1602 is used to transmit information between the components of the data storage device 1600. The bus 1602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus 1602 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.16 The fact that only one line is used in the diagram does not mean that there is only one bus or only one type of bus.

[0150] The memory 1603 is, for example, a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Among them, the nonvolatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache.

[0151] By way of example but not limitation, many forms of ROM and RAM are available. For example, ROM is a compact disc read-only memory (CD-ROM). RAM includes, but is not limited to, static RAM (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM).

[0152] The memory 1603 may also be other types of storage devices that can store static information and instructions. Or it may be other types of dynamic storage devices that can store information and instructions. Or it may be other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, blue-ray disk, etc.), magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by the computer, but is not limited to this. The memory 1603, for example, exists independently and is connected to the processor 1601 through the bus 1602. The memory 1603 may also be integrated with the processor 1601.

[0153] The network interface 1604 uses any transceiver-like device to communicate with other devices or communication networks, and the communication network can be Ethernet, radio access network (RAN) or wireless local area network (WLAN), etc. The network interface 1604 may include a wired network interface and may also include a wireless network interface. Specifically, the network interface 1604 may be an Ethernet interface, such as a Fast Ethernet (FE) interface, a Gigabit Ethernet (GE) interface, an Asynchronous Transfer Mode (ATM) interface, a WLAN interface, a cellular network interface or a combination thereof. The Ethernet interface may be an optical interface, an electrical interface or a combination thereof. In some embodiments of the present application, the network interface 1604 may be used for the data storage device 1600 to communicate with other devices.

[0154] In a specific implementation, as some embodiments, the processor 1601 may include one or more CPUs, such as Fig.16 0 and CPU1 shown in FIG. Each of these processors may be a single-core processor or a multi-core processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).

[0155] In a specific implementation, as some embodiments, the data storage device 1600 may include multiple processors, such as Fig.16 1 and 1605. Each of these processors may be a single-core processor or a multi-core processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0156] In some implementations, the memory 1603 is used to store program instructions 1610 for executing the solution of the present application, and the processor 1601 can execute the program instructions 1610 stored in the memory 1603. That is, the data storage device 1600 can implement the method provided in the method embodiment through the processor 1601 and the program instructions 1610 in the memory 1603, that is, Figure 6 The program instruction 1610 may include one or more software modules. Optionally, the processor 1601 itself may also store program instructions for executing the solution of the present application.

[0157] In a specific implementation process, the data storage device 1600 of the present application may correspond to a first network element device for executing the above method, and the processor 1601 in the data storage device 1600 reads the instructions in the memory 1603, so that Fig.16 The data storage device 1600 shown is capable of executing all or part of the steps in the method embodiment.

[0158] The data storage device 1600 may also correspond to the above Fig.15 The device shown, Fig.15 Each functional module in the illustrated apparatus is implemented using software of the data storage device 1600. In other words, Fig.15 The functional modules included in the illustrated apparatus are generated after the processor 1601 of the data storage device 1600 reads the program instructions 1610 stored in the memory 1603 .

[0159] in, Figure 6 Each step of the method shown is completed by an integrated logic circuit of hardware or software instructions in the processor of the data storage device 1600. The steps of the method embodiment disclosed in the present application can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor. The software module 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, and the processor reads the information in the memory and completes the steps of the above method embodiment in combination with its hardware. To avoid repetition, it will not be described in detail here.

[0160] In an exemplary embodiment, a data storage system is provided, the data storage system comprising a receiving device and a sending device, the receiving device is used to perform Figure 6 In the method shown, a sending device is used to send data to a receiving device.

[0161] In an exemplary embodiment, a computer program (product) is provided, the computer program (product) comprising: a computer program code, when the computer program code is executed by a computer, the computer executes Figure 6 The method shown.

[0162] In an exemplary embodiment, a computer-readable storage medium is provided, the computer-readable storage medium storing a program or instruction, when the program or instruction is executed on a computer, the computer executes the above Figure 6 The method shown.

[0163] In an exemplary embodiment, a chip is provided, including a processor for calling and executing instructions stored in a memory, so that a computer equipped with the chip executes Figure 6 The method shown.

[0164] In an exemplary embodiment, another chip is provided, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected through an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the computer equipped with the chip executes Figure 6 The method shown.

[0165] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in this application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk), etc.

[0166] In this application, the terms "first", "second", etc. are used to distinguish between identical or similar items with substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is there a limitation on the quantity and execution order. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another element.

[0167] It should also be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0168] The term "at least one" in this application means one or more, and the term "multiple" in this application means two or more, for example, multiple second devices means two or more second devices. The terms "system" and "network" are often used interchangeably herein.

[0169] It should be understood that the terms used in the description of the various examples herein are only for describing specific examples and are not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0170] It should also be understood that the term "and / or" used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. The term "and / or" is a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.

[0171] It should also be understood that the terms "if" and "if" may be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting." Similarly, the phrases "if it is determined that ..." or "if [a stated condition or event] is detected" may be interpreted to mean "upon determining that ..." or "in response to determining that ..." or "upon detecting [a stated condition or event]" or "in response to detecting [a stated condition or event]," depending on the context.

[0172] The above description is only an embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data storage method, characterized in that: The method comprises: receiving first data, wherein the length of the first data is a first length; Acquire a first free length of a first data storage area in a first receiving unit, where the first free length is the length of free space in the first data storage area; Determine a target data storage area for storing the first data based on the first idle length and the first length, the target data storage area including the first data storage area or a second data storage area of ​​a second receiving unit, the second receiving unit and the first receiving unit being different receiving units in the same receiving queue; The first data is stored in the target data storage area.

2. The method according to claim 1, characterized in that The first receiving unit further includes a first information storage area, and the first idle length is stored in the first information storage area.

3. The method according to claim 1 or 2, characterized in that: The receiving first data comprises: receiving a first message, wherein the first message includes the first data and a first length of the first data; The first data and the first length are obtained from the first message.

4. The method according to any one of claims 1 to 3, characterized in that: The determining, based on the first idle length and the first length, a target data storage area for storing the first data comprises: comparing the first free length and the first length to obtain a comparison result, wherein the comparison result indicates whether the free space of the first data storage area can be used to store the first data; The target data storage area is determined according to the comparison result.

5. The method according to any one of claims 1 to 4, characterized in that: After determining the target data storage area for storing the first data, the method further includes: Acquire the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, wherein the occupied length is the length of the space in which data has been stored in the target data storage area, and the starting address is the first address of the target data storage area; Determine a storage start address of the first data according to the start address and the occupied length; The storing the first data into the target data storage area comprises: The first data is stored starting from the position in the target data storage area indicated by the storage start address.

6. The method according to any one of claims 1 to 4, characterized in that: After determining the target data storage area for storing the first data, the method further includes: Acquire the starting address and occupied length of the target data storage area from the information storage area corresponding to the target data storage area, wherein the occupied length is the length of the space in which data has been stored in the target data storage area, and the starting address is the first address of the target data storage area; Determine a storage start address of the first data according to the start address and the occupied length; Determining a storage end address of the first data according to the storage start address and the first length; The storing the first data into the target data storage area comprises: The first data is stored with the position in the target data storage area indicated by the storage start address as a starting point and the position in the target data storage area indicated by the storage end address as an end point.

7. The method according to any one of claims 4 to 6, characterized in that: When the comparison result is that the first length is less than or equal to the first free length, the target data storage area is the first data storage area, the start address is the start address of the first data storage area, and the occupied length is the occupied length of the first data storage area.

8. The method according to any one of claims 4 to 6, characterized in that: When the comparison result is that the first length is greater than the first free length, the target data storage area is the second data storage area, the start address is the start address of the second data storage area, and the occupied length is the occupied length of the second data storage area.

9. The method according to claim 8, characterized in that After comparing the first idle length and the first length to obtain a comparison result, the method further includes: The first receiving unit is removed from the receiving queue.

10. The method according to any one of claims 1 to 9, characterized in that: After storing the first data in the target data storage area, the method further includes: Determine a second free length of the target data storage area, where the second free length is the length of free space in the target data storage area after the first data is stored; Based on the second idle length being less than or equal to an idle threshold, the receiving unit to which the target data storage area belongs is removed from the receiving queue.

11. The method according to any one of claims 1 to 10, characterized in that: After storing the first data in the target data storage area, the method further includes: Generate first completion information, the first completion information is used to indicate that the first data has been stored, the first completion information includes at least one of the storage start address, storage end address, second free length and removal flag of the first data, the removal flag indicates whether there is a receiving unit removed from the receiving queue in the first receiving unit or the second receiving unit, and the first completion information is used to determine whether to add a third receiving unit to the receiving queue.

12. The method according to claim 11, characterized in that After generating the first completion information, the method further includes: receiving supplementary information, the supplementary information being determined based on the first completion information; According to the supplementary information, the third receiving unit is added to the receiving queue.

13. The method according to any one of claims 1 to 12, characterized in that: The first idle length is greater than an idle threshold.

14. A data storage device, characterized in that: The device comprises: A receiving module, configured to receive first data, wherein the length of the first data is a first length; An acquisition module, configured to acquire a first idle length of a first data storage area in a first receiving unit, wherein the first idle length is a length of an idle space in the first data storage area; a determination module, configured to determine, based on the first idle length and the first length, a target data storage area for storing the first data, wherein the target data storage area includes the first data storage area or a second data storage area of ​​a second receiving unit, and the second receiving unit and the first receiving unit are different receiving units in the same receiving queue; A storage module is used to store the first data in the target data storage area.

15. A data storage device, characterized in that: The device includes a processor coupled to a memory; the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor so that the data storage device implements the data storage method described in any one of claims 1-13.

16. A data storage system, characterized in that: The data storage system comprises a sending device and a receiving device, wherein the receiving device is used to execute the data storage method according to any one of claims 1 to 13, and the sending device is used to send data to the receiving device.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the instruction is loaded and executed by the processor to implement the data storage method according to any one of claims 1 to 13.

18. A computer program product, characterized in that The computer program product comprises a computer program or instructions, and the computer program or instructions are executed by a processor to enable a computer to implement the data storage method according to any one of claims 1 to 13.

Citation Information

Cited By

  • Data storage method and apparatus, device, and computer readable storage medium

    EP4797653A1

  • Data storage method and apparatus, device, and computer readable storage medium

    WO2025092402A1