Data storage method and device, and computer-readable medium

By splitting and splicing storage routing entries across multiple RAM modules, the problem of wasted RAM storage resources is solved, achieving more efficient resource utilization and data retrieval.

WO2024244825A1PCT designated stage expired Publication Date: 2024-12-05SANECHIPS TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/089463
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-31
Filing Date
2024-04-24
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

In the prior art, there is a problem of wasted resources when storing routing entries in random access memory (RAM), especially due to the gaps caused by the sparsity and imbalance of the prefix tree.

Method used

The routing entries are split into multiple subtrees and stored in multiple RAM storage modules. Each logical row consists of multiple physical rows. The actual address is determined by the logical address for storage and retrieval. Data from different physical rows is concatenated using splicing units.

Benefits of technology

It reduces the waste of RAM storage resources, improves resource utilization, ensures that data can be stored logically continuously, and simplifies the reading process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024089463_05122024_PF_FP_ABST
    Figure CN2024089463_05122024_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present disclosure is a data storage method. Data is stored in a storage module comprising a plurality of RAMs, wherein each RAM comprises a plurality of physical rows. The method comprises: according to the occupation condition of a storage module, determining logical addresses used for storing target data to be stored, wherein each logical address represents a logical row and the locations in the logical row, and each logical row is composed of a plurality of physical rows from different RAMs; according to the determined logical address, determining a real address of said target data, wherein the real address is a physical address of a storage space corresponding to the logical address in each RAM; and storing said target data in the storage module according to the determined real address. Further provided in the present disclosure are a data storage device, and a computer-readable medium.
Need to check novelty before this filing date? Find Prior Art

Description

Data storage method and device, and computer readable medium

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application CN 202310639225.0, entitled “Data Storage Method and Device, Computer-Readable Medium,” filed on May 31, 2023, the entire contents of which are incorporated herein by reference. Technical Field

[0003] The present disclosure relates to the technical field of data storage, and in particular to a data storage method and device, and a computer-readable medium. Background Art

[0004] Part of the content of the routing entry can be stored in a random access memory (RAM). However, in the existing method of storing routing entries, the RAM will have large holes, resulting in a waste of resources.

[0005] Summary of the Invention

[0006] The present disclosure provides a data storage method and device, and a computer-readable medium.

[0007] An embodiment of the present disclosure provides a data storage method, in which data is stored in a storage module including multiple RAMs, each RAM including multiple physical rows. The method comprises: determining a logical address for storing target data to be stored according to the occupancy of the storage module, each logical address representing a logical row and a position in the logical row, and each logical row consisting of multiple physical rows from different RAMs; determining a real address for storing the target data to be stored according to the determined logical address, the real address being the physical address of the storage space corresponding to the logical address in the RAM; and storing the target data to be stored in the storage module according to the determined real address.

[0008] An embodiment of the present disclosure provides a data storage device, comprising: a storage module, which includes multiple RAMs, each RAM includes multiple physical rows; an address mapping unit, which is used to determine a real address for storing target data based on a logical address for storing the target data, each logical address represents a logical row and a position in the logical row, each of the logical rows is composed of multiple physical rows from different RAMs, and the real address is the physical address of the storage space corresponding to the logical address in the RAM; a splicing unit, which is used to splice different parts of the same target data read from different physical rows to obtain the target data.

[0009] An embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon. When the computer program is executed by a processor, any one of the data storage methods of the embodiments of the present disclosure is executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In the accompanying drawings of the embodiments of the present disclosure:

[0011] FIG1 is a flow chart of a data storage method provided by an embodiment of the present disclosure;

[0012] FIG2 is another flow chart of the data storage method provided by an embodiment of the present disclosure;

[0013] FIG3 is a block diagram of a data storage device according to an embodiment of the present disclosure;

[0014] FIG4 is another block diagram of a data storage device provided by an embodiment of the present disclosure;

[0015] FIG5 is a schematic diagram of a routing entry processing process in a data storage method provided by an embodiment of the present disclosure;

[0016] FIG6 is a schematic diagram of a process of storing target data in a logical row in a data storage method provided by an embodiment of the present disclosure;

[0017] FIG7 is a schematic diagram of a process of reading target data in a data storage method provided by an embodiment of the present disclosure;

[0018] FIG8 is a block diagram of the composition of a computer-readable medium provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] To enable those skilled in the art to better understand the technical solutions of the present disclosure, the data storage method and device, and computer-readable medium provided by the embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0020] The present disclosure will be described more fully hereinafter with reference to the accompanying drawings, but the illustrated embodiments may be embodied in different forms, and the present disclosure should not be construed as limited to the embodiments set forth below. On the contrary, these embodiments are provided so that the present disclosure will be thorough and complete and will fully understand the scope of the present disclosure to those skilled in the art.

[0021] The accompanying drawings of the embodiments of the present disclosure are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the detailed embodiments, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing the detailed embodiments with reference to the accompanying drawings.

[0022] The present disclosure may be described with reference to plan views and / or cross-sectional views by way of ideal schematic views of the present disclosure. Therefore, the exemplary illustrations may be modified according to manufacturing techniques and / or tolerances.

[0023] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.

[0024] The terms used in this disclosure are only used to describe specific embodiments and are not intended to limit the disclosure. As used in this disclosure, the term "and / or" includes any and all combinations of one or more related enumerated items. As used in this disclosure, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. As used in this disclosure, the terms "comprising" and "made of" specify the presence of the features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof.

[0025] Unless otherwise defined, all terms (including technical and scientific terms) used in this disclosure have the same meanings as those commonly understood by those skilled in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning unless expressly defined in this disclosure.

[0026] The present disclosure is not limited to the embodiments shown in the drawings, but includes modifications of the configurations formed based on the manufacturing process. Therefore, the regions illustrated in the drawings have schematic properties, and the shapes of the regions shown in the drawings illustrate the specific shapes of the regions of the elements, but are not intended to be limiting.

[0027] Routing service is an essential function of network processor chips. To support this function, it is necessary to store the routing entries issued by users (i.e., the mapping relationship between prefix routes and egresses). Therefore, it is desirable to use the minimum storage resources to store these routing entries (routing tables) while ensuring the correctness of the routing function.

[0028] In some related technologies, routing entries may be stored in the form of a prefix tree (trie), where the prefix tree includes multiple nodes, wherein the child nodes of any node have the same prefix.

[0029] For example, the routing and forwarding system is divided into a control plane and a forwarding plane. The control plane (software) receives the user's routing entries and sends them to the routing storage system through the routing storage algorithm. The forwarding plane (hardware) receives the routing query request key, matches the routing entries sent by the control plane, and outputs the longest prefix match result.

[0030] To reduce forwarding latency and storage resource overhead, the entire prefix tree can be split into multiple smaller subtrees, using a multi-level storage architecture. For example, in a two-level storage architecture, the first-level storage structure can use ternary content addressable memory (TCAM) and hash tables to store the root node of the subtree. The second-level storage structure can use RAM to reduce costs and is used to store the child nodes of the subtree (i.e., the nodes that store the actual rules).

[0031] When searching for routing entries on the forwarding plane, a match is usually performed first in the first-level storage structure, and then the longest prefix match is used in the subtree of the hit root node to further search for matching rules. Due to the principle limitation of RAM, it can only read data from one physical row at a time, so the data of all child nodes of each subtree should be stored in one physical row to ensure that all child nodes can be read out and matched at the same time when the root node is matched. However, since the prefix tree is established based on a set of rules, the prefix tree is usually sparse and very unbalanced, that is, the sizes of different subtrees may vary greatly, resulting in that if the largest subtree is guaranteed to be stored in one physical row, there may be a lot of empty space (that is, holes) in the physical row storing other smaller subtrees, resulting in a waste of resources.

[0032] 1 to 7 , an embodiment of the present disclosure provides a data storage method, where data is stored in a storage module including a plurality of RAMs, each of which includes a plurality of physical rows.

[0033] The embodiments of the present disclosure are used to store and / or read data in a storage module composed of multiple RAMs. In the context of this application, the data to be stored and / or read is referred to as "target data."

[0034] In some embodiments, each target data is data of all child nodes of a subtree of the prefix tree of the routing entry.

[0035] The target data stored in the embodiment of the present disclosure may be data of all child nodes of a subtree of a prefix tree (trie) of the routing entry.

[0036] Referring to Figure 5 , after constructing the routing entry in the form of a prefix tree, the routing entry is split into multiple subtrees according to the subtrie selection algorithm. A first-level storage algorithm is used to determine how the root node of each subtree is stored in a TCAM, HASH table, etc., and a second-level storage algorithm is used to determine how the child nodes of each subtree are stored in RAM. It should be appreciated that embodiments of the present disclosure can be applied to the above "second-level storage algorithm."

[0037] It should be understood that in the embodiments of the present disclosure, how the target data is processed has no necessary relationship with how the prefix tree is established, how the subtrees are split, how the root nodes of the subtrees are stored, etc.

[0038] It should be understood that the embodiments of the present disclosure are not limited to the storage of data of the child nodes of the subtree, and any data that meets the requirements of the embodiments of the present disclosure can be used as target data.

[0039] 1 , the method according to the embodiment of the present disclosure includes the following steps S101 to S103 .

[0040] In step S101 , a logical address for storing target data to be stored is determined according to the occupancy of the storage module.

[0041] Each logical address represents a logical row and a position in the logical row, and each logical row is composed of multiple physical rows from different RAMs.

[0042] 6 , in an embodiment of the present disclosure, the storage module includes a plurality of RAMs, and each RAM includes a storage space consisting of a plurality of physical rows.

[0043] According to an embodiment of the present disclosure, when storing data, multiple physical rows from different RAMs are "regarded" as one logical row (any logical row includes multiple physical rows of different RAMs), or in other words, each logical row is equivalent to a "big row" "spliced ​​together" from multiple physical rows of different RAMs.

[0044] Thus, each target data may be stored in a logical row, and the target data has a corresponding logical address in the "logical storage space", and the logical address represents that the target data is stored at a certain position in a certain logical row.

[0045] It should be understood that the specific forms of the logical address are diverse. For example, the logical address may include the start and end addresses, or the start address and the length of the target data (the target data is required to be stored continuously), which will not be described in detail here.

[0046] Referring to Figure 6, since each logical row includes multiple physical rows of different RAMs, the target data stored in a logical row may actually be stored in one physical row (such as target data 1) or may actually be stored in multiple physical rows (for example, target data 2). The multiple physical rows are physical rows from different RAMs, thereby ensuring that one target data will not be stored in different physical rows of one RAM.

[0047] It should be understood that to ensure that the target data can be stored in a logical row, the length of the target data must be less than or equal to the maximum length of the logical row (i.e., the amount of RAM * the width of a physical row). Further, the length of the target data can be less than or equal to the width of a physical row.

[0048] The length of the target data can be limited by the algorithm that generates the target data. For example, the sub-trie selection algorithm can be set to ensure that the total data volume of all child nodes (target data) of any subtree split out is less than the width of a physical row.

[0049] In step S102, the real address of the target data to be stored is determined according to the determined logical address.

[0050] The real address is the physical address of the storage space corresponding to the logical address in RAM.

[0051] The logical address represents the location in the "logical storage space". The actual storage space is the storage space located in the physical row of the RAM. That is, the storage space corresponding to each logical address is actually located in one or more physical rows. The physical address of the storage space is the real address corresponding to the logical address, that is, a certain position in a certain physical row of a certain RAM.

[0052] It should be understood that the specific forms of the real address are diverse. For example, the real address may include the start and end addresses, or the start address and the length of the target data (of course, the target data must be stored continuously), which will not be described in detail here.

[0053] In this step, the corresponding real address is determined according to the logical address.

[0054] In step S103, the target data to be stored is stored in the storage module according to the determined real address.

[0055] After determining the real address corresponding to each target data, the target data is stored in the storage space according to the real address, that is, different parts of the target data are respectively stored at the real address position of one or more physical rows corresponding to the logical address.

[0056] In the embodiment of the present disclosure, multiple physical rows are "joined" into one "large" logical row, and each target data is stored in one logical row (each logical row can store multiple target data); since different physical rows in each logical row come from different RAMs, each target data can be stored in one physical row or in physical rows of multiple different RAMs, that is, all physical rows (that is, logical rows) where each target data is located can be read at the same time. Therefore, while ensuring that each target data can be read "all at once", according to the embodiment of the present disclosure, it is no longer required that each target data must be stored in one physical row, but one target data can be divided into different physical rows of different RAMs. Therefore, when the remaining storage space in a physical row is insufficient to store one target data, the physical row can still be used to store part of the target data, thereby reducing voids and improving resource utilization.

[0057] In some embodiments, referring to FIG. 2 , storing the target data to be stored in the storage module (ie, step S103 ) according to the determined real address includes step S1301 .

[0058] In step S1031 , in response to the determined real address corresponding to multiple physical rows, the target data to be stored is sequentially and continuously stored in the multiple physical rows.

[0059] 6 , when a target data in a logical row is actually to be stored in multiple physical rows (for example, target data 2), it can be stored “continuously” and “sequentially” in each physical row, that is, a portion of the target data is first written starting from the first physical row (for example, physical row 0), and when the physical row is used up, the remaining content of the target data is continued to be written from the beginning of the next physical row (for example, physical row 1).

[0060] In this way, it is possible to ensure that the target data is stored in a logically continuous logical storage space as much as possible to facilitate the correspondence between the real address and the logical address.

[0061] In some embodiments, referring to FIG. 2 , the data storage method of the embodiment of the present disclosure further includes steps S104 to S106 .

[0062] In step S104 , the real address storing the target data to be read is determined according to the logical address of the target data to be read.

[0063] In step S105 , the target data to be read is read from the storage module according to the real address of the target data to be read.

[0064] In step S106 , in response to the fact that the parts of the target data to be read are respectively located in different physical rows, the read parts are spliced ​​together to obtain the target data to be read.

[0065] Referring to Figure 2, after the target data is written into the storage module in the above manner, if there is a requirement to read the target data (for example, the root node of the corresponding subtree matches), the logical address of the target data can be obtained, and the real address corresponding to the logical address can be further determined, and the target data can be read from the corresponding physical row according to the real address.

[0066] If the target data is stored in multiple physical rows, part of the target data is read from each physical row. That is, the parts of the target data are directly read out instead of the complete target data. Therefore, it is necessary to "splice" the parts of the read target data to obtain the complete target data.

[0067] In some embodiments, referring to FIG. 2 , reading the target data to be read from the storage module according to the real address of the target data to be read (ie, step S105 ) includes step S1051 .

[0068] In step S1051, all data of all physical rows corresponding to the real addresses are read from the storage module.

[0069] In response to the respective parts of the target data to be read being located in different physical rows, the read parts are spliced ​​together to obtain the target data to be read (ie, step S106 ), including step S1016 .

[0070] In step S1061, in response to the fact that various parts of the target data to be read are located in different physical rows, the data of multiple physical rows read are sequentially spliced ​​together to form data to be intercepted, and based on the real address of the target data to be read, an intercepted segment including the target data to be read is obtained from the data to be intercepted.

[0071] Normally, the data of one physical row of RAM is read out “entirely” at a time, so when reading target data, the data of all physical rows where the target data is located can be read out simultaneously.

[0072] Furthermore, if the target data is distributed in multiple physical rows, the data of the multiple physical rows are read out simultaneously.

[0073] As shown in Figure 7 , the data in these physical rows can be sequentially "joined" together to form the "data to be intercepted." The data to be intercepted can be all or part of a logical row. Then, based on the real address of the target data to be read, a portion of the data to be intercepted is intercepted as a "segment." This segment includes the target data to be read (for example, target data 2). Therefore, obtaining the segment is equivalent to obtaining the target data.

[0074] In some embodiments, the starting position of the clipped segment begins from the starting position of the target data to be read, and the length of the clipped segment is equal to the width of one physical line.

[0075] 7 , as one embodiment of the present disclosure, data having a length equal to the width of one physical row (eg, W) may be intercepted starting from the starting position (eg, start_ptr) of the target data as a intercepted segment.

[0076] In the related art, when it is necessary to read target data, all data in a physical row is usually read, and the target data is located at the starting position of the read data. According to the above reading method of the embodiment of the present disclosure, the form of the obtained segment is the same as the form of the data read in the related art, that is, the data length is a physical width W, and the target data is located at the starting position of the read data, thereby facilitating subsequent processing of the read data.

[0077] Should be understood that the length of the intercepted segment can be greater than the length of the target data, that is, also comprises other content that does not belong to the target data in the intercepted segment.At this moment, can make irrelevant content invalid in the intercepted segment through appropriate mode, thereby obtain the target data.

[0078] It should be understood that when the real address of the target data corresponds to only one physical row (ie, the target data is located in only one physical row), it is sufficient to read the data of the physical row.

[0079] It should be understood that the specific reading method in the embodiment of the present disclosure is not limited thereto. For example, the portion corresponding to the target data can be read from a physical row, and portions from different physical rows can be spliced ​​together when necessary.

[0080] In some embodiments, the number of physical rows in all RAMs is the same, and the width of all physical rows is the same.

[0081] As one embodiment of the present disclosure, all RAMs include the same number of physical rows, and all RAM physical rows have the same width.

[0082] For example, referring to FIG. 6 , there are two RAMs (RAM0 and RAM1 ), each RAM includes the same number of physical rows, and the width of all physical rows is the same, which is W.

[0083] In some embodiments, determining a logical address for storing target data to be stored (ie, step S101 ) according to the occupancy of the storage module includes step S1011 .

[0084] In step S1011 , according to the occupancy of the storage module, a segment tree algorithm is used to determine a logical address for storing the target data to be stored.

[0085] As one approach in the disclosed embodiments, a "segment tree algorithm" can be used to determine the logical address of the target data. For example, the length of the target data segment to be stored can be determined based on the target data segment. Free segments with lengths greater than or equal to the length of the target data segment can be found in the segment tree. The logical address for storing the target data can be determined from the free segments with the smallest lengths. The target data segment can then be subtracted from the free segments, and the segment tree can be updated.

[0086] In some embodiments, the method of the embodiment of the present disclosure further includes steps S1001 to S1002.

[0087] In step S1001, multiple RAMs are regarded as a logical storage space, and a mapping relationship between the physical addresses of the multiple RAMs and the logical addresses of the logical storage space is determined.

[0088] In step S1002, unoccupied continuous free storage space in the logical storage space is recorded as a free address segment represented by a start point and an end point.

[0089] The starting point of the free address segment is the logical address of the starting position of the free storage space in the logical storage space, and the ending point of the free address segment is the logical address of the ending position of the free storage space in the logical storage space.

[0090] Determining the logical address for storing the target data to be stored using a segment tree algorithm according to the occupancy of the storage module (ie, step S1011 ) includes steps S1011A1 to S1011A2 .

[0091] In step S1011A1, the recorded free address segments are searched, and the free address segments whose free storage space represented by the free address segments is greater than or equal to the size of the target data to be stored are determined.

[0092] In step S1011A2, the free storage space corresponding to the determined free address line segment is determined as the storage space for storing the target data, and the logical address of the target data to be stored is determined according to the free address line segment.

[0093] Determining the real address of the target data to be stored according to the determined logical address (ie, step S102 ) includes step S1021 .

[0094] In step S1021 , the determined logical address is converted into a physical address of the RAM according to the mapping relationship, as the real address of the target data to be stored.

[0095] As one embodiment of the present disclosure, each RAM can be regarded as a logical storage space as a whole. If there are two RAMs (for example, RAM0 and RAM1), the parity rows of the logical storage space can be the physical rows in the two RAMs respectively, and adjacent parity rows constitute a logical row, that is, each target data is stored in two adjacent parity rows.

[0096] The free storage space in the logical storage space can be represented by "free segments", and the target data to be stored can be stored in the appropriate free segments through the segment tree algorithm.

[0097] In some embodiments, referring to FIG. 2 , determining a logical address for storing target data to be stored (ie, step S101 ) according to the occupancy of the storage module includes steps S1011B1 to S1011B2 .

[0098] In step S1011B1 , in response to the inability to determine the logical address of the target data to be stored, space compression is performed on the storage module.

[0099] In step S1011B2, a logical address for storing the target data to be stored is determined according to the occupancy of the storage module after space compression.

[0100] In some cases, the actual free storage space may be sufficient to store the target data, but because the stored target data is relatively scattered, it is impossible to find space in a logical row to store the target data (for example, it is impossible to find a free segment of sufficient length in a logical row). To this end, space squeezing can be performed, that is, moving part of the data (for example, part of the data separated by free segments) together, so that the original multiple free storage spaces (for example, free segments) are "connected" to form a larger free storage space. Therefore, after space squeezing, a larger free storage space appears, and an attempt can be made to determine the logical address of the target data again (for example, using a segment tree algorithm).

[0101] It should be understood that since in the embodiment of the present disclosure, a target data is required to be stored in a logical row, during the process of moving data, the target data can be moved within a logical row, or the data can be moved to another logical row, but it is not allowed to move the data to be dispersed in multiple logical rows.

[0102] It should be understood that the specific methods of the segment tree algorithm and space compression are diverse and will not be described in detail here.

[0103] 1 to 7 , an embodiment of the present disclosure provides a data storage device, comprising: a storage module comprising a plurality of RAMs, each RAM comprising a plurality of physical rows; an address mapping unit for determining a real address for storing target data based on a logical address for storing the target data, each logical address representing a logical row and a position in the logical row, each logical row being composed of a plurality of physical rows from different RAMs, and the real address being the physical address of the storage space corresponding to the logical address in the RAM; and a splicing unit for splicing different parts of the same target data read from different physical rows to obtain the target data.

[0104] 3 , the data storage device includes a storage module composed of multiple RAMs, an address mapping unit is provided for converting a logical address into a real address, and a splicing unit is provided for splicing different parts of the same target data from different physical rows, so that the data storage device can implement the data storage method according to the present disclosure.

[0105] In some embodiments, referring to Figure 4, the data storage device of the embodiment of the present disclosure also includes: a logical address storage unit, which is used to store the logical address of the target data; and / or a logical address determination unit, which is used to determine the logical address for storing the target data to be stored based on the occupancy of the storage module.

[0106] 4 , the data storage device may further include a logical address storage unit in which the logical address of the target data may be stored, so that the address mapping unit may obtain the required logical address from the logical address storage unit and perform conversion. For example, referring to FIG4 , the logical address storage unit may also be a RAM.

[0107] 4 , the data storage device may further include a logical address determination unit. When target data needs to be written into the storage module, the logical address determination unit may calculate the logical address of the target data and write the logical address into the logical address storage unit.

[0108] It should be understood that it is also feasible to implement the logical address storage unit and the logical address determination unit by hardware or software located outside the data storage device.

[0109] It should be understood that the data storage device according to the embodiment of the present disclosure may further include other functional units.

[0110] For example, referring to Figure 4, when each target data is the data of all child nodes of a subtree of the prefix tree of the routing entry, the data storage device may also include a matching unit connected to the splicing unit, which is used to perform the longest prefix match on the read target data to obtain a matching routing entry, that is, the data storage device according to the present disclosure can be applied to a device that implements a routing forwarding function.

[0111] In some embodiments, the number of RAMs is two.

[0112] 4 , as one embodiment of the present disclosure, the storage module may specifically include two RAMs (RAM0 and RAM1).

[0113] 8 , an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon. When the computer program is executed by a processor, the data storage method of each embodiment of the present disclosure is implemented.

[0114] A processor is a device with data processing capabilities, including but not limited to a central processing unit (CPU); a memory is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and flash memory (FLASH); an I / O interface (read-write interface) is connected between the processor and the memory, enabling information exchange between the memory and the processor, including but not limited to a data bus (Bus), etc.

[0115] Exemplarily, a process of storing data using a storage module including two RAMs (RAM0 and RAM1) is described in detail below with reference to FIG. 4 .

[0116] Each RAM consists of N / 2 physical rows, each of which has a width of W (byte, the same below). The size of the entire storage space is N (total depth) * W (width). The addresses (real addresses) of the physical rows in RAM0 and RAM1 are consecutively numbered with even and odd numbers, respectively.

[0117] Each logical row is composed of two adjacent physical rows (one even-numbered row and one odd-numbered row) in the entire storage space. When writing, it is necessary to ensure that each target data is located in at most two adjacent rows and not occupy three or more rows.

[0118] The storage address of each entry can be represented as a line segment [start_byte_index, end_byte_index]. The storage space is managed by a line segment tree. Initially, the line segment tree contains only one line segment [0, N*W-1].

[0119] When a child node of a subtree (ie, target data) is to be written, if the subtree includes Nr child nodes, the total number of bytes occupied by the target data is Rw=m*Nr.

[0120] Assuming that the total number of bytes of each child node of the routing entry prefix tree is k, each child node requires a storage space of m=k+1 bytes, and the additional 1 byte is used to represent the prefix length.

[0121] Find an idle segment, select a segment whose length is closest to Rw and greater than or equal to Rw to store the target data, and update the idle segment after subtracting Rw from the segment, and record the segment start_byte_index as the abstract starting address Addrs (that is, the starting address in the logical address).

[0122] If no suitable free line segment can be found, the following space extrusion process is executed.

[0123] First, find the longest idle segment a among the current idle segments. Then, find the idle segment b that is closest to the idle segment a, and determine whether the sum of the idle segments a and b reaches the required space length. If it does not reach, continue to find the idle segment c that is closest, and determine whether the sum of the idle segments a, b, and c reaches the required space length, and so on, until the sum of the space lengths of multiple found idle segments exceeds the required space length.

[0124] Overall move the data between multiple selected idle segments. Assume moving the data between the idle segments a and b. Move the data corresponding to the 1st position before the idle segment b to the starting position of the idle segment b, move the data corresponding to the 2nd position before the idle segment b to the 1st position before the idle segment b, and so on, until the data corresponding to the 1st position after the idle segment a is moved away and merged with the idle segment a to form a larger idle segment. End the idle address squeezing process and re - search for idle segments.

[0125] Calculate the addresses (i.e., physical addresses) for storing the target data in two RAMs (RAM0 and RAM1) based on the abstract starting address Addrs (i.e., the starting address in the logical address) in the following way: Addr2nd0 = ((Addrs % 2W) < W)? ROUNDDOWN(Addrs / 2W, 0) : (ROUNDDOWN(Addrs / 2W, 0) + 1); Offset2nd0 = ((Addrs % 2W) < W)? (Addrs % W) : 0; Addr2nd1 = (ROUNDDOWN(Addrs / 2W, 0)); Offset2nd1 = ((Addrs % 2W) >= W)? (Addrs % W) : 0

[0126] The symbol "%" represents taking the remainder; "(Addrs % 2W) < W" determines whether the address is in RAM0, "ROUNDDOWN" represents rounding down, " ? : <c>" means if A is true, return B, otherwise return C; Addr2ndx corresponds to the row address of RAMx, and Offset2ndx corresponds to the offset (bit offset) of RAMx, where x is 0 or 1.

[0127] 6 , the real address (ie, the position in which row of which RAM) of the target data can be calculated according to the logical address of the target data (ie, the address in the entire storage space) in the above manner.

[0128] The data of each child node (ie, target data) is written into RAM0 and RAM1 based on Addr2nd0, Offset2nd0, Addr2nd1, and Offset2nd1, and Addrs is stored in the logical address determination unit.

[0129] When the target data is to be deleted, 0 is written to the corresponding position information of Addr2nd0 and Addr2nd1, and the corresponding segment is released to the idle segment to update the idle segment.

[0130] When the target data is to be read, the logical address of the subtree to be read is determined from the logical address storage unit according to the matching of the root node, and the RAM0 and RAM1 addresses (i.e., the real addresses) are mapped as follows: Addr2nd0 = ((Addrs% 2W) <W)?ROUNDDOWN(Addrs / 2W,0):(ROUNDDOWN(Addrs / 2W,0)+1); Addr2nd1=(ROUNDDOWN(Addrs / 2W,0)); Offset2nd=Addrs%W

[0131] 7 , all data in the row involved in the target data is read out.

[0132] The entry splicing unit receives the information transmitted by RAM0 and RAM1 and the abstract address information Addrs, recorded as Info0 and Info1, and obtains the spliced ​​target data in the following way: bitmap = (((Addrs% 2W) <W)?[Info0][Info1]: [Info1][Info0])<<Offset2nd;

[0133] 7 , the rows of RAM0 and RAM1 are spliced ​​together to obtain the data to be intercepted, and then the first W bytes of data are intercepted from the starting position start_ptr of the target data as the intercepted segment.

[0134] The subnode format of the matching unit is rule_num rule0_bitmap rule1_bitmap.... Based on the fixed fields of each entry, the position where the last bit is 1 can be found first, and the prefix length is determined to be preffix_len = rule_len - bit_index. Matching can be performed based on the prefix length to obtain the matching subnode.

[0135] For the intercepted segment, the target data (sub-node) therein is further matched, for example, the portion after the target data is invalidated.

[0136] Those skilled in the art will appreciate that all or some of the steps, systems, and functional modules / units in the apparatus disclosed above may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0137] In hardware implementations, the division between functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation.

[0138] Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit (CPU), a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As is well known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH) or other disk storage; compact disc (CD-ROM), digital versatile disc (DVD) or other optical disc storage; magnetic cassettes, tapes, disk storage or other magnetic storage; any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0139] The present disclosure has disclosed example embodiments, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for purposes of limitation. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly indicated, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, it will be understood by those skilled in the art that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.< / c>

Claims

1. A data storage method, in, The data is stored in a storage module including a plurality of random access memories RAM, each RAM including a plurality of physical rows, and the method includes: Determine a logical address for storing the target data to be stored according to the occupancy of the storage module, each logical address represents a logical row and a position in the logical row, and each logical row is composed of a plurality of physical rows from different RAMs; Determine the real address of the target data to be stored according to the determined logical address, wherein the real address is the physical address of the storage space corresponding to the logical address in the RAM; According to the determined real address, the target data to be stored is stored in the storage module.

2. The method according to claim 1, in, According to the determined real address, storing the target data to be stored in the storage module comprises: In response to the determined real address corresponding to a plurality of physical rows, the target data to be stored is stored sequentially and continuously in the plurality of physical rows.

3. The method according to claim 1, further comprising: include: Determining a real address for storing the target data to be read according to the logical address of the target data to be read; Reading the target data to be read from the storage module according to the real address of the target data to be read; In response to the respective parts of the target data to be read being located in different physical rows, the read parts are spliced ​​to obtain the target data to be read.

4. The method according to claim 3, in, Reading the target data to be read from the storage module according to the real address of the target data to be read includes: Reading all data of all physical rows corresponding to the real address from the storage module, In response to the respective parts of the target data to be read being located in different physical rows, The read parts are spliced ​​to obtain the target data to be read, including: In response to the respective parts of the target data to be read being located in different physical rows, the data of the multiple physical rows read are sequentially spliced ​​to form data to be intercepted, and according to the real address of the target data to be read, an interception segment including the target data to be read is obtained from the data to be intercepted.

5. The method according to claim 4, in, The interception segment starts from the starting position of the target data to be read, and The length of the clipped segment is equal to the width of one physical line.

6. The method according to claim 1, in, Determining a logical address for storing target data to be stored according to the occupancy of the storage module includes: According to the occupancy of the storage module, a segment tree algorithm is used to determine a logical address for storing the target data to be stored.

7. The method according to claim 6, further comprising: include: Taking the multiple RAMs as a logical storage space, determining a mapping relationship between the physical addresses of the multiple RAMs and the logical addresses of the logical storage space; The unoccupied continuous free storage space in the logical storage space is recorded as a free address segment represented by a start point and an end point, wherein the start point of the free address segment is the logical address of the starting position of the free storage space in the logical storage space, and the end point of the free address segment is the logical address of the ending position of the free storage space in the logical storage space.

8. The method according to claim 7, in, According to the occupancy of the storage module, determining the logical address for storing the target data to be stored by using a segment tree algorithm includes: Searching for the recorded free address segments, and determining free address segments whose free storage space represented by the free address segments is larger than or equal to the size of the target data to be stored; Determine the free storage space corresponding to the determined free address line segment as the storage space for the target data to be stored, and determine the logical address of the target data to be stored according to the free address line segment, 9. The method according to claim 8, in, Determining the real address of the target data to be stored according to the determined logical address includes: According to the mapping relationship, the determined logical address is converted into a physical address of the RAM as the real address of the target data to be stored.

10. The method according to claim 1, in, Determining a logical address for storing target data to be stored according to the occupancy of the storage module includes: In response to being unable to determine the logical address of the target data to be stored, performing space compression on the storage module; According to the occupancy of the storage module after space compression, a logical address for storing the target data to be stored is determined.

11. The method according to any one of claims 1 to 10, in, Each target data is the data of all child nodes of a subtree of the prefix tree of the routing entry.

12. A data storage device, in, include: A storage module including a plurality of RAMs, each RAM including a plurality of physical rows; An address mapping unit, which is used to determine a real address for storing the target data according to a logical address for storing the target data, each logical address represents a logical row and a position in the logical row, each logical row is composed of a plurality of physical rows from different RAMs, and the real address is a physical address of a storage space corresponding to the logical address in the RAM; The splicing unit is used to splice different parts of the same target data read from different physical rows to obtain the target data.

13. The device according to claim 12, further comprising: include: A logical address storage unit, which is used to store the logical address of the target data; and / or, A logical address determination unit is used to determine a logical address for storing target data to be stored according to the occupancy status of the storage module.

14. A computer-readable medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the data storage method according to any one of claims 1 to 11 is executed.

Citation Information

Patent Citations

  • Rule storage method and device, electronic equipment and storage medium

    CN115834340A

  • Routing address storage method and device, network equipment and storage medium

    CN115987888A

  • Algorithmic TCAM based ternary lookup

    US10318587B1

  • Technologies for efficiently accessing data columns and rows in a memory

    US20190146717A1