Data caching system, method and device, network processor and network equipment

By maintaining the priority status of the storage block in the cache system of the network processor and affecting the replacement weight, the problem of low hit rate of multi-priority level data cache in the prior art is solved, and higher service quality and comprehensive capabilities are achieved.

CN119669107AActive Publication Date: 2025-03-21T-HEAD (SHANGHAI) SEMICON CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411635764.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-03-21
Estimated Expiration
2044-11-14

AI Technical Summary

Technical Problem

When the cache system of existing network processors processes multi-priority level data, it is difficult to effectively improve the cache hit rate of high-priority data, resulting in limited service quality and comprehensive capabilities.

Method used

By maintaining the priority status of the memory block, affecting the replacement weight of each memory block, ensuring that the hit rate of high-priority level data in the cache system increases, thereby achieving flexible caching requirements for data of different priority level levels.

Benefits of technology

The service quality and comprehensive capabilities of network equipment have been improved. By dynamically adjusting the cache partition size and priority status, we ensure that the cache hit rate of high-priority data and the cache hit rate of low-priority data are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119669107A_ABST
    Figure CN119669107A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data caching system, method and device, a network processor and network equipment. The data caching system provided by the embodiment of the invention comprises a data caching space, the data caching space comprises a plurality of storage blocks, the data caching system maintains the priority state of each storage block, and the data caching system is used for determining a target storage block according to the priority level of to-be-cached data and the priority state of each corresponding storage block, and storing the to-be-cached data to the target storage block. Therefore, according to the embodiment of the invention, the replacement weight of each storage block can be influenced by maintaining the priority state of the storage block, and the hit rate of high-priority-level data caching can be improved under the condition of multi-priority-level data, so that the caching requirements of different-priority-level data are met, the flexibility is relatively high, and the data caching efficiency is improved. And the service quality and the comprehensive capability of the network equipment can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of semiconductor technology, and more specifically, to a data cache system, method, device, network processor and network equipment. Background Art

[0002] The cache design of network processors in various network devices has a great impact on the comprehensive capabilities of network devices. Taking NP (Network Processor) as an example, NP is a computing unit that completes tasks such as network protocol processing, high-speed data forwarding, and QoS (Quality of Service) assurance. It usually has the characteristics of light computing load, multi-threading, and low thread correlation. How to design the cache system (Cache) of NP is crucial to the performance, power consumption, and size of the chip. At the same time, it also affects the comprehensive capabilities of network devices that use NP to a certain extent. Summary of the invention

[0003] In view of this, the embodiments of the present invention provide a data caching system, method, apparatus, network processor and network device, which can influence the replacement weight of each storage block by maintaining the priority status of the storage block. In the case of multi-priority level data, the hit rate of high priority level data cache can be improved, thereby realizing the caching requirements of data of different priority levels, with high flexibility, and thus can improve the service quality and comprehensive capabilities of the network equipment.

[0004] In a first aspect, an embodiment of the present invention provides a data cache system, the data cache system comprising:

[0005] A data cache space, wherein the data cache space includes a plurality of storage blocks, and the data cache system maintains a priority status of each of the storage blocks;

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

[0007] In a second aspect, an embodiment of the present invention provides a data caching method, which is applicable to a data caching system, wherein the data caching system includes a data caching space, the data caching space includes a plurality of storage blocks, and the data caching system maintains a priority state of each of the storage blocks, the method comprising:

[0008] Receiving a data cache request, wherein the data cache request has corresponding data to be cached;

[0009] Determining a target storage block according to the priority level of the data to be cached and the priority status of each storage block;

[0010] The data to be cached is stored in the target storage block.

[0011] In a third aspect, an embodiment of the present invention provides a data cache device, which is applicable to a data cache system, wherein the data cache system 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 of the storage blocks, and the device includes:

[0012] A request receiving unit, configured to receive a data cache request, wherein the data cache request has corresponding data to be cached;

[0013] A determination unit, configured to determine a target storage block according to a priority level of the data to be cached and a priority state of each of the storage blocks;

[0014] The storage unit is configured to store the data to be cached in the target storage block.

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

[0016] Multiple processing cores;

[0017] A data caching system as described above;

[0018] Among them, each of the processing cores shares the data cache space corresponding to the data cache system.

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

[0020] The data cache system of the embodiment of the present invention includes a data cache space, the data cache space includes a plurality of storage blocks, the data cache system maintains the priority status of each storage block, and the data cache system is used to determine the target storage block according to the priority level of the data to be cached and the corresponding priority status of each storage block, and store the data to be cached in the target storage block. Therefore, the embodiment of the present invention can affect the replacement weight of each storage block by maintaining the priority status of the storage block, and in the case of data with multiple priority levels, it can improve the hit rate of the high priority level data cache, thereby realizing the cache requirements of data of different priority levels, with high flexibility, and further can improve the service quality and comprehensive capabilities of the network device. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0022] Figure 1 is a schematic diagram of the structure of a data cache system according to an embodiment of the present invention;

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

[0024] Figure 3 is a schematic diagram of initializing data cache space according to an embodiment of the present invention;

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

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

[0027] Figure 6 is a flow chart of a data caching method according to an embodiment of the present invention;

[0028] Figure 7 is a flow chart of another data caching method according to an embodiment of the present invention;

[0029] Figure 8 is a schematic diagram of a data cache device according to an embodiment of the present invention;

[0030] Fig. 9 is a schematic diagram of a network processor according to an embodiment of the present invention;

[0031] Fig.10 Schematic diagram of a network device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0032] The present application is described below based on embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, some specific details are described in detail. It is possible for those skilled in the art to fully understand the present application without the description of these details. In order to avoid confusing the essence of the present application, known methods, processes, flows, components and circuits are not described in detail.

[0033] In addition, persons of ordinary skill in the art will appreciate that the drawings provided herein are for illustration purposes and are not necessarily drawn to scale.

[0034] Unless the context clearly requires otherwise, the words "include", "comprising" and similar words throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, the meaning is "including but not limited to".

[0035] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.

[0036] The solutions described in this specification and in the examples, if they involve the processing of personal information, will be processed on the premise of having a legal basis (such as obtaining the consent of the subject of personal information, or being necessary for the performance of a contract, etc.), and will only be processed within the scope of regulations or agreements. If a user refuses to process personal information other than the necessary information for basic functions, it will not affect the user's use of basic functions.

[0037] The mixed cache of multiple types of data in the relevant comparison ratio adopts a fully shared cache or a partitioned cache method. For the fully shared cache method, it completely relies on the replacement algorithm to ensure the hit rate of cache access. Although it can achieve a lower cache access delay and a higher cache sharing degree, the hit rate of each type of data cannot be controlled after the data type (different data types have the same or different priorities) increases, which may cause the access delay of some types of data to increase significantly. For the partitioned cache method, the cache is divided into multiple cache partitions, each cache partition corresponds to a type of data. At this time, the cache space of each type of data is completely independent. Although 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, the cache resources between cache partitions cannot be shared, which increases the required cache capacity, and the more cache partitions there are, the more complex the access path control logic is, and the access delay is relatively increased, which will reduce the overall performance of the system. Based on this, the embodiments of the present invention provide a data caching system, method, network processor and network device, which can influence the replacement weight of each storage block by maintaining the priority status of the storage block. In the case of multi-priority level data, the hit rate of high priority level data cache can be improved, thereby realizing the caching requirements of data of different priority levels, with high flexibility, and thus can improve the service quality and comprehensive capabilities of the network device.

[0038] Figure 1 Schematic diagram of the structure of the data cache system of the embodiment of the present invention. Figure 1 As shown, the data cache system 1 of the embodiment of the present invention includes a data cache space 11 and a controller 12. Among them, the data cache space 11 includes multiple storage blocks. Taking the 8-Way Set Associative data cache space as an example, the data cache space includes multiple sets, each set includes 8 cache lines (Cache Line, that is, the storage block in this embodiment), and the size of each cache line is a predetermined number of bytes. It should be understood that the above-mentioned 8-Way Set Associative type of data cache space is only a schematic example, and the embodiment of the present invention does not show the type and specific structure of the data cache space.

[0039] For requests with cache lookup misses, the required data needs to be read from the main memory and stored in a storage block in the data cache space. Taking the above-mentioned 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 by the index, and checks whether the tag of the storage block in the set matches the tag of the access address in the determined set. If a storage block matching the tag of the access address is found in the determined set, a cache hit is determined, and the offset obtained by parsing is used to read data from the matching 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, a cache miss is determined, and a storage block needs to be selected for replacement. For example, when a cache miss occurs, data is read from the main content and a storage block in the data cache space is replaced. Further, the network processor can choose to select a storage block from the determined set in the data cache space for replacement.

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

[0041] In this embodiment, if a data access request cache misses, the controller 12 can determine the target storage block according to the priority level of the corresponding data to be cached and the priority status of each corresponding storage block, and store the data to be cached in the target storage block. Wherein, 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 data to be cached. Further, the priority level can be determined according to the requirements of data access frequency and / or data delay. Wherein, the higher the data access frequency and the stricter the data delay requirement, the higher the corresponding data priority. It should be understood that this embodiment does not limit the division of data priority, which can be determined according to specific application scenarios or resource usage. Therefore, the cache replacement method of this embodiment can affect the replacement weight of each storage block by maintaining the priority status of the storage block. In the case of multi-priority level data, the hit rate of the high priority level data cache can be improved, thereby realizing the cache requirements of data of different priority levels, with high flexibility, and thus can improve the service quality and comprehensive capabilities of the network device.

[0042] Furthermore, in this embodiment, the controller 12 can search for the priority status of each corresponding storage block according to the priority level of the data to be cached, so as 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, this embodiment can improve the cache hit rate of high-priority data, thereby improving the service quality and comprehensive capabilities of the network device.

[0043] In an optional implementation, the present embodiment maintains the priority status of each storage block through a tree structure. Taking the priority status including two levels as an example, the present embodiment can maintain the priority status of each storage block through a binary tree. Taking the two levels as high priority (high) and low priority (low) as an example, the present embodiment can maintain the priority status of each storage block through a binary tree.

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

[0045] Table (1)

[0046]

[0047] Among them, L0 to L7 respectively represent 8 storage blocks in a group in the data cache space 11. The priority signal includes 7 bits Cos bit0 to Cos bit6. A bit value of 1 in the priority signal indicates that there is a low-priority storage block in the corresponding at least one storage block, and a bit value of 0 in the priority signal indicates that there is a high-priority storage block in the corresponding at least one storage block.

[0048] like Figure 2 As shown, Figure 2 B0 to B6 in the byte correspond to the 7 bits Cos bit0 to Cos bit6 in the priority signal respectively. Figure 2 The "B1 low" in the binary tree is used to indicate that there are low-priority storage blocks in the child nodes in the B1 branch of the binary tree, that is, Cos bit1=1, and there are low-priority storage blocks in the storage blocks L0~L3. It can be seen that if the storage block L0 is a low-priority storage block, the values ​​of the bits Cos bit3, Cos bit1 and Cos bit0 in the priority signal are all 1. At the same time, if the storage blocks L2 and L3 are both high-priority storage blocks, the value of the bit Cos bit4 in the priority signal is 0. Therefore, this embodiment can update the corresponding priority tree according to the priority status of each storage block to achieve the maintenance of the priority status of each storage block.

[0049] Further, if the priority signal currently corresponding to a group in the data cache space 11 is 0001011. Assuming that the current data access request does 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 the storage blocks L0 and L1 in the corresponding group, and the storage blocks L2-L7 are all high priority storage blocks. The priority status of the storage blocks L0 and L1 is further queried to determine that the storage block L0 is a low priority storage block and L1 is a high priority storage block, 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 low priority storage blocks, this embodiment can also randomly select 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, and this 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 invention. In an optional implementation, the data cache space of the present embodiment is initialized into at least one cache partition, each cache partition including a plurality of storage blocks. The cache partition is used to cache data of at least one priority level. Figure 3 As shown, the initialized data cache space 11 is divided into two cache partitions 111 and 112. Among them, cache partition 111 is used to store data of the first priority and the second priority, and cache partition 112 is used to store data of the third priority. The data cache space 11 of this embodiment divides the addresses in the data cache space 11 based on the priority to obtain at least one cache partition. Since the priority levels of different types of data may be the same, compared with the method of performing cache partitioning based on data type in the comparative example, the data cache space can be shared to a certain extent, reducing the required data cache space capacity, and at the same time, the cache hit rate of various types of data can be improved to a certain extent.

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

[0052] In a further optional implementation, the controller 12 of this embodiment is also 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 the first threshold, and to reduce the priority level of the corresponding storage block when the proportion of storage blocks of the corresponding priority level is higher than the second threshold. Among them, this embodiment can calculate the proportion of storage blocks of the corresponding priority level 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 requirements of each priority data and the overall quality requirements of the system, which can be specifically set according to the actual application scenario. This embodiment does not limit the specific determination method of the first threshold and the second threshold, which meets the requirements of the corresponding network device.

[0053] In another optional implementation, the controller 12 of this embodiment can also be used to 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 to lower 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.

[0054] Therefore, this embodiment can dynamically adjust the size of the corresponding cache partition based on the proportion of storage blocks of each priority level (or the number of storage blocks of each priority level). While improving the cache hit rate of high-priority data, it avoids the situation where 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 this embodiment, thereby adapting to the deployment requirements of multiple data types.

[0055] In an optional implementation, the data cache system 1 of this embodiment also maintains the storage status of each storage block. The storage status includes an idle state and an occupied state. Among them, the idle state indicates that the corresponding storage block does not store data, and the occupied state indicates that the corresponding storage block stores data. After receiving the data to be cached, the controller 12 responds to the storage block in the data cache space being in an idle state and determines the corresponding storage block in the idle state as the target storage block. Further, after receiving the data to be cached, the controller 12 responds to the storage block in the data cache space being in an occupied state and there being a storage block of a predetermined priority level, and determines the corresponding storage block at a predetermined priority level as the target storage block, and the predetermined priority level is lower than or equal to the priority level of the data to be cached.

[0056] Optionally, the present embodiment can use any idle storage block found in the query as the target storage block. In other optional implementations, the present embodiment can preferentially obtain an idle storage block that matches the priority of the data to be cached as the target storage block. If there is no idle storage block that matches the priority of the data to be cached in the data cache space 11, it can be sequentially queried whether there are idle storage blocks with a lower priority than the data to be cached and idle storage blocks with a higher priority than the data to be cached, and the queried idle storage block is used as the target storage block. If no idle storage block is found in the query, the storage block replacement scheme is executed using the above-mentioned replacement method based on the priority status of each storage block.

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

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

[0059] Figure 4 Schematic diagram of the storage state tree of the embodiment of the present invention. Taking the storage state tree of one group in the data cache space 11 with 8 rows associative groups as an example, each group in the data cache space 11 requires a 7-bit storage state signal. Figure 4 As shown, the assignment description of the storage state signal corresponding to the storage state tree is shown in Table (2).

[0060] Table (2)

[0061]

[0062] Among them, L0 to L7 respectively represent 8 storage blocks in a certain group in the data cache space 11. The storage status signal includes 7 bits Vld bit0 to Vld bit6. A bit value of 1 in the storage status signal indicates that there is an idle storage block in the corresponding at least one storage block, and a bit value of 0 in the storage status signal indicates that the corresponding at least one storage block is occupied.

[0063] like Figure 4 As shown, Figure 4 B0 to B6 in respectively correspond to the 7 bits Vld bit0 to Vld bit6 in the storage state signal. Figure 4 "B1 free" in is used to indicate that there is a free storage block in the child node in the B1 branch of the binary tree, that is, Vld bit1=1, and there is a free storage block in the storage blocks L0~L3. It can be seen that if the storage block L0 is in the free state, the values ​​of the bits Vld bit3, Vld bit1 and Vld bit0 in the priority signal are all 1. At the same time, if the storage blocks L2 and L3 are both in the occupied state, the value of the bit Vld bit4 in the priority signal is 0. Therefore, this embodiment can update the corresponding storage status tree according to the storage status of each storage block to achieve the maintenance of the storage status of each storage block.

[0064] Further, if the storage status signal currently corresponding to a group in the data cache space 11 is 0001011. Assuming that the current data access request does not hit, the data to be cached read from the main memory is high priority data. Based on the storage status tree corresponding to the group and the storage status information, it can be determined that there are idle storage blocks in the storage blocks L0 and L1 in the corresponding group, and the storage blocks L2-L7 are all in an occupied state. Further query the storage status of the storage blocks L0 and L1, determine that the storage block L0 is in an idle state and L1 is in an occupied state, then determine the storage block L0 as the target storage block, and store the data to be cached in the target storage block L0. Further optionally, if the storage blocks L0 and L1 are both in an idle state, this embodiment can also randomly select 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, and this embodiment does not limit this.

[0065] Further, if the value of the first bit Vld bit0 of the storage state signal currently corresponding to a certain group in the data cache space 11 is 0, it indicates that all storage blocks in the group are in an occupied state. This embodiment can determine whether there is a storage block with a priority level not higher than the data to be cached based on the priority tree corresponding to the group and the current priority signal. If so, the storage block with a priority level not higher than the data to be cached in the group is determined as the target storage block. Taking the priority binary tree in which the priority state includes high priority and low priority as an example, assuming that the priority signal currently corresponding to the above group is 0001011, based on the priority tree corresponding to the group and the current priority signal, it can be determined that there is a low-priority storage block in the storage blocks L0 and L1 in the corresponding group, and the storage blocks L2-L7 are all high-priority storage blocks. The priority states of the storage blocks L0 and L1 are further queried to determine that the storage block L0 is a low-priority storage block and L1 is a high-priority storage block. 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 storage blocks L0 and L1 are both low-priority storage blocks, this embodiment may also randomly select therefrom, or select a storage block that has not been accessed recently based on access records, or select a storage block with a low access frequency based on access records, and this embodiment is not limited to this.

[0066] In an optional implementation, the controller 12 is further configured to, after receiving the data to be cached, determine the target data block from each storage block according to a predetermined cache replacement algorithm (Cache Replacement Algorithms) in response to the storage blocks in the data cache space being occupied and the storage blocks of the predetermined priority level not existing. The cache replacement algorithm is a type of algorithm used to determine which storage block should be replaced when the cache is full, so as to maximize the cache hit rate within the limited cache space, thereby improving the performance of the system.

[0067] Furthermore, this embodiment can adopt any one of the least recently used (LRU), pseudo least recently used (PLRU, Pseudo-LRU), random replacement (RAND, Random), least frequently used (LFU, Least Frequently Used), least frequently used approximation (PFLRU, Pseudo-Frequent LRU), least frequently used time (LFUT, Least Frequently Used in Time), adaptive replacement (ARC, Adaptive Replacement Cache), random least recently used (RAND-LRU), first-in-first-out (FIFO, First-In-First-Out), etc. to implement cache replacement, and examples are not given one by one here.

[0068] Among them, FIFO uses a queue to record the entry order of each storage block, so that the storage block with the highest entry into the cache is replaced first. LRU uses a bidirectional linked list to record the access order of each storage block, and moves the corresponding storage block to the head of the linked list each time it is accessed, so that the storage block least recently used is replaced first. PLRU uses a binary tree to record the usage of each storage block, and updates the state of the tree each time it is accessed, so as to record the usage of each storage block through the tree structure, so that the storage block least recently used is replaced first as much as possible. RAND selects the storage block to be replaced by using a random number generator to randomly select a storage block for replacement. LFU maintains a counter for each storage block to record the number of times it is accessed, so that the storage block with the least number of uses is replaced first. PFLRU uses a counter array to record the number of accesses to each storage block, and resets the counter regularly to record the usage frequency of each storage block through a simplified method, so that the storage block with the least number of uses is replaced first. LFUT maintains a counter and a timestamp for each storage block to combine time and frequency to select the storage block with the least number of uses for replacement. ARC uses two cache lists, one for LRU and one for LFU, and dynamically adjusts the size of the two lists according to the access pattern to combine the advantages of LRU and LFU and adaptively adjust the replacement strategy. RAND-LRU combines the advantages of random replacement and LRU by randomly selecting a storage block for replacement with a certain probability based on the LRU algorithm, and selects the storage block corresponding to LRU for replacement with a certain probability.

[0069] This embodiment uses PLRU for cache replacement as an example. The data cache system of this embodiment also maintains access records of storage blocks, and queries the least recently used storage block based on the access records, and uses it as the target storage block. Further, this embodiment maintains access records of each storage block through a binary tree structure.

[0070] Figure 5 Schematic diagram of the access record tree of the embodiment of the present invention. Taking the access record tree of one group in the data cache space 11 with 8 rows associative groups as an example, each group in the data cache space 11 requires a 7-bit access record signal. Figure 5 As shown, 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 No Care 1 L7

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

[0074] Furthermore, when a storage block replacement or a storage block hit occurs in the group, the access record signal is updated, and the update rule table is shown in Table (4).

[0075] Table (4)

[0076]

[0077]

[0078] Therefore, this embodiment can update the access record tree by replacing the truth table and the access record update rule table after a storage block replacement or storage block hit occurs to maintain the access records of each storage block, so that the least recently used storage block can be found by querying the access record tree and used as the target storage block.

[0079] It should be understood that this embodiment does not limit a specific cache replacement algorithm, and any cache replacement algorithm currently available or generated in the future may be used.

[0080] The data cache system of the embodiment of the present invention includes a data cache space, the data cache space includes a plurality of storage blocks, the data cache system maintains the priority status of each storage block, and the data cache system is used to determine the target storage block according to the priority level of the data to be cached and the corresponding priority status of each storage block, and store the data to be cached in the target storage block. Therefore, the embodiment of the present invention can affect the replacement weight of each storage block by maintaining the priority status of the storage block, and in the case of multi-priority level data, the hit rate of the high priority level data cache can be improved, so as to realize the cache requirements of data of different priority levels, with high flexibility, and thus can improve the service quality and comprehensive capacity of the network device. Further, the present embodiment can also maintain the storage status and access records of each storage block, so as to preferentially determine the free storage block as the target storage block when there is a free storage block, and when there is no free storage block in the data cache space, determine the storage block whose storage priority level is not higher than the data to be cached as the target storage block, and when the priority level of each storage block is higher than the priority level of the data to be cached, adopt a predetermined cache replacement algorithm to determine the target storage block. Therefore, the present embodiment can further improve the service quality and comprehensive capacity of the network device.

[0081] Figure 6 is a flow chart of a data caching method according to an embodiment of the present invention. The data caching method according to this embodiment is implemented by the above-mentioned data caching system, wherein the data caching system maintains the priority status of each storage block in the data caching space. Figure 6 As shown, the data caching method of this embodiment includes the following steps:

[0082] Step S110, receiving a data cache request. The data cache request has corresponding data to be cached. For a cache search 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.

[0083] Step S120, determining the target storage block according to the priority level of the data to be cached and the priority status of each storage block. The data cache system of this embodiment maintains the priority status of each storage block. The priority status is used to characterize 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 data to be cached. Further, the priority level can be determined according to the data access frequency and / or data delay requirements. Among them, the higher the data access frequency and the stricter the data delay requirements, the higher the corresponding data priority. It should be understood that this embodiment does not limit the division of data priorities, which can be determined according to specific application scenarios or resource usage. Therefore, the cache replacement method of this embodiment can affect the replacement weight of each storage block by maintaining the priority status of the storage block. In the case of multi-priority level data, the hit rate of the high priority level data cache can be improved, thereby realizing the caching requirements of data of different priority levels, with high flexibility, and thus can improve the service quality and comprehensive capabilities of the network equipment.

[0085] Further, in this embodiment, this embodiment can search for the priority status of each corresponding storage block according to the priority level of the data to be cached, so as 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, this embodiment can improve the cache hit rate of high-priority data, thereby improving the service quality and comprehensive capabilities of the network device. Optionally, this embodiment maintains the priority status of each storage block through a tree structure. This 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 method is similar to the above embodiment, which will not be described in detail here.

[0086] In a further optional implementation, in response to the proportion of storage blocks corresponding to the priority level being lower than a first threshold, this embodiment increases the priority level of the corresponding storage block, and in response to the proportion of storage blocks corresponding to the priority level being higher than a second threshold, reduces the priority level of the corresponding storage block. Among them, this embodiment can calculate the proportion of storage blocks corresponding to the priority level 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 requirements of each priority data and the overall quality requirements of the system, which can be specifically set according to the actual application scenario. This embodiment does not limit the specific determination method of the first threshold and the second threshold, which can meet the requirements of the corresponding network device.

[0087] In another optional implementation, this 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 the third threshold, and lower the priority level of the corresponding storage block when the number of storage blocks of the corresponding priority level is higher than the fourth threshold.

[0088] Therefore, this embodiment can dynamically adjust the size of the corresponding cache partition based on the proportion of storage blocks of each priority level (or the number of storage blocks of each priority level). While improving the cache hit rate of high-priority data, it avoids the situation where 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 this embodiment, thereby adapting to the deployment requirements of multiple data types.

[0089] Step S130: storing the data to be cached in the target storage block.

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

[0091] The data cache system of the embodiment of the present invention includes a data cache space, the data cache space includes a plurality of storage blocks, the data cache system maintains the priority status of each storage block, and the data cache system is used to determine the target storage block according to the priority level of the data to be cached and the corresponding priority status of each storage block, and store the data to be cached in the target storage block. Therefore, the embodiment of the present invention can affect the replacement weight of each storage block by maintaining the priority status of the storage block, and in the case of data with multiple priority levels, it can improve the hit rate of the high priority level data cache, thereby realizing the cache requirements of data of different priority levels, with high flexibility, and further can improve the service quality and comprehensive capabilities of the network device.

[0092] Figure 7 FIG. 1 is a flow chart of another data caching method according to an embodiment of the present invention. The data caching method according to the present embodiment is implemented by the above-mentioned data caching system, wherein the data caching system maintains the priority status and storage status of each storage block in the data caching space. Figure 7 As shown, the data caching method of this embodiment includes the following steps:

[0093] Step S210, receiving a data cache request. The data cache request has corresponding data to be cached. For a cache search 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, query whether there is a free storage block. If there is a free storage block, execute step S230, if there is no free storage block, execute step S240.

[0095] In this 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 in an idle state in the set. In other optional implementations, the embodiment can also query whether there is a storage block in an idle state 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.

[0096] In an optional implementation, the present embodiment maintains the storage state of each storage block through a tree structure. Since the storage state includes two states, namely, idle and occupied, the present embodiment can maintain the storage state of each storage block through a binary tree. Further, the present embodiment can determine whether there is a storage block in an idle state by traversing the storage state tree through the current storage state signal. Among them, the present embodiment can determine whether there is a storage block in an idle state by determining the value of the lowest bit Vld bit0 of the storage state signal. Taking the assignment description of the storage state signal shown in the above 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. 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 repeated here.

[0097] Step S230, in response to the corresponding storage block in the data cache space being in an idle state, the corresponding storage block in an idle state is determined as a target storage block. In this embodiment, an idle storage block that matches the priority of the data to be cached can be obtained preferentially as the target storage block. If there is no idle storage block that matches the priority of the data to be cached in the data cache space, it can be sequentially queried whether there are idle storage blocks with a lower priority than the data to be cached and idle storage blocks with a higher priority than the data to be cached, and the queried idle storage blocks are used as the target storage blocks.

[0098] Step S240, in response to the fact that there is no corresponding storage block in the data cache space that is in an idle state, query whether there is a storage block with 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, execute step S250; if there is no storage block with a priority level not higher than the priority level of the data to be cached, execute step S260.

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

[0100] In this embodiment, this embodiment can parse the access address in the data access request, determine the set determined by the index of the access request, and this 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 implementations, this 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, the present embodiment maintains the priority status of each storage block through a tree structure. Taking the priority status including two states of high priority and low priority as an example, the present embodiment can maintain the priority status of each storage block through a binary tree. Further, the present embodiment can determine whether there is a storage block whose priority level is not higher than the priority level of the data to be cached by traversing the priority tree through the current priority signal. Among them, the present embodiment can determine whether there is a storage block whose priority level is 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 description 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 whose priority level is not higher than the priority level of the data to be cached. If the value of the lowest bit Cos bit0 of the storage status signal is 0, it indicates that the corresponding storage blocks are all in a high priority state. It should be understood that the priority tree and its specific traversal process are similar to the above embodiment and will not be repeated here.

[0102] In an optional implementation, before querying whether there are storage blocks of a predetermined priority level, this 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 that records the storage blocks of each priority level. Taking the case where the priority state includes two states, high priority and low priority, and the data cache system includes a counter of the number of storage blocks of low priority as an example, in response to the current number of storage blocks of low priority reaching a first predetermined threshold (the proportion of storage blocks of the corresponding priority level reaches a second predetermined threshold), this embodiment queries whether there are storage blocks of the predetermined priority level, and in response to the current number of storage blocks of low priority being less than the first predetermined threshold (the proportion of storage blocks of the corresponding priority level being less than the second predetermined threshold), cache replacement is not performed by replacing the low priority storage blocks, and step S260 is executed. Among them, the above-mentioned first predetermined threshold corresponds to the above-mentioned third threshold, and the second predetermined threshold corresponds to the above-mentioned first threshold. Therefore, this embodiment can avoid using the method of replacing low-priority storage blocks for cache replacement 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 situation where the cache hit rate of low-priority data does not meet the access requirements due to the low number of low-priority storage blocks, thereby enabling the system to ensure the cache hit rate of storage blocks of each priority level.

[0103] Step S250, in response to the storage block in the data cache space being in an occupied state and the existence of a storage block of a predetermined priority level, the corresponding storage block of the predetermined priority level is determined as the target storage block. If there are multiple storage blocks of the predetermined priority level, this embodiment can randomly select 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, a predetermined cache replacement algorithm is executed on the queried storage block of the predetermined priority level to obtain the target storage block, and this embodiment does not limit the specific cache replacement algorithm.

[0104] Step S260 , in response to the storage blocks in the data cache space being in an occupied state and no storage blocks of a predetermined priority level exist, determining a target storage block from the storage blocks according to a predetermined cache replacement algorithm.

[0105] Furthermore, this embodiment can adopt any one of the least recently used (LRU), pseudo least recently used (PLRU, Pseudo-LRU), random replacement (RAND, Random), least frequently used (LFU, Least Frequently Used), least frequently used approximation (PFLRU, Pseudo-Frequent LRU), least frequently used time (LFUT, Least Frequently Used in Time), adaptive replacement (ARC, Adaptive Replacement Cache), random least recently used (RAND-LRU), first-in-first-out (FIFO, First-In-First-Out), etc. to implement cache replacement, and examples are not given one by one here.

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

[0107] Furthermore, in response to the proportion of storage blocks of the corresponding priority level being lower than the first threshold, the present embodiment increases the priority level of the corresponding storage block, and in response to the proportion of storage blocks of the corresponding priority level being higher than the second threshold, decreases the priority level of the corresponding storage block. Among them, the present embodiment calculates the proportion of storage blocks of the corresponding priority level 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 requirements of each priority data and the overall quality requirements of the system, which can be specifically set according to the actual application scenario. The present embodiment does not limit the specific determination method of the first threshold and the second threshold, which can meet the requirements of the corresponding network device.

[0108] In another optional implementation, this 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 the third threshold, and lower the priority level of the corresponding storage block when the number of storage blocks of the corresponding priority level is higher than the fourth threshold.

[0109] Therefore, this embodiment can dynamically adjust the size of the corresponding cache partition based on the proportion of storage blocks of each priority level (or the number of storage blocks of each priority level). While improving the cache hit rate of high-priority data, it avoids the situation where 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 this embodiment, thereby adapting to the deployment requirements of multiple data types.

[0110] The data cache system of the embodiment of the present invention includes a data cache space, the data cache space includes a plurality of storage blocks, the data cache system maintains the priority status of each storage block, and the data cache system is used to determine the target storage block according to the priority level of the data to be cached and the corresponding priority status of each storage block, and store the data to be cached in the target storage block. Therefore, the embodiment of the present invention can affect the replacement weight of each storage block by maintaining the priority status of the storage block, and in the case of multi-priority level data, the hit rate of the high priority level data cache can be improved, so as to realize the cache requirements of data of different priority levels, with high flexibility, and thus can improve the service quality and comprehensive capacity of the network device. Further, the present embodiment can also maintain the storage status and access records of each storage block, so as to preferentially determine the free storage block as the target storage block when there is a free storage block, and when there is no free storage block in the data cache space, determine the storage block whose storage priority level is not higher than the data to be cached as the target storage block, and when the priority level of each storage block is higher than the priority level of the data to be cached, adopt a predetermined cache replacement algorithm to determine the target storage block. Therefore, the present embodiment can further improve the service quality and comprehensive capacity of the network device.

[0111] Figure 8 Schematic diagram of a data cache device according to an embodiment of the present invention. The data storage device according to this 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 the priority status of each of the storage blocks. Figure 8 As shown, the data storage device 8 of this embodiment includes a request receiving unit 81, a determining unit 82 and a storage unit 83.

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

[0113] In an optional implementation, the data cache system maintains the storage status of each of the storage blocks, and the determination unit 82 is further configured to: in response to the data cache space having a corresponding idle storage block, determine the corresponding idle storage block as the target storage block; in response to the storage blocks in the data cache space being in an occupied state and there being storage blocks of a predetermined priority level, determine the corresponding storage block of a 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; in response to the storage blocks in the data cache space being in an occupied state and there being no storage blocks of a predetermined priority level, determine the target data block from each of the storage blocks according to a predetermined cache replacement algorithm.

[0114] In an optional implementation, the priority state of each storage block changes dynamically according to the priority of the cached data. The data storage device 8 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, and to reduce 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.

[0115] The data cache system of the embodiment of the present invention includes a data cache space, the data cache space includes a plurality of storage blocks, the data cache system maintains the priority status of each storage block, and the data cache system is used to determine the target storage block according to the priority level of the data to be cached and the corresponding priority status of each storage block, and store the data to be cached in the target storage block. Therefore, the embodiment of the present invention can affect the replacement weight of each storage block by maintaining the priority status of the storage block, and in the case of multi-priority level data, the hit rate of the high priority level data cache can be improved, so as to realize the cache requirements of data of different priority levels, with high flexibility, and thus can improve the service quality and comprehensive capacity of the network device. Further, the present embodiment can also maintain the storage status and access records of each storage block, so as to preferentially determine the free storage block as the target storage block when there is a free storage block, and when there is no free storage block in the data cache space, determine the storage block whose storage priority level is not higher than the data to be cached as the target storage block, and when the priority level of each storage block is higher than the priority level of the data to be cached, adopt a predetermined cache replacement algorithm to determine the target storage block. Therefore, the present embodiment can further improve the service quality and comprehensive capacity of the network device.

[0116] Fig. 9 is a schematic diagram of a network processor according to an embodiment of the present invention. Another embodiment of the present invention relates to a network processor. Fig. 9As shown, the network processor 9 includes at least one processing core 91, a data cache space 92, and a spacer for controlling the cache (not shown in the figure). Among them, the processing core 91 has a corresponding first-level cache (L1Cache) and a second-level cache (L2Cache). Multiple processing cores 91 share the data cache space 92, and multiple processing cores 91 are connected to the data cache space 92 through a corresponding bus. Optionally, the data cache space 92 can be implemented using SRAM (static random access memory). The processing core 91 includes multiple NP cores. Among them, different types of NP cores run different types of data. NP cores running different types of data share the data cache space 92.

[0117] The embodiment of the present invention affects the replacement weight of each storage block by maintaining the priority status of each storage block in the cache. In the case of data with multiple priority levels, the hit rate of the high priority level data cache can be improved, thereby realizing the cache requirements of data with different priority levels, with high flexibility, and thus the service quality and comprehensive capabilities of the network device can be improved. Furthermore, the embodiment can also maintain the storage status and access records of each storage block, so that when there is a free storage block, the free storage block is preferentially determined as the target storage block. When there is no free storage block in the data cache space, the storage block with a storage priority level not higher than the data to be cached is determined 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, the embodiment can further improve the service quality and comprehensive capabilities of the network device.

[0118] Fig.10 Schematic diagram of a network device according to an embodiment of the present invention. The network device according to this embodiment includes the above-mentioned network processor. Fig.10 As shown, the network device 10 of the embodiment of the present invention comprises at least one network processor 101, a memory 102 and a communication component 103. The communication component 103 receives and sends data under the control of the network processor 101. The data cache system in the network processor 101 is used to execute the above-mentioned data cache method. The memory 102 can be used as a main memory to store data. When the data access request received by the communication component 103 does not hit in the data cache space of the network processor 101, the required data is read from the memory 102 and cached as the data to be cached in the data cache space corresponding to the network processor 101 to achieve data access.

[0119] Furthermore, the network processor 101, the memory 102 and the communication component 103 may be connected via a bus or other means. Fig.10The example of 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, to implement the above-mentioned data caching method.

[0120] The memory 102 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store different types of data, etc. In addition, the memory 102 may include a high-speed random access memory, and may 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 may optionally include a memory remotely arranged relative to the network processor 101, and these remote memories may be connected to an external device via 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 combinations thereof.

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

[0122] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.

[0123] The embodiment of the present invention affects the replacement weight of each storage block by maintaining the priority status of each storage block in the cache. In the case of data with multiple priority levels, the hit rate of the high priority level data cache can be improved, thereby realizing the cache requirements of data with different priority levels, with high flexibility, and thus the service quality and comprehensive capabilities of the network device can be improved. Furthermore, the embodiment can also maintain the storage status and access records of each storage block, so that when there is a free storage block, the free storage block is preferentially determined as the target storage block. When there is no free storage block in the data cache space, the storage block with a storage priority level not higher than the data to be cached is determined 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, the embodiment can further improve the service quality and comprehensive capabilities of the network device.

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

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

[0126] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A data cache system, characterized in that: The data cache system comprises: A data cache space, wherein the data cache space includes a plurality of storage blocks, and the data cache system maintains a priority status of each of the storage blocks; The controller is used to determine a target storage block according to the priority level of the data to be cached and the priority status of each corresponding storage block, and store the data to be cached in the target storage block.

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

3. The system according to claim 1 or 2, characterized in that: The priority status of each storage block changes dynamically according to the priority of the cached data.

4. The system according to claim 1, characterized in that The data cache system includes at least one counter, and the counter is used to record the number of storage blocks corresponding to the priority level.

5. The system according to claim 1 or 4, characterized in that: 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, and to reduce 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.

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

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

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

9. A data caching method, applicable to a data caching system, characterized in that: The data cache system 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 of the storage blocks, and the method includes: Receiving a data cache request, wherein the data cache request has corresponding data to be cached; Determining a target storage block according to 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.

10. The method according to claim 9, characterized in that The data cache system maintains the storage status of each storage block, and determining the target storage block according to the priority level of the data to be cached and the priority status of each storage block includes: In response to the data cache space having a corresponding storage block in an idle state, determining the corresponding storage block in an idle state as a target storage block; In response to a storage block in the data cache space being in an occupied state and having a storage block of a predetermined priority level, determining a corresponding storage block at the predetermined priority level as a 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 the storage blocks in the data cache space being in an occupied state and no storage blocks of a predetermined priority level existing, a target data block is determined from the storage blocks according to a predetermined cache replacement algorithm.

11. The method according to claim 9, characterized in that The priority state of each storage block changes dynamically according to the priority of the cached data, and the method further includes: In response to the proportion of storage blocks of a corresponding priority level being lower than a first threshold, increasing the priority level of the corresponding storage block; In response to the proportion of storage blocks corresponding to the priority level being higher than a second threshold, the priority level of the corresponding storage block is lowered.

12. A data cache device, applicable to a data cache system, characterized in that: The data cache system 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 of the storage blocks, and the device includes: A request receiving unit, configured to receive a data cache request, wherein the data cache request has corresponding data to be cached; A determination unit, configured to determine a target storage block according to a priority level of the data to be cached and a priority state of each of the storage blocks; The storage unit is configured to store the data to be cached in the target storage block.

13. A network processor, characterized in that: The network processor comprises: Multiple processing cores; The data cache system according to any one of claims 1 to 8; Wherein, each of the processing cores shares the data cache space corresponding to the data cache system.

14. A network device, characterized in that: The network device is equipped with the network processor as claimed in claim 13.

Citation Information

Patent Citations

  • Cache management method and device

    CN113138851A

  • Chip service data caching method and device, computer equipment and storage medium

    CN117891401A

  • Implementing advanced caching

    US20150378914A1

  • Multi-level storage method and apparatus for blockchain data

    US20200034311A1

  • Method for storing and reading cached data and device

    US20240289055A1