Data cache system, method, device, network processor and network device

By maintaining the priority status of storage blocks and dynamically adjusting the cache replacement strategy in the network processor's caching system, the cache hit rate problem of multi-priority data is solved, thereby improving the service quality and overall capabilities of network devices.

CN119669107BActive Publication Date: 2026-01-23T-HEAD (SHANGHAI) SEMICON CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411635764.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2026-01-23
Estimated Expiration
2044-11-14

AI Technical Summary

Technical Problem

Existing network processor caching systems struggle to effectively improve the cache hit rate of high-priority data when processing multi-priority data, thus limiting the service quality and overall capabilities of network devices.

Method used

By maintaining the priority status of storage blocks, the target storage block is determined based on the priority level of the data to be cached and the priority status of the storage block. A dynamically adjusted cache replacement strategy is adopted to improve the cache hit rate of high-priority data.

Benefits of technology

It improved the cache hit rate of high-priority data, enhanced the service quality and overall capabilities of network devices, and enabled flexible adaptation to data caching needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119669107B_ABST
    Figure CN119669107B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data caching system, method, device, network processor and network device. The data caching system comprises a data caching space, the data caching space comprises a plurality of storage blocks, the data caching system maintains priority states of the storage blocks, and the data caching system is configured to determine a target storage block according to a priority level of to-be-cached data and the priority states of the corresponding storage blocks, and store the to-be-cached data in the target storage block. Thus, the embodiments of the present application can affect the replacement weight of each storage block by maintaining the priority states of the storage blocks, and can improve the hit rate of high-priority-level data caching in the case of multiple priority levels, thereby meeting the caching requirements of data with different priority levels, having high flexibility, and further improving the service quality and comprehensive capability of the network device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of semiconductor technology, and more specifically, to a data caching system, method, apparatus, network processor, and network device. Background Technology

[0002] The cache design of network processors in various network devices has a significant impact on the overall capabilities of these devices. Taking the Network Processor (NP) as an example, the NP, as a computing unit that performs tasks such as network protocol processing, high-speed data forwarding, and QoS (Quality of Service) assurance, typically features light computational load, multi-threading, and low thread dependency. Therefore, the design of the NP's cache system is crucial to the chip's performance, power consumption, and size, and also influences the overall capabilities of network devices using the NP to a certain extent. Summary of the Invention

[0003] In view of this, embodiments of the present invention provide a data caching system, method, apparatus, network processor, and network device to influence the replacement weight of each storage block by maintaining the priority status of the storage blocks. In the case of data with multiple priority levels, the hit rate of high priority data caching can be improved, thereby meeting the caching needs of different priority levels, with high flexibility, and thus improving the service quality and overall capabilities of the network device.

[0004] In a first aspect, embodiments of the present invention provide a data caching system, the data caching system comprising:

[0005] A data cache space, comprising multiple storage blocks, wherein the data cache system maintains the priority status of each storage block;

[0006] The controller is used to determine the target storage block based on the priority level of the data to be cached and the priority status of each of the corresponding storage blocks, and to store the data to be cached in the target storage block.

[0007] Secondly, embodiments of the present invention provide a data caching method applicable to a data caching system. The data caching system includes a data cache space, which includes multiple storage blocks. The data caching system maintains a priority state for each of the storage blocks. The method includes:

[0008] Receive a data caching request, wherein the data caching request has corresponding data to be cached;

[0009] The target storage block is determined based on the priority level of the data to be cached and the priority status of each storage block.

[0010] storing the to-be-cached data to the target storage block.

[0011] In a third aspect, an embodiment of the present application provides a data caching apparatus, applicable to a data caching system, the data caching system comprising a data caching space, the data caching space comprising a plurality of storage blocks, the data caching system maintaining priority states of the storage blocks, and the apparatus comprising:

[0012] a request receiving unit configured to receive a data caching request, the data caching request having corresponding to-be-cached data;

[0013] a determining unit configured to determine a target storage block according to a priority level of the to-be-cached data and the priority states of the storage blocks;

[0014] a storing unit configured to store the to-be-cached data to the target storage block.

[0015] In a fourth aspect, an embodiment of the present application provides a network processor, comprising:

[0016] a plurality of processing cores;

[0017] a data caching system as described above;

[0018] wherein the processing cores share the data caching space corresponding to the data caching system.

[0019] In a fifth aspect, an embodiment of the present application provides a network device, the network device being deployed with the network processor as described above.

[0020] The data caching system of the embodiment of the present application comprises a data caching space, the data caching space comprising a plurality of storage blocks, the data caching system maintaining priority states of the storage blocks, and the data caching system being configured to determine a target storage block according to a priority level of to-be-cached data and the priority states of the corresponding storage blocks, and store the to-be-cached data to the target storage block. Thus, the embodiment of the present application can affect the replacement weights of the storage blocks by maintaining the priority states of the storage blocks, and in the case of having data of multiple priority levels, the hit rate of caching data of high priority levels can be improved, thereby meeting the caching requirements of data of different priority levels, having high flexibility, and further improving the service quality and comprehensive capability of the network device. BRIEF DESCRIPTION OF DRAWINGS

[0021] The above and other objects, features and advantages of the present application will become more apparent from the following description of embodiments of the present application taken in conjunction with the accompanying drawings, in which:

[0022] Figure 1 is a structural schematic diagram of the data caching system of the embodiment of the present application.

[0023] Figure 2 is a schematic diagram of a priority state tree of an embodiment of the present application;

[0024] Figure 3 is a schematic diagram of an initialization data cache space of an embodiment of the present application;

[0025] Figure 4 is a schematic diagram of a storage state tree of an embodiment of the present application;

[0026] Figure 5 is a schematic diagram of an access record tree of an embodiment of the present application;

[0027] Figure 6 is a flowchart of a data caching method of an embodiment of the present application;

[0028] Figure 7 is a flowchart of another data caching method of an embodiment of the present application;

[0029] Figure 8 is a schematic diagram of a data caching apparatus of an embodiment of the present application;

[0030] Figure 9 is a schematic diagram of a network processor of an embodiment of the present application;

[0031] Figure 10 is a schematic diagram of a network device of an embodiment of the present application. DETAILED DESCRIPTION

[0032] The present application is described herein based on the embodiments, but the present application is not limited to these embodiments. In the following detailed description of the present application, some specific details are described in detail. The present application can also be fully understood without the description of these specific details. In order to avoid confusion of the essence of the present application, the well-known methods, processes, flows, elements and circuits are not described in detail.

[0033] In addition, those of ordinary skill in the art should understand that the drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.

[0034] Unless the context clearly requires otherwise, throughout the description, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is to say, in the sense of "including, but not limited to".

[0035] In the description of the present application, it should be understood that the terms "first", "second", etc. are only for the purpose of description and should not be understood as indicating or implying relative importance. In addition, in the description of the present application, unless otherwise stated, the meaning of "multiple" is two or more.

[0036] In the solutions described in the specification and embodiments, if personal information processing is involved, the processing is performed on the premise of legal basis (for example, obtaining the consent of the subject of personal information, or being necessary for performing a contract, etc.), and is performed only within the prescribed or agreed range. The user refuses to process personal information other than the necessary information required for the basic function, which does not affect the user's use of the basic function.

[0037] The multi-type data mixed cache of the related comparative example adopts a cache full sharing or cache partitioning manner. For the cache full sharing manner, it completely depends on the replacement algorithm to ensure the hit rate of accessing the cache, although it can achieve lower cache access delay and higher cache sharing degree, but the hit rate of each type of data cannot be controlled after the increase of the data type (the priority of different data types is the same or different), which may cause the access delay of part of the type of data to increase significantly. For the cache partitioning manner, the cache is divided into multiple cache partitions, and each cache partition corresponds to a type of data. At this time, the cache space of each type of data is completely independent. This can ensure the cache hit rate of each type of data due to the complete isolation of the cache space of different types of data. However, since the cache resources between the cache partitions cannot be shared, the required cache capacity is increased, and the more the number of cache partitions, the more complex the access path control logic, and the access delay is also relatively increased, thereby reducing the overall performance of the system. Based on this, the embodiment of the present application provides a data cache system, method, network processor and network device to affect the replacement weight of each storage block by maintaining the priority state of the storage block, which can improve the hit rate of high priority level data cache in the case of multiple priority level data, thereby realizing the cache demand of different priority level data, having high flexibility, and thereby improving the service quality and comprehensive ability of the network device.

[0038] Figure 1 is a structural schematic diagram of the data cache system of the embodiment of the present application. As shown in Figure 1 The data cache system 1 of the embodiment of the present application includes a data cache space 11 and a controller 12. The data cache space 11 includes a plurality of storage blocks. Taking an 8-way set associative data cache space as an example, the data cache space includes a plurality of sets, each set includes 8 cache lines (storage blocks in this embodiment), and each cache line has a size of a predetermined number of bytes. It should be understood that the above-mentioned 8-way set associative type data cache space is only an illustrative example, and the type and specific structure of the data cache space are not shown in the embodiment of the present application.

[0039] For a request of cache lookup miss, the required data needs to be read from the main memory and stored in a certain storage block in the data cache space. Taking the above type of data cache space as an example, when the corresponding network processor receives a data access request, the access address in the data access request is parsed and decomposed into three parts, index, tag and offset. Among them, the network processor determines which set in the data cache space the access address is mapped to through the index, and checks whether the tag of the storage block in the determined set matches the tag of the access address. If a storage block matching the tag of the access address is found in the determined set, it is determined that the cache hits, and the offset obtained by parsing is used to read data from the matched storage block or write data in the storage block. If a storage block matching the tag of the access address is not found in the determined set, it is determined that the cache misses, and a storage block needs to be selected for replacement. For example, when the cache misses, the data is read from the main content and replaces a certain storage block in the data cache space. Further, the network processor can select a storage block in the determined set in the data cache space for replacement.

[0040] In the embodiment, the data cache system 1 maintains the priority states of the storage blocks. The priority state is used to represent the priority level of each storage block.

[0041] In the embodiment, if a certain data access request cache misses, the controller 12 can determine a target storage block according to the priority level of the corresponding data to be cached and the priority state of each corresponding storage block, and store the data to be cached in the target storage block. The data to be cached can be data read from the main memory. Optionally, the priority level of the data to be cached can be determined according to the type of the data to be cached. Further, the priority level can be determined according to the data access frequency and / or the data delay requirement. The higher the data access frequency and the more stringent the data delay requirement, the higher the corresponding data priority. It should be understood that the embodiment does not limit the division of data priority, which can be determined according to specific application scenarios or resource usage, etc. Therefore, the cache replacement method of the embodiment can affect the replacement weight of each storage block by maintaining the priority state of the storage block, and in the case of multiple priority level data, it can improve the hit rate of high priority level data cache, thereby realizing the cache requirement of different priority level data, having high flexibility, and further improving the service quality and comprehensive ability of the network device.

[0042] Furthermore, in this embodiment, the controller 12 can look up the priority status of each storage block according to the priority level of the data to be cached, so as to determine the storage block with a priority level no higher than that of the data to be cached as the target storage block. Therefore, this embodiment can improve the cache hit rate of high-priority data, thereby improving the service quality and overall capabilities of the network device.

[0043] In one optional implementation, this embodiment uses a tree structure to maintain the priority status of each storage block. Taking a priority status with two levels as an example, this embodiment can use a binary tree to maintain the priority status of each storage block. Taking the two levels as high priority and low priority as an example, this embodiment can use a binary tree to maintain the priority status of each storage block.

[0044] Figure 2 This is a schematic diagram of the priority state number in an embodiment of the present invention. Taking the priority tree of one group in an 8-row associative data cache space 11 as an example, each group in the data cache space 11 requires a 7-bit priority signal. Figure 2 As shown, the assignment of priority signals corresponding to the priority tree is explained in Table (1).

[0045] Table (1)

[0046]

[0047] Here, L0 to L7 represent eight storage blocks in a group within the data cache space 11. The priority signal consists of seven bits, Cos bit 0 to Cos bit 6. A bit value of 1 in the priority signal indicates that at least one storage block contains a low-priority storage block, while a bit value of 0 indicates that at least one storage block contains a high-priority storage block.

[0048] like Figure 2 As shown, Figure 2 B0 to B6 in the sequence correspond to the seven bits Cos bit0 to Cos bit6 in the priority signal, respectively. Figure 2 In this context, "B1 low" indicates that a low-priority storage block exists among the child nodes of the B1 branch of the binary tree, meaning Cos bit1 = 1. This means low-priority storage blocks exist in storage blocks L0 through L3. Therefore, if storage block L0 is a low-priority block, the values ​​of bits Cos bit3, Cos bit1, and Cos bit0 in the priority signal are all 1. Conversely, if storage blocks L2 and L3 are both high-priority blocks, the value of bit Cos bit4 in the priority signal is 0. Thus, this embodiment can update the corresponding priority tree based on the priority status of each storage block to maintain the priority status of each storage block.

[0049] Further, if the priority signal corresponding to a certain group in the data cache space 11 is 0001011. Assuming that the current data access request is not hit, the data to be cached read from the main memory is high-priority data, based on the priority tree corresponding to the group and the current priority signal, it can be determined that there are low-priority storage blocks in storage blocks L0 and L1 in the corresponding group, and storage blocks L2-L7 are all high-priority storage blocks. Further query the priority state of storage blocks L0 and L1, determine that storage block L0 is a low-priority storage block and L1 is a high-priority storage block, then determine storage block L0 as the target storage block, and store the data to be cached in the target storage block L0. Further, if storage blocks L0 and L1 are both low-priority storage blocks, the embodiment can also randomly select from them, or select the storage block that has not been accessed recently based on the access record, or select the storage block with low access frequency based on the access record, and the embodiment does not limit this.

[0050] Figure 3 is a schematic diagram of initializing a data cache space according to an embodiment of the present application. In an optional implementation, the data cache space of the embodiment is initialized as at least one cache partition, and each cache partition includes a plurality of storage blocks. Among them, the cache partition is used to cache data of at least one priority level. As shown in Figure 3 , the initialized data cache space 11 is divided into two cache partitions 111 and 112. Among them, the cache partition 111 is used to store data of the first priority and the second priority, and the cache partition is used to store data of the third priority. The data cache space 11 of the embodiment divides the address in the data cache space 11 based on the priority, obtains at least one cache partition, and since the priority levels of different types of data can be the same, compared with the way of cache partitioning based on data types in the prior art, the data cache space can be shared to a certain extent, the required data cache space capacity is reduced, and the cache hit rate of each type of data is improved to a certain extent.

[0051] In an optional implementation, the data cache system 1 of the embodiment further includes at least one counter for recording the number of storage blocks corresponding to the priority. Taking the priority state including high priority and low priority as an example, the data cache system 1 can include a counter for recording the number of high-priority storage blocks or the number of low-priority storage blocks. The number of low-priority storage blocks or the number of high-priority storage blocks not recorded by the counter can be determined based on the total number of storage blocks.

[0052] In a further optional implementation, the controller 12 of the present embodiment is further configured to increase the priority level of the storage block corresponding to the priority level when the proportion of the storage block corresponding to the priority level is lower than a first threshold, and decrease the priority level of the storage block corresponding to the priority level when the proportion of the storage block corresponding to the priority level is higher than a second threshold. In this case, the proportion of the storage block corresponding to the priority level can be calculated according to the number of storage blocks of the priority level recorded by the counter. Optionally, the first threshold and the second threshold can be set according to the cache hit rate requirement of each priority data and the overall quality requirement of the system, which can be specifically set according to the actual application scenario, and the present embodiment does not limit the specific determination method of the first threshold and the second threshold, as long as it meets the requirement of the corresponding network device.

[0053] In another optional implementation, the controller 12 of the present embodiment is further configured to increase the priority level of the storage block corresponding to the priority level when the number of storage blocks corresponding to the priority level is lower than a third threshold, and decrease the priority level of the storage block corresponding to the priority level when the number of storage blocks corresponding to the priority level is higher than a fourth threshold.

[0054] Therefore, the present embodiment can dynamically adjust the size of the corresponding cache partition based on the proportion of the storage block of each priority level (or the number of storage blocks of each priority level), which improves the cache hit rate of high-priority data while avoiding the situation that the cache hit rate of some low-priority data is particularly low, thereby ensuring the cache hit rate of each type of data. This improves the flexibility of the data cache system of the present embodiment, thereby adapting to the deployment requirements of multiple data types.

[0055] In an optional implementation, the data cache system 1 of the present embodiment further maintains the storage state of each storage block. The storage state includes an idle state and an occupied state. In this case, the idle state represents that the corresponding storage block does not store data, and the occupied state represents that the corresponding storage block stores data. After receiving the to-be-cached data, the controller 12 determines the storage block in the idle state as the target storage block in response to the storage block in the idle state in the data cache space. Further, after receiving the to-be-cached data, the controller 12 determines the storage block in the predetermined priority level as the target storage block in response to the storage block in the occupied state in the data cache space and the existence of the storage block in the predetermined priority level, and the predetermined priority level is lower than or equal to the priority level of the to-be-cached data.

[0056] Optionally, the embodiment can query any idle storage block as the target storage block. In other optional implementations, the embodiment can preferentially acquire an idle storage block matching the priority of the data to be cached as the target storage block. If there is no idle storage block matching the priority of the data to be cached in the data cache space 11, the embodiment can sequentially query whether there is an idle storage block with a lower priority than the data to be cached, an idle storage block with a higher priority than the data to be cached, and acquire the queried idle storage block as the target storage block. If no idle storage block is queried, the embodiment can execute the storage block replacement scheme by using the above replacement method based on the priority state of each storage block.

[0057] Further, the priority state of each storage block of the embodiment dynamically changes according to the priority of the data cached thereby. That is, the embodiment updates the priority state of the target storage block to the priority level of the data to be cached after storing the data to be cached in the target storage block. Thus, the embodiment can further improve the flexibility of the priority configuration of each storage block in the data cache system, improve the sharing degree of the data cache space, and further adapt to the deployment requirements of multiple data types.

[0058] In an optional implementation, the embodiment maintains the storage state of each storage block by using a tree structure. Since the storage state includes two states of idle and occupied, the embodiment can maintain the storage state of each storage block by using a binary tree.

[0059] Figure 4 is a schematic diagram of the storage state tree of the embodiment. Taking the storage state tree of one group in the data cache space 11 with 8-row group association as an example, each group in the data cache space 11 needs 7-bit storage state signals. As shown in Figure 4 , the assignment of the storage state signals corresponding to the storage state tree is shown in Table (2).

[0060] Table (2)

[0061]

[0062] wherein L0-L7 respectively represent 8 storage blocks in a certain group in the data cache space 11. The storage state signals include 7-bit Vld bit0-Vld bit6. The bit value of 1 in the storage state signals represents that there is an idle storage block in the corresponding at least one storage block, and the bit value of 0 in the storage state signals represents that the corresponding at least one storage block is in the occupied state.

[0063] As shown in Figure 4 , B0-B6 in Figure 4 respectively correspond to 7-bit Vld bit0-Vld bit6 in the storage state signals.Figure 4 “B1 free” in the priority signal is used to represent that there is a free storage block in the child nodes in the B1 branch of the binary tree, i.e., Vld bit1=1, and there is a free storage block in the storage blocks L0-L3. As can be seen, if the storage block L0 is in a free state, the values of the bit positions Vld bit3, Vld bit1 and Vld bit0 in the priority signal are all 1, and at the same time, if the storage blocks L2 and L3 are in an occupied state, the value of the bit position Vld bit4 in the priority signal is 0. Thus, the embodiment can update the corresponding storage state tree according to the storage state of each storage block, so as to realize the maintenance of the storage state of each storage block.

[0064] Further, if the current corresponding storage state signal of a certain group in the data cache space 11 is 0001011. Assuming that the current data access request is not hit, the data to be cached read from the main memory is high-priority data, and based on the storage state tree and the storage state information corresponding to the group, it can be determined that there is a free storage block in the storage blocks L0 and L1 in the corresponding group, and the storage blocks L2-L7 are all in an occupied state. Further, the storage states of the storage blocks L0 and L1 are queried to determine that the storage block L0 is in a free state and the storage block L1 is in an occupied state, and then the storage block L0 is determined as the target storage block, and the data to be cached is stored in the target storage block L0. Further optionally, if the storage blocks L0 and L1 are both in a free state, the embodiment can also randomly select therefrom, or select the storage block that has not been accessed recently based on the access record, or select the storage block with low access frequency based on the access record, and the embodiment does not limit this.

[0065] Further, if the value of the first bit Vld bit0 of the storage state signal corresponding to the group in the data cache space 11 is 0, it indicates that all the storage blocks in the group are in the occupied state. In this embodiment, whether there is a storage block with a priority level not higher than the to-be-cached data can be determined based on the priority tree corresponding to the group and the current priority signal. If there is, the storage block with a priority level not higher than the to-be-cached data in the group is determined as the target storage block. Taking the above priority binary tree including high priority and low priority as an example, assuming that the current priority signal corresponding to the group is 0001011, it can be determined that there is a low priority storage block in the storage blocks L0 and L1 in the corresponding group based on the priority tree corresponding to the group and the current priority signal. The storage blocks L2-L7 are all high priority storage blocks. Further, the priority states of the storage blocks L0 and L1 are queried to determine that the storage block L0 is a low priority storage block and the storage block L1 is a high priority storage block. Then, the storage block L0 is determined as the target storage block, and the to-be-cached data is stored in the target storage block L0. Further, optionally, if the storage blocks L0 and L1 are both low priority storage blocks, the embodiment can also randomly select one from them, or select the storage block that has not been accessed recently based on the access record, or select the storage block with low access frequency based on the access record. The embodiment does not limit this.

[0066] In an optional implementation, the controller 12 is further configured to, after receiving the to-be-cached data, determine a target data block from the storage blocks in the data cache space according to a predetermined cache replacement algorithm in response to the storage blocks in the data cache space being in the occupied state and there being no storage block with a predetermined priority level. The cache replacement algorithm is a kind of algorithm for deciding which storage block should be replaced when the cache is full, so as to maximize the cache hit rate in the limited cache space and improve the performance of the system.

[0067] Further, the embodiment can employ any one of the following cache replacement algorithms: Least Recently Used (LRU), Pseudo-LRU (PLRU), Random (RAND), Least Frequently Used (LFU), Pseudo-Frequent LRU (PFLRU), Least Frequently Used in Time (LFUT), Adaptive Replacement Cache (ARC), Random Least Recently Used (RAND-LRU), First-In-First-Out (FIFO), etc., and thus will not be described in detail herein.

[0068] The FIFO records the entering order of each memory block by using a queue to achieve that the memory block with the highest entering cache is replaced first. The LRU records the access order of each memory block by using a double-linked list, and each time the corresponding memory block is moved to the head of the list to achieve that the memory block with the least recent use is replaced first. The PLRU records the use of each memory block by using a binary tree, and each time the state of the tree is updated to record the use of each memory block by the tree structure to achieve that the memory block with the least recent use is replaced first as far as possible. The RAND selects the memory block to be replaced by using a random number generator to achieve that a memory block is randomly selected for replacement. The LFU maintains a counter for each memory block to record the number of times it is accessed to achieve that the memory block with the least use is replaced first. The PFLRU records the number of times each memory block is accessed by using a counter array and periodically resets the counter to record the use frequency of each memory block by a simplified method to achieve that the memory block with the least use is replaced first. The LFUT maintains a counter and a timestamp for each memory block to combine time and frequency to select the memory block with the least recent use for replacement. The ARC uses two cache lists, one for LRU and one for LFU, to dynamically adjust the size of the two lists according to the access pattern to combine the advantages of LRU and LFU to adaptively adjust the replacement strategy. The RAND-LRU randomly selects a memory block for replacement with a certain probability based on the LRU algorithm to combine the advantages of random replacement and LRU to select the memory block corresponding to LRU for replacement with a certain probability.

[0069] The embodiment takes the cache replacement using PLRU as an example. The data cache system of the embodiment also maintains access records of the storage blocks, so as to query the least recently used storage block as the target storage block based on the access records. Further, the embodiment maintains the access records of the storage blocks by using a binary tree structure.

[0070] Figure 5 is a schematic diagram of the access record tree of the embodiment. Taking the access record tree of one group in the 8-group associative data cache space 11 as an example, 7 bits of access record signals are needed for each group in the data cache space 11. As shown in Figure 5 , the replacement truth table corresponding to the access record tree is shown in Table (3).

[0071] Table (3)

[0072] PLRU bit0 PLRU bit1 PLRU bit2 PLRU bit3 PLRU bit4 PLRU bit5 PLRU bit6 Replacement number 0 0 No Care 0 No Care No Care No Care L0 0 0 No Care 1 No Care No Care No Care L1 0 1 No Care No Care 0 No Care No Care L2 0 1 No Care No Care 1 No Care No Care L3 1 No Care 0 No Care No Care 0 No Care L4 1 No Care 0 No Care No Care 1 No Care L5 1 No Care 1 No Care No Care No Care 0 L6 1 No Care 1 No Care No Care Figure 5 1 L7

[0073] wherein L0-L7 represent 8 storage blocks in a certain group in the data cache space 11. The access record signals include 7 bits of PLRU bit0-PLRU bit6. As shown in Figure 5 , B0-B6 in Figure 6 correspond to the 7 bits of PLRU bit0-PLRU bit6 in the access record signals respectively.

[0074] Further, when the storage block replacement or the storage block hit occurs in the group, the access record signals are updated, and the updating rule table is shown in Table (4).

[0075] Table (4)

[0076]

[0077]

[0078] Therefore, the embodiment can update the access record tree by using the replacement truth table and the access record updating rule table after the storage block replacement or the storage block hit occurs, so as to maintain the access records of the storage blocks, and make it possible to find the least recently used storage block as the target storage block by querying the access record tree.

[0079] It should be understood that the embodiment is not limited to a specific cache replacement algorithm, and can use any cache replacement algorithm existing or developed in the future.

[0080] The data caching system of the embodiment of the present application comprises a data caching space, the data caching space comprises a plurality of storage blocks, the data caching system maintains priority states of the storage blocks, and the data caching system is configured to determine a target storage block according to a priority level of to-be-cached data and the priority states of the corresponding storage blocks, and store the to-be-cached data in the target storage block. Thus, the embodiment of the present application can affect the replacement weight of each storage block by maintaining the priority states of the storage blocks, and in the case of multi-priority level data, the hit rate of high-priority level data caching can be improved, thereby meeting the caching requirements of data of different priority levels, having high flexibility, and further improving the service quality and comprehensive capability of the network device. Further, the embodiment can also maintain the storage states and access records of the storage blocks, to preferentially determine an idle storage block as the target storage block when there is an idle storage block, determine a storage block with a storage priority level not higher than that of the to-be-cached data as the target storage block when there is no idle storage block in the data caching space, and determine the target storage block by using a predetermined caching replacement algorithm when the priority level of each storage block is higher than that of the to-be-cached data. Thus, the embodiment can further improve the service quality and comprehensive capability of the network device.

[0081] Figure 6 is a flowchart of the data caching method of the embodiment of the present application. The data caching method of the embodiment is implemented by the data caching system described above, wherein the data caching system maintains the priority states of each storage block in the data caching space. As shown in Figure 7 , the data caching method of the embodiment comprises the following steps:

[0082] Step S110, receiving a data caching request. The data caching request has corresponding to-be-cached data. For a request with a cache lookup miss, the required data is read from the main memory, and a data caching request is generated based on the read data and sent to the data caching system.

[0083] Step S120, determining a target storage block according to the priority level of the to-be-cached data and the priority states of each storage block. The data caching system of the embodiment maintains the priority states of each storage block. The priority state is used to represent the priority level of each storage block.

[0084] Optionally, the priority level of the data to be cached can be determined according to the type of the data to be cached. Further, the priority level can be determined according to the data access frequency and / or the data delay requirement. Among them, the higher the data access frequency and the more stringent the data delay requirement, the higher the corresponding data priority. It should be understood that the present embodiment does not limit the division of data priority, which can be determined according to the specific application scenario or resource usage, etc. Thus, the cache replacement method of the present embodiment can affect the replacement weight of each storage block by maintaining the priority state of the storage block, and in the case of multiple priority level data, the hit rate of high priority level data cache can be improved, thereby realizing the cache requirement of different priority level data, having high flexibility, and further improving the service quality and comprehensive ability of the network device.

[0085] Further, in the present embodiment, the present embodiment can find the priority state of each storage block according to the priority level of the data to be cached, to determine the storage block whose priority level is not greater than the priority level of the data to be cached as the target storage block. Thus, the present embodiment can improve the cache hit rate of high priority data, thereby improving the service quality and comprehensive ability of the network device. Optionally, the present embodiment maintains the priority state of each storage block through a tree structure. The present embodiment can query the storage block whose priority level is not greater than the priority level of the data to be cached through the corresponding priority tree, and the specific implementation manner is similar to the above-mentioned embodiment, which will not be described in detail here.

[0086] In a further optional implementation manner, the present embodiment increases the priority level of the corresponding storage block in response to the proportion of the storage block of the corresponding priority level being lower than a first threshold, and decreases the priority level of the corresponding storage block in response to the proportion of the storage block of the corresponding priority level being higher than a second threshold. Among them, the present embodiment can calculate the proportion of the storage block of the corresponding priority according to the number of priority storage blocks recorded by the counter. Optionally, the first threshold and the second threshold can be set according to the cache hit rate requirement of each priority data and the overall quality requirement of the system, which can be set according to the actual application scenario, and the present embodiment does not limit the specific determination manner of the first threshold and the second threshold, which meets the requirement of the corresponding network device.

[0087] In another optional implementation manner, the present embodiment can increase the priority level of the corresponding storage block when the number of storage blocks of the corresponding priority level is lower than a third threshold, and decrease the priority level of the corresponding storage block when the number of storage blocks of the corresponding priority level is higher than a fourth threshold.

[0088] Thus, the embodiment can dynamically adjust the size of the corresponding cache partition based on the storage block proportion of each priority type (or the number of storage blocks of each priority type), improve the cache hit rate of high-priority data, avoid the case that the cache hit rate of part of low-priority data is particularly low, and thus guarantee the cache hit rate of each type of data, which improves the flexibility of the data cache system of the embodiment and thus adapts to the deployment requirements of multiple data types.

[0089] In step S130, the data to be cached is stored in the target storage block.

[0090] Further, the priority state of each storage block of the embodiment dynamically changes according to the priority of the data cached thereby. That is, the embodiment updates the priority state of the target storage block to the priority level of the data to be cached after storing the data to be cached in the target storage block. Thus, the embodiment can further improve the flexibility of the priority configuration of each storage block in the data cache system, improve the sharing degree of the data cache space, and further adapt to the deployment requirements of multiple data types.

[0091] The data cache system of the embodiment includes a data cache space including a plurality of storage blocks, and the data cache system maintains the priority state of each storage block. The data cache system is configured to determine a target storage block according to the priority level of the data to be cached and the priority state of each corresponding storage block, and store the data to be cached in the target storage block. Thus, the embodiment can affect the replacement weight of each storage block by maintaining the priority state of the storage block, can improve the cache hit rate of high-priority level data in the case of multiple priority level data, and thus realize the cache requirements of different priority level data, has high flexibility, and thus can improve the service quality and comprehensive capability of the network device.

[0092] Figure 7 is a flowchart of another data caching method of the embodiment. The data caching method of the embodiment is implemented by the above-mentioned data cache system, wherein the data cache system maintains the priority state and storage state of each storage block in the data cache space. As shown in Figure 8 The data caching method of the embodiment includes the following steps:

[0093] In step S210, a data cache request is received. The data cache request has corresponding data to be cached. For a cache lookup miss request, the required data is read from the main memory, and a data cache request is generated based on the read data and sent to the data cache system.

[0094] Step S220, it is inquired whether there is a storage block in an idle state. If there is a storage block in an idle state, step S230 is executed, and if there is no storage block in an idle state, step S240 is executed.

[0095] In the embodiment, the access address in the data access request can be parsed to determine the set determined by the index of the access request, and it can be determined in the set whether there is a storage block in an idle state. In other optional implementation manners, it can also be inquired in all sets of the data cache space whether there is a storage block in an idle state, and the mapping relationship between the data cache space and the data address in the main memory after subsequent data caching is updated, so as to facilitate subsequent data access.

[0096] In an optional implementation manner, the storage state of each storage block is maintained by a tree structure. Since the storage state includes two states of idle and occupied, the storage state of each storage block can be maintained by a binary tree. Further, the current storage state signal can be used to traverse the storage state tree to determine whether there is a storage block in an idle state. The value of the lowest bit Vld bit0 of the storage state signal can be determined to determine whether there is a storage block in an idle state. Taking the assignment of the storage state signal shown in Table (2) as an example, if the value of the lowest bit Vld bit0 of the storage state signal is 1, it indicates that there is a storage block in an idle state, and if the value of the lowest bit Vld bit0 of the storage state signal is 0, it indicates that the corresponding storage blocks are all in an occupied state. It should be understood that the storage state tree and its specific traversal process are similar to the above embodiment, and will not be described here.

[0097] Step S230, in response to the data cache space having a corresponding storage block in an idle state, the corresponding storage block in an idle state is determined as a target storage block. The idle storage block matching the priority of the data to be cached can be preferentially acquired as the target storage block, and if there is no idle storage block matching the priority of the data to be cached in the data cache space, idle storage blocks with a priority lower than that of the data to be cached and idle storage blocks with a priority higher than that of the data to be cached can be sequentially inquired, and the inquired idle storage blocks are taken as the target storage block.

[0098] Step S240, in response to the data cache space not having a corresponding storage block in an idle state, it is inquired whether there is a storage block of a predetermined priority level. The predetermined priority level is lower than or equal to the priority level of the data to be cached. If there is a storage block with a priority level not higher than the priority level of the data to be cached, step S250 is executed, and if there is no storage block with a priority level not higher than the priority level of the data to be cached, step S260 is executed.

[0099] Optionally, the priority level of the data to be cached can be determined according to the type of the data to be cached. Further, the priority level can be determined according to the data access frequency and / or the requirement of data delay. Wherein, the higher the data access frequency is, the more strict the requirement of data delay is, and the higher the corresponding data priority is. It should be understood that the embodiment does not limit the division of data priority, which can be determined according to specific application scenarios or resource usage, etc.

[0100] In the embodiment, the access address in the data access request can be parsed to determine the set determined by the index of the access request, and the embodiment can determine whether there is a storage block with a priority level not higher than the priority level of the data to be cached in the set. In other optional implementation manners, the embodiment can also query whether there is a storage block with a priority level not higher than the priority level of the data to be cached in all sets of the data cache space, and update the mapping relationship between the data cache space and the data address in the main memory after subsequent data caching, so as to facilitate subsequent data access.

[0101] In an optional implementation manner, the embodiment maintains the priority state of each storage block through a tree structure. Taking an example in which the priority state includes two states of high priority and low priority, the embodiment can maintain the priority state of each storage block through a binary tree. Further, the embodiment can traverse the priority tree through the current priority signal to determine whether there is a storage block with a priority level not higher than the priority level of the data to be cached. Wherein, the embodiment can determine whether there is a storage block with a priority level not higher than the priority level of the data to be cached by determining the value of the lowest bit Cos bit0 of the priority signal. Taking the assignment of the priority signal shown in the above table (1) as an example, if the value of the lowest bit Cos bit0 of the priority signal is 1, it indicates that there is a storage block with a priority level not higher than the priority level of the data to be cached, and if the value of the lowest bit Cos bit0 of the storage state signal is 0, it indicates that the corresponding storage block is in a high priority state. It should be understood that the priority tree and its specific traversal process are similar to the above embodiment, which will not be described here.

[0102] In an optional implementation, before inquiring whether there is a storage block of a predetermined priority level, the embodiment can also determine the number of storage blocks of the corresponding priority level (or the proportion of storage blocks of the corresponding priority level) according to the counter recording the storage blocks of each priority level. Taking the case that the priority states include two states of high priority and low priority and the data cache system includes a counter of the number of low-priority storage blocks as an example, the embodiment inquires whether there is a storage block of a predetermined priority level in response to the current number of low-priority storage blocks reaching a first predetermined threshold (the proportion of storage blocks of the corresponding priority level reaching a second predetermined threshold). In response to the current number of low-priority storage blocks being less than the first predetermined threshold (the proportion of storage blocks of the corresponding priority level being less than the second predetermined threshold), the embodiment does not perform cache replacement by replacing low-priority storage blocks and executes step S260. The first predetermined threshold corresponds to the third threshold, and the second predetermined threshold corresponds to the first threshold. Thus, the embodiment can avoid performing cache replacement by replacing low-priority storage blocks when the number of low-priority storage blocks is too low, so as to avoid further reducing the number of low-priority storage blocks, thereby avoiding the case that the cache hit rate of low-priority data does not meet the access requirement due to the number of low-priority storage blocks being too low, and further enabling the system to guarantee the cache hit rate of storage blocks of each priority level.

[0103] In step S250, in response to the storage blocks in the data cache space being in the occupied state and there being a storage block of a predetermined priority level, the corresponding storage block in the predetermined priority level is determined as the target storage block. If there are multiple storage blocks of a predetermined priority level, the embodiment can randomly select one from them, or select a storage block that has not been accessed recently based on the access record, or select a storage block with a low access frequency based on the access record. That is, the predetermined cache replacement algorithm is performed on the inquired storage block of a predetermined priority level to obtain the target storage block, and the embodiment does not limit the specific cache replacement algorithm.

[0104] In step S260, in response to the storage blocks in the data cache space being in the occupied state and there being no storage block of a predetermined priority level, the target storage block is determined from the storage blocks according to the predetermined cache replacement algorithm.

[0105] Further, the embodiment can employ any one of the following cache replacement methods: Least Recently Used (LRU), Pseudo-LRU, Random (RAND), Least Frequently Used (LFU), Pseudo-Frequent LRU (PFLRU), Least Frequently Used in Time (LFUT), Adaptive Replacement Cache (ARC), Random-LRU, First-In-First-Out (FIFO), etc., and thus will not be described in detail herein.

[0106] In an optional implementation, the priority state of each storage block of the embodiment dynamically changes according to the priority of the data cached thereby. That is, after the data to be cached is stored in the target storage block, the priority state of the target storage block is updated to the priority level of the data to be cached. Thus, the embodiment can further improve the flexibility of the priority configuration of each storage block in the data caching system, improve the sharing degree of the data caching space, and further adapt to the deployment requirements of multiple data types.

[0107] Further, the embodiment increases the priority level of the corresponding storage block in response to the proportion of the storage block of the corresponding priority level being lower than a first threshold, and decreases the priority level of the corresponding storage block in response to the proportion of the storage block of the corresponding priority level being higher than a second threshold. The embodiment can calculate the proportion of the storage block of the corresponding priority level according to the number of storage blocks of the priority recorded by the counter. Optionally, the first threshold and the second threshold can be set according to the cache hit rate requirement of each priority data and the overall quality requirement of the system, and can be specifically set according to the actual application scenario. The embodiment does not limit the specific determination method of the first threshold and the second threshold, and it is sufficient that it meets the corresponding network equipment requirement.

[0108] In another optional implementation, the embodiment can increase the priority level of the corresponding storage block when the number of storage blocks of the corresponding priority level is lower than a third threshold, and decrease the priority level of the corresponding storage block when the number of storage blocks of the corresponding priority level is higher than a fourth threshold.

[0109] Thus, the embodiment can dynamically adjust the size of the corresponding cache partition based on the storage block proportion of each priority type (or the number of storage blocks of each priority type), improve the cache hit rate of high-priority data, avoid the case that the cache hit rate of part of low-priority data is particularly low, and thus guarantee the cache hit rate of each type of data, which improves the flexibility of the data cache system of the embodiment and thus adapts to the deployment requirements of multiple data types.

[0110] The data cache system of the embodiment includes a data cache space, the data cache space includes a plurality of storage blocks, the data cache system maintains a priority state of each storage block, and the data cache system is configured to determine a target storage block according to a priority level of to-be-cached data and the priority state of each corresponding storage block, and store the to-be-cached data into the target storage block. Thus, the embodiment can affect the replacement weight of each storage block by maintaining the priority state of the storage block, can improve the cache hit rate of high-priority level data in the case of multiple priority level data, and thus realizes the cache requirement of different priority level data, has high flexibility, and thus can improve the service quality and comprehensive capability of the network device. Further, the embodiment can also maintain the storage state and access record of each storage block to preferentially determine an idle storage block as the target storage block when there is an idle storage block, determine a storage block with a storage priority level not higher than the to-be-cached data as the target storage block when there is no idle storage block in the data cache space, and determine the target storage block by using a predetermined cache replacement algorithm when the priority level of each storage block is higher than the priority of the to-be-cached data. Thus, the embodiment can further improve the service quality and comprehensive capability of the network device.

[0111] Figure 8 FIG. 1 is a schematic diagram of a data cache device of the embodiment. The data storage device of the embodiment is applicable to a data cache system, the data cache system includes a data cache space, the data cache space includes a plurality of storage blocks, and the data cache system maintains a priority state of each storage block. As shown in FIG. 1, the data storage device 8 of the embodiment includes a request receiving unit 81, a determination unit 82, and a storage unit 83. Figure 9 The request receiving unit 81 is configured to receive a data cache request, and the data cache request has corresponding to-be-cached data. The determination unit 82 is configured to determine a target storage block according to a priority level of the to-be-cached data and the priority state of each storage block. The storage unit 83 is configured to store the to-be-cached data into the target storage block.

[0112] The request receiving unit 81 is configured to receive a data cache request, and the data cache request has corresponding to-be-cached data. The determination unit 82 is configured to determine a target storage block according to a priority level of the to-be-cached data and the priority state of each storage block. The storage unit 83 is configured to store the to-be-cached data into the target storage block.

[0113] In an alternative implementation, the data caching system maintains storage states of the storage blocks, and the determining unit 82 is further configured to: in response to a storage block in the data caching space being in an idle state, determine the corresponding storage block in the idle state as the target storage block; in response to a storage block in the data caching space being in an occupied state and a storage block of a predetermined priority level existing, determine the corresponding storage block of the predetermined priority level as the target storage block, the predetermined priority level being lower than or equal to the priority level of the data to be cached; and in response to a storage block in the data caching space being in an occupied state and no storage block of a predetermined priority level existing, determine the target storage block from the storage blocks according to a predetermined caching replacement algorithm.

[0114] In an alternative implementation, the priority states of the storage blocks dynamically change according to the priority of the cached data. The data storage device 8 further includes a level adjusting unit configured to: in response to the proportion of storage blocks of a corresponding priority level being lower than a first threshold, increase the priority level of the corresponding storage blocks; and in response to the proportion of storage blocks of a corresponding priority level being higher than a second threshold, decrease the priority level of the corresponding storage blocks.

[0115] The data caching system of the embodiment of the present application includes a data caching space, the data caching space including a plurality of storage blocks, the data caching system maintaining priority states of the storage blocks, the data caching system being configured to determine a target storage block according to the priority level of data to be cached and the priority states of the corresponding storage blocks, and store the data to be cached into the target storage block. Thus, the embodiment of the present application can affect the replacement weight of each storage block by maintaining the priority states of the storage blocks, and in the case of multiple priority level data, the hit rate of high priority level data caching can be improved, thereby meeting the caching requirements of data of different priority levels, having high flexibility, and further improving the service quality and comprehensive capability of the network device. Further, the embodiment can further maintain the storage states and access records of the storage blocks, to determine an idle storage block as the target storage block when an idle storage block exists, determine a storage block of a storage priority level not higher than the data to be cached as the target storage block when no idle storage block exists in the data caching space, and determine the target storage block according to a predetermined caching replacement algorithm when the priority level of each storage block is higher than the priority level of the data to be cached. Thus, the embodiment can further improve the service quality and comprehensive capability of the network device.

[0116] Figure 9 is a schematic diagram of a network processor of the embodiment of the present application. Another embodiment of the present application relates to a network processor. As shown in Figure 10As shown, the network processor 9 includes at least one processing core 91, a data cache space 92, and a control cache spacer (not shown). Each processing core 91 has a corresponding L1 cache and L2 cache. Multiple processing cores 91 share the data cache space 92, and are connected to it via a corresponding bus. Optionally, the data cache space 92 can be implemented using SRAM (Static Random Access Memory). Each processing core 91 includes multiple NP cores. Different types of NP cores process different types of data. NP cores processing different types of data share the data cache space 92.

[0117] This invention influences the replacement weight of each storage block by maintaining its priority status in the cache. In cases with data of multiple priority levels, it can improve the hit rate of high-priority data caching, thereby meeting the caching needs of different priority levels with high flexibility, ultimately improving the service quality and overall capabilities of network devices. Furthermore, this embodiment can maintain the storage status and access records of each storage block to prioritize the available storage block as the target storage block when one exists. If no free storage block exists in the data cache space, the storage block with a priority level no higher than the data to be cached is selected as the target storage block. When the priority level of each storage block is higher than the priority level of the data to be cached, a predetermined cache replacement algorithm is used to determine the target storage block. Therefore, this embodiment can further improve the service quality and overall capabilities of network devices.

[0118] Figure 10 This is a schematic diagram of a network device according to an embodiment of the present invention. The network device in this embodiment includes the network processor described above. Figure 10 As shown, the network device 10 of this embodiment includes at least one network processor 101, a memory 102, and a communication component 103. The communication component 103 receives and transmits data under the control of the network processor 101. The data caching system in the network processor 101 is used to execute the aforementioned data caching method. The memory 102 can serve as main memory to store data. When a data access request received by the communication component 103 is not found in the data cache space of the network processor 101, the required data is read from the memory 102 and cached as cacheable data in the corresponding data cache space of the network processor 101 to achieve data access.

[0119] Furthermore, the network processor 101, memory 102, and communication component 103 can be connected via a bus or other means. ​The bus connection is taken as an example. The memory 102, as a non-volatile computer readable storage medium, can also be used to store non-volatile software programs, non-volatile computer executable programs and modules. The network processor 101 can execute various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory 102, that is, implement the above-mentioned data caching method.

[0120] The memory 102 can include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required by a function; and the data storage area can store different types of data, etc. In addition, the memory 102 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 102 can optionally include a memory remotely arranged with respect to the network processor 101, and these remote memories can be connected to the external device through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0121] One or more modules are stored in the memory 102, and when executed by the one or more network processors 101, the data caching method in any method embodiment described above is executed.

[0122] The above-mentioned product can execute the method provided in the embodiments of the present application, has the corresponding functional modules and beneficial effects of executing the method, and the technical details not described in detail in the embodiments can be referred to the method provided in the embodiments of the present application.

[0123] The embodiment of the present application can improve the hit rate of the cache of the high priority level data by maintaining the priority state of each storage block in the cache, and can improve the hit rate of the cache of the high priority level data in the case of multiple priority level data, thereby realizing the cache requirement of different priority level data, having high flexibility, and further improving the service quality and comprehensive ability of the network device. Further, the embodiment can also maintain the storage state and access record of each storage block, to determine the idle storage block as the target storage block when there is an idle storage block, determine the storage block with the storage priority level not higher than the data to be cached as the target storage block when there is no idle storage block in the data cache space, and determine the target storage block by using a predetermined cache replacement algorithm when the priority level of each storage block is higher than the priority of the data to be cached. Thus, the embodiment can further improve the service quality and comprehensive ability of the network device.

[0124] Another embodiment of the present application relates to a non-volatile storage medium for storing a computer readable program for a computer to execute part or all of the method embodiments described above.

[0125] That is, a person skilled in the art can understand that all or part of the steps in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a program stored in a storage medium, including a number of instructions to cause a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the method described in the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0126] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data caching system, characterized in that, The data caching system includes: A data cache space, comprising multiple storage blocks, wherein the data cache system maintains the priority status of each storage block; The controller is configured to determine a target storage block based on the priority level of the data to be cached and the priority status of each of the corresponding storage blocks, store the data to be cached in the target storage block, and update the priority status of the target storage block to the priority level of the data to be cached. The priority status of each storage block changes dynamically according to the priority of the cached data. The controller is used to increase the priority level of the corresponding storage block when the proportion of storage blocks of the corresponding priority level is lower than a first threshold or the number of storage blocks of the corresponding priority level is lower than a third threshold, and to decrease the priority level of the corresponding storage block when the proportion of storage blocks of the corresponding priority level is higher than a second threshold or the number of storage blocks of the corresponding priority level is higher than a fourth threshold.

2. The system according to claim 1, characterized in that, The data cache space is initialized as at least one cache partition, which includes multiple storage blocks and is used to cache data of at least one priority level.

3. The system according to claim 1, characterized in that, The data caching system includes at least one counter, which is used to record the number of storage blocks corresponding to a certain priority level.

4. The system according to claim 1, characterized in that, The data caching system maintains the storage status of each storage block. After receiving the data to be cached, the controller, in response to the presence of an idle storage block in the data cache space, determines the corresponding idle storage block as the target storage block.

5. The system according to claim 1, characterized in that, After receiving the data to be cached, the controller, in response to the fact that the storage block in the data cache space is occupied and there is a storage block with a predetermined priority level, determines the corresponding storage block with the predetermined priority level as the target storage block, wherein the predetermined priority level is lower than or equal to the priority level of the data to be cached.

6. The system according to claim 1, characterized in that, The controller is further configured to, upon receiving the data to be cached, determine the target data block from each of the storage blocks in response to the storage blocks in the data cache space being occupied and the absence of a storage block with a predetermined priority level, according to a predetermined cache replacement algorithm.

7. A data caching method, applicable to a data caching system, characterized in that, The data caching system includes a data cache space, which includes multiple storage blocks. The data caching system maintains the priority state of each storage block. The method includes: Receive a data caching request, wherein the data caching request has corresponding data to be cached; The target storage block is determined based on the priority level of the data to be cached and the priority status of each storage block. The data to be cached is stored in the target storage block; Update the priority status of the target storage block to the priority level of the data to be cached; The priority status of each storage block changes dynamically according to the priority of the cached data. The method further includes: In response to the fact that the proportion of storage blocks of the corresponding priority level is lower than the first threshold and the number of storage blocks of the corresponding priority level is lower than the third threshold, the priority level of the corresponding storage block is increased. In response to the fact that the proportion of storage blocks of the corresponding priority level is higher than the second threshold, or the number of storage blocks of the corresponding priority level is higher than the fourth threshold, the priority level of the corresponding storage block is reduced.

8. The method according to claim 7, characterized in that, The data caching system maintains the storage status of each of the storage blocks, and determining the target storage block based on the priority level of the data to be cached and the priority status of each of the storage blocks includes: In response to the presence of a corresponding idle storage block in the data cache space, the corresponding idle storage block is determined as the target storage block; In response to the fact that a storage block in the data cache space is occupied and there is a storage block with a predetermined priority level, the corresponding storage block with the predetermined priority level is determined as the target storage block, wherein the predetermined priority level is lower than or equal to the priority level of the data to be cached. In response to a storage block in the data cache space being occupied and no storage block of a predetermined priority level being available, a target data block is determined from each of the storage blocks according to a predetermined cache replacement algorithm.

9. A data caching device, suitable for a data caching system, characterized in that, The data caching system includes a data cache space, which includes multiple storage blocks. The data caching system maintains the priority status of each storage block. The device includes: The request receiving unit is configured to receive data caching requests, wherein the data caching requests have corresponding data to be cached. The determining unit is configured to determine the target storage block based on the priority level of the data to be cached and the priority status of each storage block; The storage unit is configured to store the data to be cached in the target storage block and update the priority status of the target storage block to the priority level of the data to be cached. The priority status of each storage block changes dynamically according to the priority of the cached data. The device also includes a level adjustment unit, which is configured to increase the priority level of the corresponding storage block in response to the proportion of storage blocks of the corresponding priority level being lower than a first threshold or the number of storage blocks of the corresponding priority level being lower than a third threshold, and to decrease the priority level of the corresponding storage block in response to the proportion of storage blocks of the corresponding priority level being higher than a second threshold or the number of storage blocks of the corresponding priority level being higher than a fourth threshold.

10. A network processor, characterized in that, The network processor includes: Multiple processing cores; The data caching system as described in any one of claims 1-6; Each of the processing cores shares the data cache space corresponding to the data cache system.

11. A network device, characterized in that, The network device is equipped with the network processor as described in claim 10.

Citation Information

Patent Citations

  • Cache management method and device

    CN113138851A

  • Implementing advanced caching

    US20150378914A1