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

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

WO2025092402A1PCT designated stage expired Publication Date: 2025-05-08HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/124541
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-10-30
Filing Date
2024-10-12
Publication Date
2025-05-08

AI Technical Summary

Technical Problem

In the communication system, the waste of free space in the data storage area is severe, resulting in insufficiency of storage.

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, and the utilization rate of the data storage area is optimized.

Benefits of technology

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

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024124541_08052025_PF_FP_ABST
    Figure CN2024124541_08052025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of communications, and discloses a data storage method and apparatus, a device, and a computer readable storage medium. The method comprises: receiving first data of a first length; acquiring a first idle length of a first data storage area of a first receiving unit, wherein the first idle length is the length of an idle space in the first data storage area; on the basis of the first idle length and the first length, determining 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 a same receiving queue; and storing the first data to the target data storage area. According to the present application, the first data is stored on the basis of the first idle length and the first length, so that the waste of idle spaces in data storage areas can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

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

[0001] This application claims priority to Chinese patent application number 202311424812.4, filed on October 30, 2023, entitled “Data Storage Method, Apparatus, Device and Computer-Readable Storage Medium,” the entire contents of which are incorporated herein by reference. Technical Field

[0002] The present application relates to the field of communication technology, and in particular to data storage methods, devices, equipment, and computer-readable storage media. Background Art

[0003] In a communication system, two nodes communicate and interact by sending and receiving messages. A sending node sends a message to a receiving node. The receiving node receives the message through a generated receiving unit and stores the data in the message for subsequent processing.

[0004] Summary of the Invention

[0005] 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:

[0006] 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 the free space in the first data storage area; determining 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; and storing the first data in the target data storage area.

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

[0008] In one 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. Storing the first idle length in the first information storage area of ​​the first receiving unit can improve the efficiency of obtaining the first idle length, reduce the time required to determine the target data storage area, and improve data storage efficiency.

[0009] In one 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. Receiving the first message enables synchronous acquisition of the first data and the first length, thereby improving efficiency in obtaining the first data and the first length.

[0010] In one 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 in the first data storage area can be used to store the first data; and determining the target data storage area based on the comparison result. Determining whether the free space in 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.

[0011] In one possible implementation, after determining a target data storage area for storing the first data, the method further includes: obtaining a starting address and an occupied length of the target data storage area from an information storage area corresponding to the target data storage area, where the occupied length is the length of the space in the target data storage area where data is already stored, and the starting address is the first address of the target data storage area; determining a storage starting address for the first data based on the starting address and the occupied length; and storing the first data in the target data storage area includes storing the first data starting from a position in the target data storage area indicated by the storage starting address. Based on 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.

[0012] In one possible implementation, after determining a target data storage area for storing the first data, the method further includes: obtaining a starting address and an occupied length of the target data storage area from an information storage area corresponding to the target data storage area, where the occupied length is the length of the space in the target data storage area where data has been stored, and the starting address is the first address of the target data storage area; determining a storage starting address for the first data based on the starting address and the occupied length; determining a storage ending address for the first data based on the storage starting address and the first length; and 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 ending 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.

[0013] In one possible implementation, if the comparison result shows 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, indicating that the free space in the first data storage area is sufficient to store the first data, the first data storage area can be determined as the target data storage area, thereby reducing waste of free space in the first data storage area and improving the utilization rate of the first data storage area.

[0014] In one possible implementation, if the comparison result shows 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 in 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, thereby ensuring more accurate storage of the first data.

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

[0016] In one possible implementation, after storing the first data in the target data storage area, the method further includes: determining 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 storing the first data; and removing 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 an free threshold. If the length of free space in the target data storage area after storing the first data is less than the free threshold, it can be considered that the target data storage area is unable to continue to store other subsequently received data, and removing the receiving unit to which the target data storage area belongs from the receiving queue can improve the efficiency of subsequently determining the target data storage area for other data.

[0017] In one possible implementation, after storing the first data in the target data storage area, the method further includes: generating first completion information, the first completion information being used to indicate that the first data has been stored, the first completion information including at least one of the storage start address, storage end address, second free length, and removal identifier of the first data, the removal identifier indicating whether there is a receiving unit in the first receiving unit or the second receiving unit that has been removed from the receiving queue, and the first completion information being used to determine whether to add a third receiving unit to the receiving queue. The first completion information generated based on the storage status 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 subsequently received data.

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

[0019] In one possible implementation, the first idle length is greater than an idle threshold. If the first idle length of the first data storage area is less than or equal to the idle threshold, it indicates 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 serve as the target data storage area for the first data. This means that there is no need to compare the first idle length with the first length, thereby avoiding the waste of processing resources by performing subsequent operations such as invalid comparisons. Furthermore, 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 facilitate subsequent determination and storage operations.

[0020] In a second aspect, a data storage device is provided, the device comprising: a receiving module for receiving first data, the length of the first data being a first length; an acquiring module for acquiring 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 for determining 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 for storing the first data to the target data storage area.

[0021] 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.

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

[0023] In a possible implementation, the determination module is configured to compare the first free length and the first length to obtain a comparison result indicating 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 based on the comparison result.

[0024] In one 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; and 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.

[0025] In one 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; determine the storage ending address of the first data based on the storage starting address and the first length; and 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.

[0026] 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.

[0027] 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.

[0028] In a possible implementation, the apparatus further includes a removing module, configured to remove the first receiving unit from the receiving queue.

[0029] In one possible implementation, the determination module is also used to determine the second idle length of the target data storage area, where the second idle length is the length of the idle 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 idle length being less than or equal to the idle threshold.

[0030] 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 idle length and removal identifier of the first data, the removal identifier indicates whether there is a receiving unit in the first receiving unit or the second receiving unit that has been removed from the receiving queue, and the first completion information is used to determine whether to add a third receiving unit to the receiving queue.

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

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

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

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

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

[0036] 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.

[0037] 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 the 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.

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

[0039] In a seventh aspect, a computer program (product) is provided, which includes: computer program code, which, when executed by a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.

[0040] In an eighth aspect, a computer-readable storage medium is provided, which 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.

[0041] In a ninth aspect, a chip is provided, comprising a processor for calling and executing instructions stored in a memory from 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.

[0042] 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 through 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.

[0043] It should be understood that the beneficial effects achieved by the technical solutions of the second to tenth aspects of this 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

[0044] FIG1 is 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;

[0045] FIG2 is a schematic diagram of a communication process in a communication scenario of a dating protocol mode provided by an embodiment of the present application;

[0046] FIG3 is a schematic diagram of a communication process of a related technology provided by an embodiment of the present application;

[0047] FIG4 is a schematic diagram of an implementation scenario provided in an embodiment of the present application;

[0048] FIG5 is a schematic diagram of an implementation scenario based on a network card provided in an embodiment of the present application;

[0049] FIG6 is a flow chart of a data storage method provided in an embodiment of the present application;

[0050] FIG7 is a schematic diagram of a receiving unit of a receiving end and its corresponding memory provided in an embodiment of the present application;

[0051] FIG8 is a schematic diagram of another receiving unit of a receiving end and its corresponding memory provided in an embodiment of the present application;

[0052] FIG9 is a schematic structural diagram of a receiving unit provided in an embodiment of the present application;

[0053] FIG10 is a schematic diagram of storage at a receiving end provided in an embodiment of the present application;

[0054] FIG11 is a schematic diagram of data storage in a data storage area according to a related art provided by an embodiment of the present application;

[0055] FIG12 is a schematic diagram of data storage in a data storage area of ​​the present application provided by an embodiment of the present application;

[0056] FIG13 is a schematic diagram of a process for implementing an additional write operation using a related technology provided by an embodiment of the present application;

[0057] FIG14 is a schematic diagram of a process for implementing an additional write operation according to an embodiment of the present application;

[0058] FIG15 is a schematic structural diagram of a data storage device provided in an embodiment of the present application;

[0059] FIG16 is a schematic structural diagram of a data storage device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] 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.

[0061] In a communication system, two nodes communicate and interact by sending and receiving messages. For example, a data center network (DCN) is one type of communication network within a communication system. In a DCN, two nodes can communicate and interact by sending messages to each other based on a transport layer protocol called remote direct memory access (RDMA). RDMA is a technology that bypasses the kernel of the remote host's operating system to access data in memory. Because RDMA bypasses the operating system when accessing data and offloads the protocol stack via the network interface card (NIC) hardware, achieving zero-copy and kernel-bypass data transmission, RDMA not only saves significant central processing unit (CPU) resources and reduces CPU usage, but also improves system throughput and reduces network communication latency. This meets the demands of compute- and storage-intensive applications in DCNs, and is therefore widely used in massively parallel computer clusters within DCNs.

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

[0063] Whether in unilateral or bilateral communication mode, in the RoCE, RoCEv2, or IB protocols, the transmission unit for interaction between the sender and receiver can be a message (msg). A message corresponds to a transmission request from the applications supported by the sender and receiver. The length of each message can vary, and the maximum message length can be set based on the transmission capabilities of the sender and receiver, for example, 2 gigabytes (GB). When the length of a message exceeds the maximum transmission unit (MTU) of the path, the message can be split into multiple packets, which the sender sends to the receiver in sequence to complete the message transmission.

[0064] The bilateral communication mode uses the send-receive (SEND-Recv) bilateral communication primitive when transmitting messages, which requires the participation of both communicating parties, that is, both the sender and the receiver must 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. MPI protocol modes include but are not limited to the Eager protocol mode and the Rendezvous protocol mode. In the Eager protocol mode, when sending a message, the sender assumes that the receiver can store the data. In the Rendezvous protocol mode, the sender requires confirmation from 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 during the communication process to perform SEND-Recv operations.

[0065] For example, see Figure 1, which shows a schematic diagram of the communication process in a communication scenario using the Eager protocol mode. In the MPI Eager protocol mode, the requester sends a message to the responder, allowing both the requester and the responder to participate in the communication process, thus achieving bilateral communication between the requester and the responder. The requester is the sender, and the responder is the receiver.

[0066] Figure 2 shows a schematic diagram of the communication process in a Rendezvous protocol scenario. In this MPI Rendezvous protocol, the requester sends a message to the responder. The responder then sends a read request based on the message. The requester then returns a read response based on the read request, achieving bilateral communication between the requester and the responder.

[0067] In one possible implementation, in a bilateral communication scenario using RDMA-based SEND-Recv, before a sender and a receiver communicate, that is, before the sender sends a message to the receiver, the sender and the receiver can each establish a work queue (WQ). The receiver's receive action must precede the sender's send (SEND) action before the sender can send data to the receiver. The work queue established by the sender is called a send queue (SQ), and the work queue established by the receiver is called a receive queue (RQ). The receive queue and the send queue can be referred to as a queue pair (QP), and different queue pairs are distinguished by different queue pair numbers (QPN). A send queue can include multiple send queue elements (SQEs), which can also be referred to as send elements. A receive queue can include multiple receive queue elements (RQEs), which can also be referred to as receive elements.

[0068] Taking the RQE establishment process as an example, the receiving end can use ibv_post_recv (an interface used to place work requests in the receive queue) to send or place multiple RQEs to the RQ. The receiving end can register the memory corresponding to each RQE. The registered memory region (MR) is used to store the incoming data and the information corresponding to the RQE. The memory region used to store data can be called a data storage region, which can be located in the receiving end's buffer. The memory region used to store information corresponding to the RQE can be called an information storage region, which can be located in the buffer or other memory areas of the receiving end.

[0069] After both the sender and the receiver have established work queues, the sender can send messages 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 base 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 can be 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 packet sequence number of the retransmitted data packet will be the same as the packet sequence number when the data packet was first sent.

[0070] 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.

[0071] In the related art, the receiving mechanism of the receiving end is that regardless of 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.

[0072] In the related art, the receiving end consumes the RQEs in the receive queue at a high rate, resulting in a high demand for RQEs. RQEs need to be continuously replenished to accommodate a large number of SQEs, which consumes significant CPU resources on the receiving end. Furthermore, if the length of 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.

[0073] Referring to Figure 3, a schematic diagram of a communication process in a related art is shown. The maximum length of data that can be sent by the sender is 64 kilobytes (KB), so the length of the data storage area in each RQE issued by the receiver can be 64KB. The lengths of the data in the multiple SQEs sent by the sender to the receiver are 16KB, 32KB, 8KB, and 64KB, respectively. The RQEs issued by the receiver are consumed in a one-to-one ratio with the SQEs. When the data length 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 remains (indicated by the white rectangle). The remaining memory space cannot store data, resulting in memory waste.

[0074] An embodiment of the present application provides a data storage method that can reduce memory waste. The method can be applied to, but is not limited to, communication scenarios based on RDMA technology. For example, see Figure 4, which shows a schematic diagram of an implementation scenario. The implementation scenario includes a sending end 41 and a receiving end 42, and the sending end 41 and the receiving end 42 are connected to each other via wired or wireless communication. The sending end 41 and the receiving end 42 can be deployed on the same device or on different devices. The sending end 41 can interact with one or more receiving ends 42, and the receiving end 42 can also interact with one or more sending ends 41. The sending end 41 can send messages to the receiving end 42, and the receiving end 42 can receive messages sent by the sending end 41 and store the data in the messages.

[0075] In one 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 offload transport layer protocol stack function. A network card with a hardware offload transport layer protocol stack function can offload 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.

[0076] Figure 5 illustrates a network interface card (NIC)-based implementation scenario. Two communication nodes, each equipped with a NIC, serve as a transmitter and a receiver, respectively. These nodes are connected via a transport network to enable communication. The transport network can include one or more communication devices capable of forwarding, such as switches or top-of-rack (ToR) switches.

[0077] Both NICs can be NICs with hardware offload transport layer protocol stack function. The transport layer protocol stack targeted by the NIC includes the physical (PHY) layer, media access control (MAC) layer, internet protocol (IP) layer and transport layer.

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

[0079] S601: Receive first data, where the length of the first data is a first length.

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

[0081] The embodiment of the present application does not limit the method for determining the length of the first data. Optionally, the sending 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 be obtained separately at different times, which is not limited by the present application.

[0082] In another method for 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. Because the first data may be lost during transmission 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.

[0083] S602 : 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.

[0084] In one possible implementation, after the sender and receiver establish a link, the receiver can pre-register memory for storing data and send the RQE bound to the memory to the RQ via the ibv_post_recv interface. For example, see Figure 7, which shows a schematic diagram of a receiving unit and its corresponding memory on the receiver side. If the maximum length of data that the sender can send is 8KB, that is, the maximum length of data carried by a message in bilateral communication is 8KB, the user program can push an 8KB RQE to the RQ via the ibv_post_recv interface.

[0085] Referring to Figure 8 , a schematic diagram of another receiving end receiving unit and its corresponding memory is shown. The method for sending an RQE to the receive queue in Figure 8 is the same as that in Figure 7 . The user program can also push the RQE to the RQ through the ibv_post_recv interface, and the relevant interface functions remain unchanged. However, the length of the memory bound to the sent RQE can be larger than the maximum length of the message data during communication. By sending a larger RQE, the receiving end can achieve continuous data reception. For example, if the maximum length is still 8KB, the length of the memory bound to the RQE can be larger than 8KB, such as 16KB.

[0086] In one 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 fields, each of which is used to store different types of information. Accordingly, the first receiving unit may further include a first information storage area in addition to the first data storage area, and the first idle length may be stored in the first information storage area.

[0087] For example, referring to FIG9 , a schematic diagram of the structure of a receiving unit is shown. Taking the receiving unit RQE1 as an example, the receiving unit includes two areas: a data storage area and an information storage area. 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. 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 used space, and the free length of free space. Different information is stored in different information fields of the information storage area. For example, the occupied length can be stored in the used field, and the free length can be stored in the free field. In one possible implementation, the first free length of the first data storage area in the first receiving unit can be stored in the free field of the first information storage area in the first receiving unit.

[0088] The wr is sent by the user and converted into a work queue by the driver at the receiving end. Each wr has a corresponding wr_id to distinguish different wrs. sg_list is an array containing one or more sges, each representing a data segment. The number of sges is indicated by num_sge. sg_list can also indicate the starting address of the receiving unit's data storage area.

[0089] Used space can also be referred to as occupied space or occupied space (such as the memory space represented by the black rectangle in Figure 9), which refers to the memory space in the data storage area where other data has been stored. Occupied length refers to the length of the space in the data storage area where data has been stored, that is, the size of the used space in the data storage area. Free space (such as the memory space represented by the white rectangle in Figure 9) 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. Free length refers to the size of the memory in the data storage area where no data is stored, that is, the length of the free space in the data storage area. The sum of the occupied length and free length of any data storage area is the total length of the data storage area. The embodiment of the present application identifies the memory usage 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.

[0090] The embodiments of the present application do not limit the first receiving unit. Optionally, the first receiving unit can be the first or last receiving unit in the receiving queue, or can be the receiving unit with the least free space among the receiving units in the receiving queue. In one possible implementation, before receiving the first data, the first data storage area of ​​the first receiving unit may have already stored other data, and the memory space in the first data storage area is partially occupied. Therefore, 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.

[0091] Optionally, embodiments of the present application may include a receiving unit removal mechanism. 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, a determination is made as to 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 idle threshold may be set based on experience or user needs, and may be, for example, 4 KB or 0.

[0092] In the presence of 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 subsequently received data, causing the first receiving unit to be 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, avoiding performing invalid comparisons and other subsequent operations and wasting processing resources. While ensuring that the first idle length of the first data storage area is greater than the idle threshold, the first idle length and the first length are compared in size for subsequent determination and storage operations.

[0093] 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.

[0094] S603, based on the first idle length and the first length, determining 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.

[0095] The embodiments of the present application do 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 in the first data storage area can be used to store the first data. Determining whether the free space in 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.

[0096] 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.

[0097] 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.

[0098] 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 may 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 may be determined as the second receiving unit.

[0099] 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 a free length greater than or equal to the first length. When the number of data storage areas with a free length 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 a free length 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.

[0100] In one possible implementation, after determining the target data storage area, the location where the first data is to be stored, as well as the address corresponding to that location, can be further determined within the target data storage area. Based on the starting address of the target data storage area and the occupied length of the target data storage area, a more accurate starting address for storing 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.

[0101] 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.

[0102] According to different comparison results, the target data storage area is determined to be different, and thus the storage start address is also determined to be different. The process of determining the storage start address is described below using Case 1 and Case 2 as examples.

[0103] In case 1, when the comparison result shows 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 previous description of FIG. 9 , the starting address of the first data storage area can be obtained from the sg_list field of the first information storage area, and the occupied length of the first data storage area can be obtained from the used field of the first information storage area.

[0104] After obtaining the occupied length and 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 starting address. For example, if the starting 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, then 0xffff0200 can be used as the storage starting address of the first data.

[0105] 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.

[0106] In Case 2, if 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.

[0107] 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.

[0108] Regardless of whether the comparison result corresponds to Case 1 or Case 2 for determining the storage start address, after determining the storage start address, the storage end address of the first data can be determined based on the storage start address and the first length. The first data can then be stored starting from the location in the target data storage area indicated by the storage start address and ending at the location in the target data storage area indicated by the storage end address.

[0109] 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, and this embodiment of the application is not limited thereto.

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

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

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

[0113] In one possible implementation, after the first data is stored, a determination can be made based on a receiving unit removal mechanism to determine whether the receiving unit used to store the first data needs to be removed from the receiving queue after storing the first data. For example, a 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 an idle threshold, the receiving unit to which the target data storage area belongs can be removed from the receiving queue. The second idle length is the length of the free space in the target data storage area after the first data is stored.

[0114] The embodiments of the present application do not limit the method for determining the second idle length. For example, the difference between the idle length of the data storage area used to store the first data before the first data is stored 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 the first data is stored and the first length can be determined as the second idle length.

[0115] 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, then 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.

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

[0117] 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.

[0118] The removal flag in the first completion information indicates whether there is a receiving unit in the first receiving unit or the second receiving unit that has been removed from the receiving queue. 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 that needs 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 that has been removed from the receiving queue.

[0119] 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 identifier 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.

[0120] 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 identifier in the first completion information corresponding to the first data can indicate that there is a receiving unit that needs to be removed from the receiving queue.

[0121] For example, see Figure 10, which shows a storage 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 was stored in the data storage area of ​​RQE1 before the data in SQE1 was 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 the data in SQE1 is stored, the length of the remaining free space in the data storage area of ​​RQE1 becomes 0x300. The length of the free space is greater than the idle threshold, and there is no need to remove RQE1 from the receiving queue. After the data storage of SQE1 is completed, 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.

[0122] 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 RQE1's data storage area, 0xffff0100, and the length of the data in SQE1, 0x100. After storing the data in SQE2, the length of the remaining free space in RQE1's data storage area becomes 0x100. The length of the free space is greater than the free threshold, so there is no need to remove RQE1 from the receive queue. After the data storage of SQE2 is completed, CQE2 corresponding to SQE2 is generated. CQE2 includes the storage start address of SQE2's data, Addr: 0xffff0200, the free length free: 0x100, and the removal flag Is_pop: 0, indicating that no receiving unit has been removed.

[0123] 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 RQE1's data storage area, 0xffff0100, and the occupied length of SQE1's data storage area, 0x300. After storing the data in SQE3, the length of the remaining free space in RQE1's data storage area becomes 0. The length of the free space is equal to the idle threshold, and RQE1 can be removed from the receive queue. After the data storage of SQE3 is completed, CQE3 corresponding to SQE3 is generated. CQE3 includes the storage start address of SQE3's data, Addr: 0xffff0400, the free length free: 0, and the removal flag Is_pop: 1, indicating that after the data storage in SQE3 is completed, RQE1 needs to be removed from the receive queue.

[0124] In one possible implementation, each completion message can be used by a user to determine the consumption of receiving units in the receiving queue based on the removal flag in each completion message, thereby determining 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 subsequently received data. The third receiving unit can be a new, unused receiving unit, i.e., the data storage area of ​​the third receiving unit does not store any data.

[0125] For example, the number of receiving units to be removed from the receive queue can be determined based on each completion message. If the number of receiving units to be removed from the receive queue is greater than or equal to a removal threshold, supplementary information can be sent to the receiving end, which can instruct the receiving end to add a third receiving unit to the receive 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 receive queue. The removal threshold can be set based on experience or user needs, such as 3 or 5.

[0126] Afterwards, the receiving end can 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 can include the number of third receiving units, and the receiving end can add third receiving units based on the number. The embodiment of the present application does not limit the number of third receiving units to be added. The number of third receiving units can be the same as the number of receiving units removed from the receiving queue, or can be set by the user.

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

[0128] Referring to FIG11 , a schematic diagram of data storage in a data storage area in a related art is shown. The SQ on the sending side includes SQE1, SQE2, and SQE3, and the RQ on the receiving side includes RQE1, RQE2, and RQE3. SQEs correspond one to one with RQEs, and the length of the data storage area of ​​each RQE is 16KB. The data in SQE1 is 8KB long. 8KB of memory in RQE1's data storage area is used to store SQE1's data, and the remaining 8KB of memory in RQE1's data storage area is free space (indicated by a black rectangle). The data in SQE2 is 8KB long. 8KB of memory in RQE2's data storage area is used to store SQE2's data, and the remaining 8KB of memory in RQE2's data storage area is free space. The data in SQE3 is 16KB long. 16KB of memory in RQE3's data storage area is used to store SQE3's data, and the remaining memory in RQE3's data storage area is 0. The free space in RQE1 and RQE2 cannot be utilized, resulting in memory waste.

[0129] In the same scenario, the data storage method provided by the embodiment of the present application can reduce memory waste. For example, see Figure 12, which shows 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. The length of the data storage area of ​​each RQE is 16KB. The length of the data in SQE1 and SQE2 is 8KB. 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. The remaining memory in the data storage area of ​​RQE1 is 0. The length of the data in SQE3 is 16KB. 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 all utilized, and no memory is wasted. In addition, the 16KB memory (indicated by the black rectangle) of the data storage area of ​​RQE3 is not occupied and can be used to store data received later.

[0130] In addition, for the append write operation, the implementation method of the embodiment of the present application is also different from that of the related art. Referring to Figure 13, a schematic diagram of the process of implementing the append write operation in the related art is shown. The process of implementing the append write operation in the related art 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. Among them, the user end can also be called the client, and the storage node can also be called the server or service device. The length of data 1 can be, for example, 0x200 shown in Figure 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, Addr: 0xffff0100 shown in Figure 13. Rkey can be a check code corresponding to the virtual address, used to verify the accuracy of the virtual address. Rkey can be, for example, xx. Step a3: The client writes data 1 to the memory location indicated by the virtual address through a WRITE operation. The length of data 1 written to the memory is the same as the length of data 1 sent by the client. Step a4: After completing the storage of data 1, the storage node returns an acknowledgment (ACK) message to the client, indicating the completion of the append write operation. In the related art, the time T1 required to complete the append write operation is: 2 * SEND time + data transmission (write) time + ACK time.

[0131] Referring to Figure 14 , a schematic diagram of a process for implementing an append write operation in the present application is shown. The process for implementing an append write operation in the present application may include two steps: step b1 and step b2. Step b1: The user end may send the appended data 2 and the length of data 2 to the storage node via SEND. The length of data 2 may be, for example, 0x200. Because the storage node has already sent the data storage area of ​​the RQE with a larger memory, the user end does not need to first send the length of data 2 to the storage node and wait for a response from the storage node. Step b2: The storage node queries the values ​​in the used and free fields of the RQE information storage area to determine the storage start address and write the data to the storage start address, completing the append write task. For example, data 2 may be written to the end of the address of the previously written data 1. After completing the append write task, the storage node sends an acknowledgment message to the user end. In the present embodiment, the process for implementing the append write operation and the data write operation is the same. The time T2 to complete the append write task is: data transmission time + ACK time. Compared with the related art, this reduces the time required for a SEND. Compared with T1, it can be seen that the append write operation completion time is shortened.

[0132] 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 new consumption mode of the receiving unit. One data storage area can be used to store data from multiple or one sending units, and the receiving unit and the sending unit will not be consumed one-to-one. Increasing the number of sending units that the receiving unit can receive can reduce the number of times the receiving end replenishes the receiving unit, thereby reducing the pressure on the receiving end CPU.

[0133] 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 data storage can be more accurate.

[0134] The above describes the data storage method provided by the embodiments of the present application. Corresponding to the above method, the embodiments of the present application also provide a data storage device. This device is applied to the receiving end shown in Figure 4 or Figure 5 . This device is used to execute the data storage method shown in Figure 6 above through the various modules shown in Figure 15 . As shown in Figure 15 , the data storage device provided by the embodiments of the present application includes the following modules.

[0135] 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.

[0136] 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.

[0137] 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.

[0138] In a possible implementation, the determination module 1503 is configured to compare the first free length and the first length to obtain a comparison result indicating 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 based on the comparison result.

[0139] In one 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.

[0140] In one 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; and to determine the storage ending address of the first data based on the storage starting address and the first length; and 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.

[0141] 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.

[0142] 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.

[0143] In a possible implementation, the apparatus further includes a removing module, configured to remove the first receiving unit from the receiving queue.

[0144] In one possible implementation, the determination module 1503 is also used to determine the 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.

[0145] 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 idle length and removal identifier of the first data, the removal identifier indicates whether there is a receiving unit in the first receiving unit or the second receiving unit that has been removed from the receiving queue, and the first completion information is used to determine whether to add a third receiving unit to the receiving queue.

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

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

[0148] It should be understood that the beneficial effects of the device provided in FIG. 15 when implementing its functions are the same as the beneficial effects of the data storage method provided in FIG. 6 , which will not be described in detail here. In addition, the device provided in FIG. 15 only uses the division of the above-mentioned functional modules as an example to illustrate when implementing its functions. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be 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. The specific implementation process is detailed in the method embodiment, which will not be described in detail here.

[0149] 16 , which shows a schematic structural diagram of an exemplary data storage device 1600 of the present application. The data storage device 1600 includes at least one processor 1601 , a memory 1603 , and at least one network interface 1604 .

[0150] 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 can be a microprocessor or any conventional processor, etc. It is worth noting that the processor can be a processor that supports the advanced reduced instruction set machine (ARM) architecture. It can implement or execute the various logic blocks, modules, and circuits described in conjunction with the disclosure of this 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.

[0151] Optionally, data storage device 1600 further includes a bus 1602. Bus 1602 is used to transmit information between the various components of data storage device 1600. Bus 1602 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, for example. Bus 1602 may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, FIG16 shows only one line, but this does not imply that there is only one bus or only one type of bus.

[0152] The memory 1603 may be, for example, a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. 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.

[0153] By way of example and 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 random access memory (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).

[0154] 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 compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this. The memory 1603 is, for example, independent and connected to the processor 1601 via the bus 1602. The memory 1603 may also be integrated with the processor 1601.

[0155] The network interface 1604 uses any transceiver-like device to communicate with other devices or communication networks. The communication network can be Ethernet, a radio access network (RAN), or a wireless local area network (WLAN). The network interface 1604 can include a wired network interface or a wireless network interface. Specifically, the network interface 1604 can 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 can be an optical interface, an electrical interface, or a combination thereof. In some embodiments of the present application, the network interface 1604 can be used for the data storage device 1600 to communicate with other devices.

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

[0157] In a specific implementation, as some embodiments, the data storage device 1600 may include multiple processors, such as processor 1601 and processor 1605 shown in FIG16 . 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).

[0158] In some embodiments, 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 by the method embodiment, i.e., the method shown in FIG6 , through the processor 1601 and the program instructions 1610 in the memory 1603. The program instructions 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.

[0159] During the 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. The processor 1601 in the data storage device 1600 reads the instructions in the memory 1603, so that the data storage device 1600 shown in Figure 16 can execute all or part of the steps in the method embodiment.

[0160] The data storage device 1600 may also correspond to the apparatus shown in FIG15 , wherein each functional module in the apparatus shown in FIG15 is implemented using software of the data storage device 1600. In other words, the functional modules included in the apparatus shown in FIG15 are generated by the processor 1601 of the data storage device 1600 after reading the program instructions 1610 stored in the memory 1603.

[0161] Among them, each step of the method shown in Figure 6 is completed by the hardware integrated logic circuit or software instructions in the processor of the data storage device 1600. The steps of the method embodiment disclosed in this 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 storage medium mature in the art such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers, 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.

[0162] In an exemplary embodiment, a data storage system is provided. The data storage system includes a receiving device and a sending device. The receiving device is used to execute the method shown in FIG. 6 , and the sending device is used to send data to the receiving device.

[0163] In an exemplary embodiment, a computer program (product) is provided. The computer program (product) includes: computer program code. When the computer program code is executed by a computer, the computer is caused to perform the method shown in FIG. 6 .

[0164] In an exemplary embodiment, a computer-readable storage medium is provided. The computer-readable storage medium stores a program or instruction. When the program or instruction is executed on a computer, the computer executes the method shown in FIG. 6 .

[0165] 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 the method shown in FIG6 .

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

[0167] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented 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, all or part of the processes or functions described herein are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may 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 integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive).

[0168] In this application, the terms "first," "second," and the like are used to distinguish between identical or similar items having substantially the same function or effect. It should be understood that "first," "second," and "nth" do not have a logical or temporal dependency, nor do they limit the quantity or order of execution. It should also be understood that although the following description uses the terms "first," "second," and the like to describe various elements, these elements should not be limited by these terms. These terms are simply used to distinguish one element from another.

[0169] 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.

[0170] In this application, the term "at least one" means one or more, and the term "plurality" means two or more. For example, "plurality of second devices" means two or more second devices. The terms "system" and "network" are often used interchangeably herein.

[0171] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is 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.

[0172] It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the listed items. The term "and / or" describes an association between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this application generally indicates that the associated objects are in an "or" relationship.

[0173] 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 [stated condition or event] is detected” may be interpreted to mean “upon determining ” or “in response to determining ” or “upon detecting [stated condition or event]” or “in response to detecting [stated condition or event],” depending on the context.

[0174] The above description is merely an embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present application shall be included in the scope of protection 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

Patent Citations

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

    CN119922156A

  • Data storage device and system and data writing method

    CN111562880A

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

    CN112181303A

  • Method and device for storing, retrieving and deleting embedded audio and video data, and memory

    CN112558873A

  • Utilization based dynamic shared buffer in data storage system

    US20220269434A1