Data caching method, device, equipment, storage medium and program product

The data caching method optimizes cache memory operations by dynamically updating prefetch numbers and sector values based on read requests, addressing the inefficiencies of manual configuration and improving adaptability and efficiency in cache memory modules.

CN118445221BActive Publication Date: 2024-12-24MOORE THREADS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410900714.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-12-24
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

Existing cache memory modules require users to dynamically configure preloading strategies, which is difficult to adjust accurately and timely, leading to increased workload and inefficiency in adapting to different read requests.

Method used

A data caching method that updates the prefetch number of storage groups based on data addresses and sector counts, determining a sector prefetch value to optimize data fetching from downstream modules, reducing redundancy and improving adaptability.

Benefits of technology

This method reduces user workload in configuring preloading strategies and enhances the flexibility and efficiency of data prefetching by dynamically adjusting to different read requests, minimizing redundancy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118445221B_ABST
    Figure CN118445221B_ABST
Patent Text Reader

Abstract

The present application provides a data caching method, device, equipment, storage medium and program product. The data caching method is applied to a cache module, and the cache module includes multiple storage groups. The method includes: obtaining a read request for the storage group, and the read request carries a data address and a number of sectors. The pre-fetch number of the storage group is updated based on the data address and the number of sectors. The sector pre-fetch value is determined based on the pre-fetch number and the number of sectors. Data is obtained from a downstream module based on the sector pre-fetch value. In the data caching method of the present application, the pre-fetch number of the storage group is updated based on the obtained read request, and the sector pre-fetch value for pre-fetching data from the downstream module is determined based on the updated pre-fetch number and the number of sectors, which improves the flexibility of the sector pre-fetch value and the adaptability to different read requests, and effectively improves the efficiency of data pre-fetching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data caching method, apparatus, device, storage medium and program product. Background Art

[0002] In chip design, a cache memory module is indispensable. The cache memory module includes multiple cache blocks. When a cache block receives at least two read requests, the cache memory module needs to obtain data from the downstream data source at least twice. In the related art, by adopting a preload strategy, that is, preloading the first read request received by each cache block to the entire cache block, the cache memory module obtains the data of the entire cache block from the downstream data source at one time.

[0003] However, the preloading strategy requires users to configure it dynamically, which increases the user's workload and is difficult to make dynamic adjustments accurately and timely.

[0004] Therefore, how to accurately and dynamically adjust the preloading strategy according to the read request has become an urgent problem to be solved. Summary of the invention

[0005] In view of this, embodiments of the present application at least provide a data caching method, apparatus, device, storage medium, and program product.

[0006] The technical solution of the embodiment of the present application is implemented as follows:

[0007] On the one hand, an embodiment of the present application provides a data caching method, which is applied to a cache module, the cache module includes multiple storage groups, and the method includes: obtaining a read request for a storage group; the read request carries a data address and a number of sectors; updating a prefetch number of the storage group based on the data address and the number of sectors; determining a sector prefetch value based on the prefetch number and the number of sectors; and obtaining data from a downstream module based on the sector prefetch value.

[0008] On the other hand, an embodiment of the present application provides a data cache device, which is applied to a cache module, wherein the cache module includes multiple storage groups, and the data cache device includes: a receiving unit, used to obtain a read request for the storage group; the read request carries a data address and a number of sectors; a first determination unit, used to update the prefetch number of the storage group based on the data address and the number of sectors; a second determination unit, used to determine a sector prefetch value based on the prefetch number and the number of sectors; and an acquisition unit, used to obtain data from a downstream module based on the sector prefetch value.

[0009] On the other hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, the steps in the aforementioned data caching method are implemented.

[0010] On the other hand, an embodiment of the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the aforementioned data caching method are implemented.

[0011] On the other hand, an embodiment of the present application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in the aforementioned data caching method.

[0012] In an embodiment of the present application, the prefetch number of the storage group is updated in real time based on the data address and the number of sectors of the obtained read request, and the sector prefetch value for prefetching data from the downstream module is determined based on the updated prefetch number and the number of sectors, thereby reducing the workload of the user in dynamically configuring the preloading strategy, solving the problem that the sector prefetch value cannot be adjusted dynamically and accurately according to the read request in a timely manner, improving the flexibility of the sector prefetch value and its adaptability to different read requests, effectively improving the efficiency of data prefetching, and reducing the redundancy rate of the prefetched data.

[0013] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 A schematic diagram of data transmission of a high-speed cache memory module in the related art;

[0015] Figure 2 for Figure 1 A partial schematic diagram of a high-speed cache memory module;

[0016] Figure 3 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 1 ;

[0017] Figure 4 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 2 ;

[0018] Figure 5 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 3 ;

[0019] Figure 6 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 4 ;

[0020] Figure 7 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 5 ;

[0021] Figure 8 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 6 ;

[0022] Fig. 9 A flowchart of the data caching method provided in the embodiment of the present application;

[0023] Fig.10 A schematic diagram of the structure of a data cache device provided in an embodiment of the present application;

[0024] Fig.11 A hardware entity diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0026] It should be understood that the "embodiments of the present application" or "the aforementioned embodiments" mentioned throughout the specification mean that specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present application. Therefore, "in the embodiments of the present application" or "in the aforementioned embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. In the various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.

[0027] Figure 1 FIG. 1 is a schematic diagram of data transmission of a high-speed cache storage module in the related art. Figure 1 As shown, the cache memory module 1 can communicate with an upstream module 2 and a downstream module 3 , wherein the upstream module 2 refers to a module for obtaining data from the cache memory module 1 , and the downstream module 3 refers to a module for providing data to the cache memory module 1 .

[0028] The cache memory module 1 receives the read request from the upstream module 2, and provides corresponding data to the upstream module 2 according to the read request. When the corresponding data of the read request is not stored in the cache memory module 1, the cache memory module 1 sends a pre-read request to the downstream module 3 according to the read request to obtain the corresponding data of the read request, and then provides it to the upstream module 2.

[0029] Figure 2 for Figure 1 Partial schematic diagram of the high-speed cache memory module. Figure 2 As shown, the cache memory module 1 includes a plurality of cache blocks 1a, each of which includes at least one sector. Figure 2 The cache block 1a shown in FIG. 1 includes 4 sectors. In some implementation scenarios, the data length of each cache block 1a is 128 bytes. When each cache block 1a includes 4 sectors 11a, the data length of each sector is 32 bytes. The read request received by the cache memory module 1 includes information representing the access address, access length, and stride length. The cache memory module 1 accesses the data of the corresponding sector and provides it to the upstream module 2 accordingly.

[0030] The read request can be set to be issued according to a request mode containing different access length and step information. Figure 2 The data transmission of multiple cache blocks 1a corresponding to the request mode 1 corresponds to the data transmission of multiple read requests issued according to the continuous address access with a step size of 128 bytes and an access length of 32 bytes. Among them, the first read request transmits the 32-byte data of the sector 11a corresponding to the access address to the upstream module 2, and the second read request transmits the data of the sector 11a of the next cache block 1a with a 128-byte interval from the access address to the upstream module 2, and so on to upload the data of the subsequent multiple cache blocks 1a.

[0031] like Figure 2 The data transmission of multiple cache blocks 1a corresponding to the request mode 2 corresponds to the data transmission of multiple read requests issued according to the continuous address access with a step size of 64 bytes and an access length of 32 bytes. Among them, the first read request transmits the 32-byte data of the sector 11a corresponding to the access address to the upstream module 2, and the second read request transmits the data of the sector 11a with a 64-byte interval from the access address to the upstream module 2, and so on to upload the data of the subsequent multiple cache blocks 1a.

[0032] like Figure 2The data transmission of multiple cache blocks 1a corresponding to the request mode 3 corresponds to the data transmission of multiple read requests issued according to the continuous address access with a step size of 32 bytes and an access length of 32 bytes. Among them, the first read request transmits the 32-byte data of the sector 11a corresponding to the access address to the upstream module 2, and the second read request transmits the data of the sector 11a with a 32-byte interval from the access address to the upstream module 2, and so on to upload the data of the subsequent multiple cache blocks 1a.

[0033] It should be noted that, when the corresponding data of the read request is not stored in the cache block 1a, the cache storage module 1 sends a pre-read request to the downstream module 3. The data length contained in the pre-read request is the access length. Furthermore, when the step size = 32 bytes or 64 bytes, and the access length is 32 bytes, 2 or 4 pre-read requests need to be sent to the downstream module 3 within one cache block 1a, which greatly increases the workload of the cache storage module 1.

[0034] Based on this, some cache memory modules 1 adopt a sector promotion strategy, which means that when the cache block 1a receives the first read request and the corresponding data of the read request is not stored in the cache block 1a, the read request is preloaded to the entire cache block 1a, so that the data length of the pre-read request sent by the cache memory module 1 to the downstream is the data length of the entire cache block 1a, that is, 128 bytes, instead of the access length of 32 bytes. In this way, only one pre-read request needs to be sent to the downstream module 3 in a cache block 1a, and when the cache block 1a receives a read request again, it will be cache hit, reducing the workload of the cache memory module 1.

[0035] However, the sector preloading strategy requires users to dynamically configure or modify software instructions, which increases the user's workload and is difficult to accurately and timely adjust dynamically according to regular expressions. At the same time, the same sector preloading strategy cannot adapt well to read requests with different step sizes. Therefore, how to accurately and dynamically adjust the preloading strategy according to the step size of the read request has become an urgent problem to be solved.

[0036] In view of the above problems, the present application embodiment proposes a data caching method. Figure 3 A schematic diagram of an implementation process of a computing unit control method provided in an embodiment of the present application Figure 1 The data caching method is applied to a cache module, and the cache module includes multiple storage groups, such as Figure 3 As shown, the data caching method at least includes the following steps:

[0037] Step S301: Obtain a read request for a storage group; the read request carries a data address and a sector number.

[0038] Here, the cache module may be, but is not limited to, any one of the following: a cache memory, a memory, or other memory for storing data.

[0039] The cache module includes multiple storage groups, each of which receives a read request based on a data address, that is, when the data address in the read request is determined, the storage group to be accessed is also determined. Each storage group can receive read requests with different data addresses under a fixed mapping.

[0040] In some embodiments, the data address includes a group index, and each storage group of the cache module includes an index. When the cache module receives a read request, the group index in the data address is compared with the index of each storage group. The storage group corresponding to the index that is successfully compared with the group index is the storage group requested by the read request.

[0041] In some embodiments, the read request may be sent from an upstream module to the cache module. The upstream module may be, but is not limited to, any one of the following: a graphics processing unit (GPU), a central processing unit (CPU), or other processors or memories that read data from the cache module.

[0042] The data address is the access address, which represents the storage group to be accessed. The number of sectors represents the data length of the accessed data.

[0043] In some embodiments, the read request may be generated by the upstream module according to the step length and the access length. In other words, the data addresses of two adjacent read requests received differ by a step length. The number of sectors in the read request is the quotient of the access length and the sector data length. Step S302: Update the pre-fetch number of the storage group based on the data address and the number of sectors.

[0044] Here, the storage group includes multiple cache blocks, and each cache block can receive a read request carrying a corresponding data address. Exemplarily, a storage group includes a first cache block and a second cache block, and the data addresses of the read request include: 0x1000, 0x1040, 0x2000, and 0x2040. Then, a read request carrying a data address of 0x1000 or 0x2000 can access the data of the first cache block, and a read request carrying a data address of 0x1040 or 0x2040 can access the data of the second cache block; accordingly, the first cache block can receive a read request with a data address of 0x1000 and 0x2000, and the second cache block can receive a read request with a data address of 0x1040 and 0x2040.

[0045] In some embodiments, the pre-fetch number is obtained based on the data address and the number of sectors in at least one read request received by the storage group. It is understandable that the pre-fetch number can be updated in units of storage groups. In other words, the pre-fetch number of each storage group is updated separately, independently of each other, and does not affect each other.

[0046] In some embodiments, the pre-fetch number can be determined by: determining an average value of the number of sectors of at least two read requests for the same cache block based on at least two read requests, and rounding the average value as the pre-fetch number of the storage group where the cache block is located.

[0047] Exemplarily, the cache blocks corresponding to data addresses 0x1000 and 0x2000 are both the first cache blocks, and two read requests carrying data addresses 0x1000 and 0x2000 are extracted. The number of sectors contained in the two read requests is 3 and 3 respectively, so the average value of 3 and 3 is used as the pre-fetch number.

[0048] In other embodiments, the pre-fetch number can also be determined in the following manner: based on the data address, at least three read requests for the same cache block are extracted, and the number of sectors that appear most frequently in the at least three read requests is determined, and the number of sectors is used as the pre-fetch number of the storage group where the cache block is located.

[0049] Exemplarily, the cache blocks corresponding to data addresses 0x1000, 0x2000, and 0x3000 are all the first cache blocks. Three read requests carrying data addresses 0x1000, 0x2000, and 0x3000 are extracted. The number of sectors contained in the three read requests is 1, 3, and 3, respectively. It can be seen that 1 appears 1 times and 3 appears 2 times, so 3 is used as the pre-fetch number of the storage group where the cache block is located.

[0050] In an embodiment of the present application, based on the read requests for the same cache block, the average value of the number of sectors of at least two read requests or the number of sectors that appear most frequently in at least three read requests is used as the pre-fetch number. This has small workload, is simple to calculate, and can effectively improve the problem of pre-fetch data redundancy caused by the inability to flexibly change the preloading strategy.

[0051] Step S303: Determine a sector prefetch value based on the prefetch number and the sector number.

[0052] The cache module pre-fetches data of the sector pre-fetch value sectors according to the sector pre-fetch value, and the sector pre-fetch value is used to represent the number of sectors requested by the upstream module for each cache block of the storage group.

[0053] In some embodiments, the median of the pre-fetch number and the sector number may be determined, and the median may be rounded to an integer and used as the sector pre-fetch value.

[0054] In other embodiments, when the prefetch number is greater than the number of sectors, the prefetch number is used as the sector prefetch value; when the prefetch number is less than or equal to the number of sectors, the sector number is used as the sector prefetch value.

[0055] In some other embodiments, the average value of the pre-fetch number and the sector number may be rounded to an integer to be used as the sector pre-fetch value, and this application does not impose any specific restrictions on this. It is understandable that the rounding here may be rounding by carrying or rounding by truncation.

[0056] In an embodiment of the present application, on the basis of considering the number of sectors, the sector prefetch value is determined according to the prefetch number and the number of sectors, so that the determined sector prefetch value is more reasonable and the degree of error in the sector prefetch value caused by the error in the prefetch number is reduced.

[0057] Step S304: Obtain data from a downstream module according to the sector pre-fetch value.

[0058] In some embodiments, the cache module generates a pre-read request based on the sector pre-fetch value and the sector address, where the sector address is determined based on the data address carried by the missed read request. The cache module transmits the pre-fetch request to the downstream module to obtain data of the sector pre-fetch value sectors and stores the data according to the sector address.

[0059] In some embodiments, the sector address corresponding to the data address carried by the missed read request is used as the sector address of the pre-read request. The missed read request may be: no data is stored in the sector corresponding to the data address of the read request, or may be: in the case where there is no cache block corresponding to the data address of the read request, a new cache block is created at the data address, and no data is stored in the sector of the newly created cache block.

[0060] Exemplarily, if a read request misses, the sector address corresponding to its data address is 0x2000, and the sector prefetch value is 3, then the sector address of the prefetch request is 0x2000. Accordingly, the cache module transmits a prefetch request to prefetch data of 3 sectors from the downstream module and store them in the 3 sectors starting at 0x2000.

[0061] In an embodiment of the present application, data is pre-fetched from a downstream module based on a sector pre-fetch value, thereby reducing the problem of a large number of read times caused by directly obtaining data based on the number of sectors, and at the same time reducing the problem of pre-fetched data redundancy caused by the inability to flexibly change the preloading strategy, thereby improving the efficiency of data acquisition and the utilization rate of acquired data.

[0062] In an embodiment of the present application, the prefetch number of the storage group is updated in real time based on the data address and the number of sectors of the received read request. In the case of a read request miss, the sector prefetch value for prefetching data from the downstream module is determined based on the updated prefetch number and the number of sectors, thereby reducing the workload of the user in dynamically configuring the preloading strategy, solving the problem that the sector prefetch value cannot be adjusted dynamically and accurately according to the read request in a timely manner, improving the flexibility of the sector prefetch value and its adaptability to different read requests, effectively improving the efficiency of data prefetching, and reducing the redundancy of prefetched data.

[0063] Figure 4 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 2 ,based on Figure 3 , the storage group includes a plurality of cache blocks, Figure 3 Step S302 in the embodiment at least comprises the following steps:

[0064] Step S401: Based on the data address, a block flag of the cache block corresponding to the data address is set, where the block flag indicates whether the cache block is a requested cache block.

[0065] Here, there is a mapping relationship between the data address and the cache block, and one data address corresponds to one cache block.

[0066] In some embodiments, the data address of the read request includes a block identifier, and each cache block of the storage group includes an identifier. When the storage group receives the read request, the block identifier in the data address is compared with the identifier of each cache block of the storage group. When the block identifier is successfully compared with the identifier, the block mark of the cache block corresponding to the identifier is set.

[0067] Exemplarily, the block identifier of the data address is 0x1020, and the identifiers of the multiple cache blocks of the storage group are respectively: 0x1000, 0x1020, and 0x1040. Then, the cache module compares the block identifier 0x1020 with the identifiers of the multiple cache blocks in sequence, and when the identifier 0x1020 is matched, the comparison is successful, and the block mark of the cache block corresponding to the identifier 0x1020 is set.

[0068] It is understandable that after the block mark of the cache block corresponding to the data address is set, the block mark remains unchanged when the cache block does not receive a read request. It should be noted that the block mark also remains unchanged when the cache block receives a write request and an atomic operation request. When the cache module is formatted or restored to factory settings, the block mark of the cache module will be restored to the initial state, such as the default value or null value, and the block mark of the cache block will be set when the cache block receives a read request next time.

[0069] In some embodiments, the length of the block tag is one bit, the default value of the block tag is a first value, and when the cache block receives a read request, the block tag of the cache block is set to a second value.

[0070] In other embodiments, the block mark of the cache module is set to a null value by default. When the cache block receives a read request, the block mark of the cache block is set to a non-null value. This application does not impose any specific restrictions on the specific content of the block mark.

[0071] Exemplarily, the block mark of the cache module is set to empty by default, and when the cache block receives a read request, the block mark of the cache block is set to 11.

[0072] The requested cache block refers to a cache block for which a read request has been received. It should be noted that in the data cache method, there is no specific limit on the number of times step S401 is executed. When a read request is received, step S401 is executed accordingly.

[0073] Exemplarily, if the first cache block receives a read request, the first cache block is a requested cache block.

[0074] In some embodiments, the block mark is set to a first value by default. The block mark being the first value indicates that the cache block corresponding to the block mark has not been requested by the upstream module. The above-mentioned setting of the block mark of the cache block corresponding to the data address based on the data address can be achieved through steps S4011 and S4012.

[0075] Step S4011: Based on the address and data address of each cache block, determine the cache block corresponding to the data address.

[0076] Here, the above solution of determining the cache block corresponding to the data address may be implemented with reference to the specific implementation of determining the cache block corresponding to the data address in the aforementioned step S401.

[0077] Step S4012: Set the block mark of the cache block corresponding to the data address to a second value.

[0078] Here, the block tag being the second value indicates that the cache block corresponding to the block tag has been requested by the upstream module. In this way, by updating the block tag of the cache block requested by the upstream module to the second value, the number of cache blocks in the storage group requested by the upstream module can be obtained by obtaining the number of block tags in the storage group whose block tags are the second value.

[0079] Exemplarily, the block mark length may be 1 bit, the first value is 0, and the second value is 1. When the cache block receives a read request, the block mark of the cache block is updated from 0 to 1.

[0080] As another example, the block tag length is 2 bits, the first value is 00, and the second value is 11. When the cache block receives a read request, the block tag of the cache block is updated from 00 to 11.

[0081] It is understandable that the contents of the first value and the second value can be set differently according to specific actual conditions, and this application does not impose any specific limitations.

[0082] Step S402: Based on the data address and the number of sectors, determine the read mark of the cache block corresponding to the data address, where the read mark represents the requested data range in the cache block.

[0083] In some embodiments, the data range of the read request is determined based on the data address and the number of sectors. Wherein, a cache block includes multiple sectors, the data address is compared with each sector address, and the starting position of the data range of the read request is determined according to the comparison result. Based on the starting position, the data range of the read request is determined based on the number of sectors. Secondly, when a cache block receives multiple read requests, the accumulated data range of the multiple read requests determines the read mark of the cache block.

[0084] The requested data range refers to a data range in which a read request for a sector within the data range has been received.

[0085] It should be noted that, when a cache block receives a read request and the read request does not hit, the cache block is replaced and the read mark of the cache block is reset, that is, the requested data range is accumulated again.

[0086] Exemplarily, a cache block includes 4 sectors, and the sector addresses of the 4 sectors are 0x1000, 0x1020, 0x1040 and 0x1060. The data address of the first read request is 0x1000, and the number of sectors is 2; the data address of the second read request is 0x1040, and the number of sectors is 2. When the first read request for the cache block is received, the data address 0x1000 is compared with the sector address 0x1000, and the comparison result is a match. Then, according to the match result, the starting position of the data range of the first read request is determined to be the sector corresponding to the sector address 0x1000. On the basis of the determination of the starting position, the data range is determined according to the number of sectors 2 as: two sectors corresponding to the sector address 0x1000 and the sector address 0x1020. The read mark represents the two sectors corresponding to the sector address 0x1000 and the sector address 0x1020.

[0087] Next, when receiving the second read request for the cache block, the data address 0x1040 is compared with the sector addresses 0x1000, 0x1020 and 0x1040 in turn. The comparison result between the data address 0x1040 and the sector address 0x1040 is a match. According to the match result, the starting position of the data range of the second read request is determined to be the sector corresponding to the sector address 0x1040. On the basis of the determination of the starting position, according to the number of sectors 2, the data range of the second read request is determined to be: the two sectors corresponding to the sector address 0x1040 and the sector address 0x1060. Further, the read mark represents the four sectors corresponding to the sector addresses 0x1000, 0x1020, 0x1040 and 0x1060.

[0088] In some embodiments, each sector of the cache block corresponds to a read tag, and when a read request is received, the read tag of the sector corresponding to the read request is determined to be content indicating that the sector has been requested.

[0089] In some embodiments, the read mark of the cache block includes a mark bit corresponding to each sector in the cache block, and each mark bit is set to a third value by default. The mark bit is the third value, which indicates that the sector corresponding to the mark bit has not been requested by the upstream module. Accordingly, the above-mentioned determination of the read mark of the cache block corresponding to the data address based on the data address and the number of sectors can be implemented through steps S4021 and S4022.

[0090] Step S4021: Based on the data address and the number of sectors, determine the number of sectors to be read in the cache block corresponding to the data address.

[0091] Here, the above-mentioned scheme for determining the number of sectors to be read corresponds to the scheme for determining the data range of the read request recorded in step S402. When implementing it, reference may be made to the specific implementation method of determining the data range of the read request in the aforementioned step S402.

[0092] Step S4022: Set the flag bits corresponding to the sectors to be read to the fourth value.

[0093] Here, the mark bit is the fourth value, indicating that the sector corresponding to the mark bit has been requested by the upstream module. In this way, by updating the mark bit of the sector requested by the upstream module to the fourth value, the number of sectors in the cache block requested by the upstream module can be obtained according to whether the mark bit in the cache block read tag is the fourth value. It should be noted that, in the case where no read request is received, the mark bit set to the fourth value remains unchanged. In the case where the cache block receives a read request and the read request does not hit, the cache block is replaced, and all the mark bits of the cache block are reset, that is, all the mark bits are updated to the third value.

[0094] Exemplarily, the third value is 0, and the fourth value is 1. A cache block includes a first sector, a second sector, a third sector, and a fourth sector, and the read tag length is 4 bits, each bit is a tag bit and corresponds to a sector. In the case where the data range of the first read request received is the first sector, the read tag is 1000. On this basis, the data range of the second read request received is the third sector, and the read tag is 1010. In the case where the cache block receives a read request and the read request does not hit, the cache block is replaced, and the read tag of the cache block is reset to 0000.

[0095] Step S403: determining the pre-fetch number based on the block tag and the read tag of each cache block of the storage group.

[0096] In some embodiments, within a storage group, the number of block tags characterizing that a cache block has been requested is determined; a read tag corresponding to the block tag characterizing that a cache block has been requested is determined; the total number of sectors requested for each cache block with the largest number of occurrences is determined based on the read tag, and the total number of sectors requested is determined as the pre-fetch number.

[0097] Exemplarily, a storage group includes a first cache block, a second cache block, a third cache block, and a fourth cache block, wherein the block tags of the first cache block, the second cache block, and the third cache block indicate that the cache block has been requested. Then, the read tags of the first cache block, the second cache block, and the third cache block are determined; according to the read tags, the total number of sectors requested by the first cache block, the second cache block, and the third cache block is obtained as 2, 2, and 1 respectively. It can be seen that 2 appears twice and 1 appears once, so 2 is used as the pre-fetch number.

[0098] In an embodiment of the present application, a block mark and a read mark are set for each cache block of each storage group. When a read request is received, the block mark is updated in time to obtain the request of the upstream module to the cache block, and the read mark is updated in time to obtain the request of the upstream module to the sector, and then the data request of the upstream module to the storage group is obtained. The pre-fetch number is obtained according to the data request situation, and the pre-fetch number is used to predict the subsequent request of the upstream module to the sector. Further, data is pre-fetched from the downstream module and stored according to the pre-fetch number and the number of sectors to improve the hit rate of subsequent read requests. At the same time, since the pre-fetch number is adjusted and flexibly changed according to the obtained request situation, the pre-fetch data redundancy problem caused by the inability to adjust the pre-fetch number in time, accurately and dynamically is solved, and the utilization rate of the pre-fetched data is improved.

[0099] Figure 5 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 3 ,based on Figure 4 , the storage group includes a plurality of cache blocks, Figure 4 Step S403 in the embodiment at least comprises the following steps:

[0100] Step S501: Determine the number of block marks in a storage group indicating that a cache block is a requested cache block.

[0101] Here, the block tag of the cache block that has not been requested is different from the block tag of the cache block that has been requested. The number of tags indicates: the total number of cache blocks that have been requested in a storage group.

[0102] Exemplarily, a storage group includes a first cache block, a second cache block, a third cache block, and a fourth cache block, a block mark of 1 indicates that it has been requested, and a block mark of 0 indicates that it has not been requested. The block marks of the first cache block and the second cache block are 1, and the block marks of the third cache block and the fourth cache block are 0, then the number of marks of the storage group is 1+1+0+0=2.

[0103] As another example, a storage group includes a first cache block, a second cache block, a third cache block, and a fourth cache block. A non-null value for a block mark indicates that it has been requested, and a null value for a block mark indicates that it has not been requested. The block marks of the first cache block and the second cache block are non-null values, and the block marks of the third cache block and the fourth cache block are null values. Then, the number of marks of the storage group is the number of non-null values ​​for the block marks, that is, 2.

[0104] Step S502: based on the read mark of each cache block of the storage group, determine the read count of each cache block, and count the sum of the read counts corresponding to the storage group, where the read count represents the number of requested sectors in the cache block.

[0105] Here, the number of reads represents the number of sectors requested by the upstream module for a cache block. In some embodiments, the number of reads is: the number of mark bits with the fourth value in the read tag of a cache block. Exemplarily, the third value is 0, the fourth value is 1, and the read tag is 1010, then the number of reads is: the number of mark bits in the read tag that are 1, that is, 2. In other embodiments, the number of reads may also be: the number of sectors spanned by two mark bits with the fourth value at both ends in the read tag of a cache block. Exemplarily, the third value is 0, the fourth value is 1, and the read tag is 1010, then the number of reads is the number of sectors spanned by the left "1" and the right "1", that is, 3.

[0106] The sum of the read counts refers to the sum of all read counts in the storage group, which represents the total number of sectors requested by the upstream module for the storage group. It is understandable that when the block tag indicates that the cache block is not a requested cache block, the read count of the cache block is 0.

[0107] In some embodiments, the above-mentioned read mark of each cache block based on the storage group can be implemented through steps S5021 to S5023 to determine the read number of each cache block.

[0108] Step S5021: Determine the requested data range based on the read mark of each cache block.

[0109] Step S5022: Determine the first sector and the second sector at both ends of the requested data range.

[0110] Step S5023: Determine the number of the first sector, the second sector, and the number of sectors spanned by the first sector and the second sector as the read number.

[0111] The technical solution for determining the requested data range may be implemented by referring to the technical solution for determining the read mark of the cache block corresponding to the data address in step S402.

[0112] Correspondingly, the data range requested by the cache block includes at least one sector. Then, the sector with the smallest sector address in the requested data range is taken as the first sector; the sector with the largest sector address in the requested data range is taken as the second sector; the sector corresponding to the sector address between the minimum sector address and the maximum sector address is the sector spanned by the first sector and the second sector.

[0113] Exemplarily, the third value is 0, the fourth value is 1, and if the read mark is 1010, then the requested data range is from the sector corresponding to the left "1" to the sector corresponding to the right "1", and accordingly, the sector corresponding to the left "1" is the first sector, the sector corresponding to the right "1" is the second sector, and the sector spanned by the first sector and the second sector is the sector corresponding to the left "0", then the number of the first sector, the second sector, and the sector corresponding to the left "0", that is, 3, is used as the number of reads. If the read mark is 1001, the number of reads is the number of sectors corresponding to the left "1", the sector corresponding to the right "1", and the number of two sectors corresponding to the double "0", that is, 4.

[0114] During implementation, the number of reads may be determined as: the number of mark bits with the fourth value at both ends and the number of mark bits crossed by the mark bits with the fourth value at both ends.

[0115] Step S503: determine the pre-fetch number according to the sum of the number of marks and the number of reads.

[0116] In some embodiments, when the total number of reads remains unchanged, the larger the number of tags, the smaller the number of pre-fetches; when the number of tags remains unchanged, the larger the total number of reads, the larger the number of pre-fetches. In other words, the number of pre-fetches is positively correlated with the number of tags, and the number of pre-fetches is negatively correlated with the total number of reads.

[0117] In some embodiments, the above-mentioned determination of the pre-fetch number according to the sum of the number of marks and the number of reads can be implemented by step S5031. Step S5031, determine the quotient of the sum of the number of marks and the number of reads, and round the obtained quotient to obtain the pre-fetch number.

[0118] Here, the rounding can be rounding by truncation or rounding by carry. For example, when the quotient is 2.5, the pre-fetch number can be determined as 2 by truncation or 3 by carry. The present application does not impose any specific restrictions on this. In other words, the pre-fetch number = ⌈ the sum of the read numbers ÷ the number of marks ⌉; or, the pre-fetch number = ⌊ the sum of the read numbers ÷ the number of marks ⌋.

[0119] In some embodiments, the above-mentioned determination of the pre-fetch number based on the sum of the number of tags and the number of reads can also be implemented through steps S5032 to S5034.

[0120] Step S5032: determining a remaining mark according to the valid mark and the read mark of the cache block, wherein the remaining mark indicates a sector in the cache block that has data stored and has not been requested, and the valid mark indicates a sector in the cache block that has data stored.

[0121] The valid mark indicates the sector corresponding to the data acquired from the downstream module and stored in the cache block according to the sector pre-fetch value.

[0122] The remaining mark indicates the sectors corresponding to the data acquired from the downstream module and stored in the cache block according to the sector pre-fetch value and not falling within the data range of the read request received after pre-fetching, that is, redundant sectors.

[0123] Exemplarily, the third value is 0 and the fourth value is 1. In the valid mark, 1 indicates that the corresponding sector has data, and 0 indicates that the corresponding sector has no data. If the read mark is 1010 and the valid mark is 1111, the remaining mark is 0101. In other embodiments, the remaining mark can also be: the number of sectors crossed by the 1s at both ends of the valid mark - the number of sectors crossed by the 1s at both ends of the read mark, that is, 4-3=1.

[0124] Step S5033: Determine a read tag of the cache block according to the data address of the read request and the number of sectors, and determine the total number of reads based on the read tag.

[0125] Here, the above-mentioned solution for determining the read mark of the cache block can be implemented with reference to the implementation of the solution for determining the read mark of the cache block corresponding to the data address in the aforementioned step S402. Here, the above-mentioned solution for determining the sum of the read numbers can be implemented with reference to the implementation of the solution for counting the sum of the read numbers corresponding to the storage group in the aforementioned step S502.

[0126] In other embodiments of the present application, step S5032 may be executed before the cache block is replaced by a read request; and step S5033 may be executed when the cache block is replaced. Replacing means that when a read request is received and the cache block determined based on the read request has been accessed, the data of the cache block is cleared. Accordingly, after the cache block is replaced, the read flag of the cache block is reset. In this way, the number of sectors requested by the upstream module for the storage group including the cache block before replacement can be obtained, and then the sector request situation of the cache block before replacement is taken into consideration to determine the pre-fetch number, which is conducive to improving the accuracy of the determined pre-fetch number.

[0127] Step S5034: determine the pre-fetch number according to the remaining tags, the sum of the read numbers and the number of tags.

[0128] In some embodiments, if the remaining mark is determined in step S5032, and the remaining mark includes multiple mark bits, the remaining number of the remaining marks is first calculated, and the calculation of the remaining number is similar to the calculation of the read number. For example, when the remaining mark is "0101", the corresponding remaining number is 3. The difference between the sum of the read numbers and the remaining number is determined, and the difference is divided by the number of marks. The quotient is rounded to an integer and used as the pre-fetch number.

[0129] In other embodiments, such as the implementation method of determining the remaining marks in step S5032, the remaining marks are constant values. For example, the valid marks in the previous text are 1. The difference between the sum of the read numbers and the remaining marks is determined, and the difference is divided by the number of marks. The quotient is rounded and used as the pre-fetch number.

[0130] It should be noted that rounding can be done by truncation or rounding. For example, when the quotient is 2.5, the pre-fetch number can be determined as 2 by truncation or rounding. The present application does not impose any specific restrictions on this.

[0131] In the embodiment of the present application, by setting a remaining mark in the storage group, the remaining mark is used to determine the redundant sectors pre-fetched from the downstream module but not requested by the read request. Further, based on the consideration of the redundant sectors, the request of the upstream module to the storage group, that is, the pre-fetch number, is predicted, thereby improving the accuracy of the determined pre-fetch number, further reducing the redundancy problem of pre-fetched data caused by the inability to adjust the pre-fetch number in a timely and accurate manner, and improving the utilization rate of the pre-fetched data.

[0132] In an embodiment of the present application, the number of tags is determined according to the block tag of each cache block, and the number of tags represents the number of requests of the upstream module for the cache block of the storage group; the number of reads is determined according to the read tags, and then the sum of the number of reads is determined, and the sum of the number of reads represents the number of requests of the upstream module for the sectors of the storage group. Further, the pre-fetch number is obtained according to the number of requests for the cache block and the number of requests for the sector, and data is pre-fetched and stored from the downstream module according to the pre-fetch number and the number of sectors to improve the hit rate of subsequent read requests. At the same time, because the pre-fetch number is adjusted and flexibly changed according to the block tag and the read tag in a timely manner, the problem of pre-fetched data redundancy caused by the inability to adjust the pre-fetch number in a timely, accurate and dynamic manner is solved, and the utilization rate of the pre-fetched data is improved.

[0133] Figure 6 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 4 ,based on Figure 5 , Figure 5 Step S5034 in the embodiment includes at least the following steps:

[0134] Step S601: Determine the difference between the sum of the read numbers and the remaining marks, the difference representing the number of sectors read by the received read request target after excluding sectors storing data and not requested.

[0135] Here, to determine the difference between the sum of the read counts and the remaining marks, please refer to the relevant records in the previous text.

[0136] Step S602: determine the target number, which is the larger of the difference value and the number of marks, and is used to correct the number of sectors requested.

[0137] Here, the difference is used to exclude redundant sectors to correct the determined number of requested sectors. The target number is the larger of the difference and the marked number, in order to avoid the situation where the difference is less than the marked number, resulting in over-correction.

[0138] It can be understood that when the difference is equal to the number of markers, the target number can be either the difference or the number of markers.

[0139] Step S603: determine the quotient of the target number and the marked number, and round the quotient to obtain the pre-fetch number.

[0140] Here, rounding can be rounding by truncation or rounding by carry. For example, when the quotient is 2.5, the pre-fetch number can be determined as 2 by truncation or rounding by carry. The present application does not impose any specific restrictions on this.

[0141] In other words, the pre-fetch number = ⌈ target number ÷ marked number ⌉; or, the pre-fetch number = ⌊ target number ÷ marked number ⌋.

[0142] Figure 7 A schematic diagram of an implementation process of a computing unit control method provided in an embodiment of the present application Figure 5 ,based on Figure 3 , Figure 3 Step S302 in the embodiment at least comprises the following steps:

[0143] Step S701: Determine the data storage range of the data obtained from the downstream module according to the pre-fetch number.

[0144] Here, in the case where the read request misses, the starting sector of the data storage range is determined according to the data address of the read request, and based on the determination of the starting sector, the data storage range is determined according to the pre-fetch number.

[0145] Exemplarily, the data address is 0x1000, the sector addresses of the cache blocks corresponding to the data address are 0x1000, 0x1020, 0x1040 and 0x1060 respectively, and the pre-fetch number is 3. At this time, according to the data address 0x1000, the sector corresponding to the sector address 0x1000 is determined as the starting sector, and according to the pre-fetch number of 3, the data storage range is determined as: the sectors corresponding to the sector address 0x1000, the sector address 0x1020 and the sector address 0x1040.

[0146] Step S702: When the data storage range is larger than the boundary range of the cache block, the pre-fetch number is determined as the corresponding boundary range.

[0147] Here, the data storage range being larger than the boundary range of the cache block means that part of the data storage range falls outside the cache block. Accordingly, the data storage range is adjusted to fall entirely within the cache block. At this time, the number of sectors included in the data storage range is the pre-fetch number.

[0148] Exemplarily, the data address is 0x1000, and the sector addresses of the cache blocks corresponding to the data addresses are 0x1000, 0x1020, 0x1040, and 0x1060, respectively, and the number of pre-fetches is 3. At this time, the sector corresponding to the sector address 0x1040 is determined as the starting sector according to the data address 0x1040, and the data storage range is determined to be: the sectors corresponding to the sector address 0x1040, the sector address 0x1060, and the sector address 0x1080 according to the pre-fetch number of 3. It can be seen that the sector corresponding to the sector address 0x1080 falls outside the cache block. Then the data storage range is adjusted to: the sectors corresponding to the sector address 0x1040 and the sector address 0x1060, and the number of pre-fetches is 2.

[0149] In an embodiment of the present application, the data storage range for obtaining data from a downstream module is determined based on the prefetch number. When the data storage range is larger than the boundary range of the cache block, the prefetch number is determined as the corresponding boundary range, thereby reducing the problem of redundant prefetched data caused by a large prefetch number and a large amount of prefetched data, further improving the accuracy of the determined prefetch number and improving the utilization rate of the prefetched data.

[0150] In the embodiment of the present application, the read request is generated by the upstream module according to the request mode; under different request modes, the data address and / or number of sectors carried by the read request are different. In this way, when a read request carrying different numbers of sectors and / or data addresses is received, different pre-fetch numbers can be obtained based on different numbers of sectors and / or data addresses, and then the pre-fetch number can be dynamically adjusted, so that the utilization rate of the data pre-fetched according to the pre-fetch number is greatly increased, and the redundancy rate of the pre-fetched data is greatly reduced.

[0151] Exemplarily, in one request mode, the data addresses carried by two adjacent read requests are separated by one sector, and the number of sectors is 1; in another request mode, the data addresses carried by two adjacent read requests are separated by two sectors, and the number of sectors is 1.

[0152] In some embodiments, a read request is generated by an upstream module according to a request mode. Under the same request mode and when all cache blocks of a storage group have been requested, a fixed prefetch strategy is obtained. When a sector of a storage group receives a read request, a fixed number of prefetches corresponds to the fixed prefetch strategy.

[0153] Here, the request mode includes information about the number of sectors and the step length, that is, the data addresses of two read requests successively received by the cache module are separated by a step length.

[0154] The fact that all cache blocks of the storage group have been requested means that target data of all cache blocks of the storage group have been read.

[0155] In some embodiments, the fixed prefetch strategy in the same request mode includes: for read requests of different sectors of the cache block, there is a prefetch number corresponding to the sector. It is understandable that in the same storage group, multiple read requests for sectors at the same position of different cache blocks have the same prefetch number.

[0156] Exemplarily, a storage group includes a first cache block, a second cache block, a third cache block and a fourth cache block, wherein the first cache block includes a first sector, a second sector, a third sector and a fourth sector arranged by address; and the second cache block includes a first sector, a second sector, a third sector and a fourth sector arranged by address. The request mode includes information that the number of sectors is 1 and the step length is two sectors. In this request mode, when the first sector and the third sector of each cache block have been requested, all cache blocks of the storage group have been requested. Further, when a data request for the first sector of the first cache block is received, there is a fixed first pre-fetch number. When a data request for the third sector of the first cache block is received, there is a fixed second pre-fetch number. Correspondingly, when a data request for the first sector of the second cache block is received, the pre-fetch number is the first pre-fetch number. When a data request for the third sector of the second cache block is received, the pre-fetch number is the second pre-fetch number.

[0157] In an embodiment of the present application, a read request is generated by an upstream module according to a request mode. When all cache blocks of a storage group have been requested, the request status of the upstream module for the entire storage group can be obtained, thereby obtaining a fixed prefetch strategy. Then, under the same request mode, when a read request is received again, data can be prefetched according to the number of prefetches included in the fixed prefetch strategy, thereby improving the efficiency of prefetching data. At the same time, the fixed prefetch strategy is dynamically adjusted according to different request modes, so that the utilization rate of the data prefetched according to the fixed prefetch strategy is greatly increased, and the redundancy rate of the prefetched data is greatly reduced.

[0158] Figure 8 A schematic diagram of an implementation process of a data caching method provided in an embodiment of the present application Figure 6 ,based on Figure 3 , the method further comprises the following steps:

[0159] Step S801: Store the acquired data into at least one sector of the cache block according to the data address.

[0160] Here, storing according to the data address means: storing according to the sector address determined by the data address, wherein the sector address is the starting sector address of storing the data, and the data is stored starting from the starting sector address.

[0161] Step S802: in response to the acquired data being stored, updating the valid flag, the valid flag indicating the sector in the cache block where the data is stored; the valid flag is also used to determine whether the read request is hit when a read request is received.

[0162] Here, updating the valid flag refers to determining the valid flag according to the data storage status of the cache block after step S41.

[0163] It is understandable that in other situations where the data storage situation of the cache block is changed, the valid flag will also be updated accordingly.

[0164] In some embodiments, the valid flag includes a valid bit corresponding to each sector, the valid bit being the fifth value indicates that the corresponding sector stores data, and the valid bit being the sixth value indicates that the corresponding sector does not store data. Accordingly, when a read request is received, the valid bit corresponding to the valid flag is queried according to the sector address corresponding to the data address, and when the valid bit is the fifth value, the read request is hit; when the valid bit is the sixth value, the read request is not hit.

[0165] In an embodiment of the present application, a valid mark is set for each cache block to identify the data storage status of the sector of the cache block, and the valid mark is updated in time when the data storage status changes, thereby avoiding the problem of executing read request errors due to the failure to update the valid mark or the untimely update, which is beneficial to improving the efficiency of executing read requests.

[0166] The following describes the application of the data caching method provided in an embodiment of the present application in an actual scenario, mainly involving the execution process of the cache module receiving read requests multiple times.

[0167] like Fig. 9 , which is a workflow diagram of the data caching method provided in the embodiment of the present application. In the data caching method provided in the embodiment of the present application, the data caching method may include the following steps:

[0168] Step S901: determine whether a storage set receives a read request.

[0169] Here, a read request refers to a request to read data. A storage group includes multiple cache lines, and each cache line includes at least one sector.

[0170] If the storage group has not received any read request, step S902 is executed; if the storage group has received any read request, step S903 is executed.

[0171] Step S902, keep the block read bit (cacheline_touch_bit, corresponding to the block mark in the above embodiment) and sector read bit (sector_touch_bit, corresponding to the read mark in the above embodiment) of the cache block in the read request unchanged, and update its block valid bit (cacheline_valid_bit) and sector valid bit (sector_valid_bit, corresponding to the valid mark in the above embodiment), and end.

[0172] Here, the block valid bit is used to indicate whether the cache block contains data.

[0173] Step S903: Determine whether to evict the cache block of the storage group.

[0174] If the cache block of the storage group is not replaced, step S904 is executed; if the cache block of the storage group is replaced, step S907 is executed.

[0175] Step S904: determine that the block read bit of the cache block is 1 based on the read request, and determine the sector read bit.

[0176] Here, each cache block is provided with a block read bit, and the word length is 1 bit. The read request includes information representing the data address, and then determines that the block read bit of the cache block corresponding to the data address is 1.

[0177] Wherein, each cache block is provided with a sector read bit, and the word length of the sector read bit is equal to the number of sectors contained in each cache block. For example, if the cache block contains 4 sectors, the word length of the sector read bit is 4 bits. Further, the sector read bit is determined according to the data address in the read request. For example, a cache block contains four sectors, the first address of each sector is 0x1000, 0x1020, 0x1040 and 0x1060, and the data address of the read request is 0x1020, then the sector read bit of the cache block is determined to be 0100 according to the data address.

[0178] Step S905, calculating the sum of the block read bits (set_cacheline_touch_cnt, corresponding to the number of marks in the above embodiment) and the sum of the lengths of the sector read bits (set_sector_touch_cnt, corresponding to the sum of the number of reads in the above embodiment) of the storage group where the cache block is located.

[0179] When a storage group receives a read request, the block read bits in the storage group are summed to obtain the total block read bit sum, which represents the total number of requested cache blocks in the storage group. At the same time, the lengths of the sector read bits in the storage group are summed to obtain the total length of the sector read bits.

[0180] The length of the sector read bit (corresponding to the number of reads in the above embodiment) refers to the number of sectors spanned by the leftmost "1" and the rightmost "1" in the sector read bit. For example, when the sector read bit is 1010, the length of the sector read bit is 3; when the sector read bit is 1001, the length of the sector read bit is 4.

[0181] Step S906 , the sum of the lengths of the sector read bits is divided by the sum of the block read bits, and the obtained quotient is rounded to an integer and used as a prediction value (corresponding to the pre-fetch number in the above embodiment).

[0182] That is, the predicted value = the sum of the lengths of the sector read bits / the sum of the block read bits.

[0183] Exemplarily, the sector read bit of the first cache block of a storage group is 1010, and the block read bit is 1; the sector read bit of the second cache block is 1110, and the block read bit is 1; the sector read bit of the third cache block is 1110, and the block read bit is 0, then the sum of the lengths of the sector read bits is 3+3=6, and the sum of the block read bits is 1+1+0=2, then the predicted value = 6÷2=3, after rounding, the predicted value is 3.

[0184] Step S907: determine that the block read bit of the cache block is 1 based on the read request, and determine the sector read bit; when the sector valid bit length is greater than the sector read bit length, determine the valid but not read bit (set_valid_but_not_touch_cn, corresponding to the remaining mark in the above embodiment) of the cache block as the difference between the sector valid bit length and the sector read bit length.

[0185] Here, the above-mentioned scheme of determining the block read bit of the cache block to be 1 and determining the sector read bit can correspond to the aforementioned steps S401 and S402. When implementing, reference can be made to the specific implementation method of determining the block mark in the aforementioned step S401 and the specific implementation method of determining the read mark in step S402.

[0186] Among them, the valid but not read bit represents a sector in the cache block that is a valid sector but not a requested sector. For example, the sector valid bit of a cache block is 0111, and the sector read is 0110, which means that the number of valid sectors is 3 and the number of read sectors is 2. In this case, the length of the sector valid bit is 3, and the length of the sector read bit is 2. Further, the valid but not read bit is 3-2=1. It can be seen that the value of the valid but not read bit is the valid sector, not the number of read sectors.

[0187] Step S908: Calculate the sum of the sector read bit lengths and the sum of the block read bits of the storage group where the cache block is located.

[0188] Here, the above-mentioned scheme for determining the sum of the sector read bit lengths and the sum of the block read bits can correspond to the aforementioned steps S501 and S502. When implementing, reference can be made to the specific implementation method of determining the number of marks in the aforementioned step S501 and the specific implementation method of determining the sum of the number of reads in step S502.

[0189] Step S909, determine the difference between the sum of the sector read bit lengths and the valid but non-read bits, and take the larger of the sum and the difference of the block read bits, determine the quotient of the larger value and the sum of the block read bits, and round the quotient as the prediction value.

[0190] Here, predicted value = max {sum of length of sector read bits - sum of valid but non-read bits, sum of block read bits} / sum of block read bits.

[0191] Step S910: determine whether the read request is a cache miss.

[0192] Here, after executing step S906 or step S909, step S910 is executed.

[0193] Step S911, the cache module sends a pre-read (linefill read) request to the downstream module to obtain data; wherein the pre-read request includes the pre-read number (linefill sector number) to be read, and the pre-read number is the larger of the predicted value and the number of sectors. When the predicted value is greater than the number of sectors, the sector validity bit of the cache block is determined and the process ends.

[0194] Here, the cache module includes a plurality of cache blocks. The cache module sends a pre-read request to the data module according to the received read request and the pre-read number to obtain data and store the data in the corresponding cache block.

[0195] For example, if the prediction value of a storage group is 3, the number of sectors in the read request is 2, and the corresponding sector read bit is 1100, then the number of pre-reads included in the pre-read request is 3. At the same time, since the prediction value is greater than the number of sectors, the sector valid bit of the cache block corresponding to the read request is updated to 1110.

[0196] In some embodiments, the upstream module sends a read request to the cache module according to different patterns (corresponding to the request patterns in the above embodiments). In some embodiments, issuing a read request according to a regular expression for continuous address access with a step size of 128 bytes and an access length of 32 bytes is recorded as issuing a read request according to pattern1; issuing a read request according to a regular expression for continuous address access with a step size of 64 bytes and an access length of 32 bytes is recorded as issuing a read request according to pattern2; issuing a read request according to a regular expression for continuous address access with a step size of 32 bytes and an access length of 32 bytes is recorded as issuing a read request according to pattern3.

[0197] For example, the first addresses of four consecutive cache blocks of a storage group are 0x1000, 0x1080, 0x1100, and 0x1180, respectively, and the cache size of each cache block is 128 bytes. Then, the first read request issued according to pattern1 contains a data address of 0x1000 and a sector number of 1; the second read request contains a data address of 0x1080 and a sector number of 1, and so on. Similarly, the first read request issued according to pattern2 contains a data address of 0x1000 and a sector number of 1; the second read request contains a data address of 0x1040 and a sector number of 1; the third read request contains a data address of 0x1080 and a sector number of 1, and so on. Similarly, the first read request issued according to pattern 3 includes a data address of 0x1000 and a sector number of 1; the second read request includes a data address of 0x1020 and a sector number of 1; the third read request includes a data address of 0x1040 and a sector number of 1, and so on.

[0198] Next, the data caching method of the present application will be illustrated. Assume that a storage group includes four cache blocks, which are respectively recorded as the first cache block, the second cache block, the third cache block and the fourth cache block; a cache block includes 4 sectors, which are respectively recorded as the first sector, the second sector, the third sector and the fourth sector, and the granularity of each sector is 32 bytes, then the cache block cache size is 128 bytes. The sum of the read tags / the number of block tags is rounded to the integer of the obtained quotient as the predicted value (which can be understood as the pre-fetch number in the previous text). The read request from the upstream module to the cache storage module is issued according to pattern1→pattern2→pattern3, and all start reading from the first cache block of the same storage group in sequence, and the duration of each pattern is indefinite.

[0199] The addresses of the first few read requests corresponding to each pattern are as follows:

[0200] pattern1: 0x10000, 0x10080, 0x10100, 0x10180.

[0201] Pattern2: 0x20000, 0x20040, 0x20080, 0x200c0, 0x20100, 0x20140, 0x20180, 0x201c0.

[0202] Pattern3: 0x30000, 0x30020, 0x30040, 0x30060, 0x30080, 0x30a0, 0x30c0, 0x30e0, 0x30100, 0x30120, 0x30140, 0x30160, 0x30180, 0x31a0, 0x31c0, 0x31e0.

[0203] It should be noted that the read request is issued according to pattern1→pattern2→pattern3 for example only. In actual reading application scenarios, the read request can also be issued according to pattern3→pattern2→pattern1, or randomly converted according to pattern 1, pattern 2 and pattern 3.

[0204] In the stage where the read request is issued according to pattern 1: when the first read request with data address 0x10000 and sector number 1 is received, the block mark of the cache block corresponding to 0x10000 is 1 (which can be understood as the first value in the previous text), and the read mark is 1000. At this time, the sum of the block marks is 1, and the sum of the read marks is also 1; when the second read request with data address 0x10080 and sector number 1 is received, the block mark of the cache block corresponding to 0x10080 is 1, and the read mark is 1000. At this time, the sum of the block marks is 2, and the sum of the read marks is also 2, and so on. It can be seen that after each read request is received, the block mark and the read mark change synchronously, and the sum of the block marks and the sum of the read marks remain equal, so the predicted value remains 1. When multiple read requests covering all cache blocks are received, that is, when pattern 1 is stable, the sum of the block marks and the sum of the read marks remain equal to the number of cache blocks in the storage group, and the predicted value is stable at 1.

[0205] In the stage where the read request is issued according to pattern 2: when the first read request with a data address of 0x20000 and a sector number of 1 is received, 0x20000 corresponds to the first cache block. Since the data of the first cache block has been read in the stage where pattern 1 is issued, the original first cache block is replaced and a new first cache block is created. The data address 0x20000 corresponds to the first cache block, and the block mark of the first cache block is 1; the data address is 0x20000 and the sector number is 1, which corresponds to the first sector, and the read mark is determined to be 1000. At this time, after the stage where pattern 1 is issued, the block marks of the second cache block, the third cache block, and the fourth cache block are all 1, and the read marks are all 1000. Therefore, the sum of the block marks of the storage group is the sum of the block marks of the four cache blocks, that is, 4, and the sum of the read marks of the storage group is the sum of the read numbers of the four cache blocks, that is, 4. The predicted value is the quotient of the sum of the read numbers and the sum of the block marks, that is, 1;

[0206] When receiving the second read request with data address 0x20040 and sector number 1, 0x20040 also corresponds to the first cache block, and the block mark of the first cache block is still 1; data address 0x20040 and sector number 1 correspond to the third sector, and combined with the first read request corresponding to the first sector, the read mark is updated to 1010, where the left "1" of the read mark corresponds to the first sector, and the right "1" corresponds to the third sector. At this time, similar to the above, the sum of the block marks of the storage group is 4; the number of reads of the first cache block is 3, and after the pattern1 issuance stage, the read marks of the second cache block, the third cache block and the fourth cache block are all 1000, so the read numbers are all 1, then the sum of the read marks of the storage group is the read number 3 of the first cache block + the read number 1 of the second cache block + the read number 1 of the third cache block + the read number 1 of the fourth cache block, which is 6, then, the prediction value is the quotient of the sum of the read marks and the sum of the block marks rounded up, which is 2. The cache module reads data from the downstream module according to the prediction value 2 and stores it in the two sectors starting from 0x20040, namely the third sector and the fourth sector. At this time, the valid mark of the cache block is updated to 1011, wherein the rightmost 1 of the valid mark corresponds to the fourth sector, and the data of the fourth sector is multi-prefetched, which is beneficial to improving the cache hit rate of receiving subsequent read requests.

[0207] Similarly, when the third read request with data address 0x20080 and sector number 1 is received, the cache block corresponding to 0x20080 is replaced, and its block mark is 1, and the read mark is 1000. At this time, the sum of the block marks is 4, the sum of the read marks is 6, and the prediction value is 2. The cache module reads data from the downstream module according to the prediction value 2 and stores it in the two sectors starting from 0x20080. At this time, the valid mark of the cache block is updated to 1100.

[0208] When the fourth read request with data address 0x200c0 and sector number 1 is received, 0x200c0 and 0x20080 correspond to the same cache block, the block tag of the cache block is still 1, and the read tag is updated to 1010. At this time, the sum of the block tags is 4, and the sum of the read tags is 8. 8÷4 is rounded up to 2, so the predicted value is 2.

[0209] When the fifth read request with data address 0x20100 and sector number 1 is received, the cache block corresponding to 0x20100 is replaced, and its block mark is 1, and the read mark is 1000. At this time, the sum of the block marks is 4, the sum of the read marks is 8, and the prediction value is 2. The cache module reads data from the downstream module according to the prediction value 2 and stores it in the two sectors starting from 0x20100. At this time, the valid mark of the cache block is updated to 1100.

[0210] When the sixth read request with data address 0x20140 and sector number 1 is received, 0x20140 and 0x20100 correspond to the same cache block, and its block mark is 1, and the read mark is updated to 1010. At this time, the sum of the block marks is 4, and the sum of the read marks is 10. 10÷4 is rounded up to get 3. However, since the data address 0x20140+32*3 exceeds the boundary address of the cache block corresponding to 0x20140, the prediction value is adjusted to within the boundary of the corresponding cache block, that is, the prediction value is 2. When the cache module reads data from the downstream module according to the prediction value 2 and stores it in the two sectors starting from 0x20140, the valid mark of the cache block is updated to 1111.

[0211] When the seventh read request with data address 0x20180 and sector number 1 is received, the cache block corresponding to 0x20180 is replaced, and its block mark is 1, and the read mark is 1000. At this time, the sum of the block marks is 4, the sum of the read marks is 10, and the prediction value is 3. The cache module reads data from the downstream module according to the prediction value 3 and stores it in the three sectors starting from 0x20180. At this time, the valid mark of the cache block is updated to 1110.

[0212] When the eighth read request with data address 0x201c0 and sector number 1 is received, 0x201c0 and 0x20180 correspond to the same cache block. At this time, the cache hits and the sector hits, and the read tag is updated to 1010.

[0213] From now on, the prediction value corresponding to the previous read request received by each cache block is 3, and the cache module obtains data from the downstream module according to the prediction value 3 and stores it in the three sectors headed by the data address of the read request. When the cache block receives the next read request, it will hit the sector. When multiple read requests covering all cache blocks are received, that is, when pattern 2 is stable, the sum of the block tags is stable at 4, and the sum of the read tags is stable at 4*3 or (4-1)*3+1, that is, 12 or 10.

[0214] In the stage where the read request is issued according to pattern 3: When the first read request with data address 0x30000 and sector number 1 is received, the cache block corresponding to 0x30000 is replaced, and its block mark is 1, and the read mark is 1000. At this time, the sum of the block marks is 4, the sum of the read marks is 10, and the prediction value is 3. The cache module reads data from the downstream module according to the prediction value 3 and stores it in the three sectors starting from 0x30000. At this time, the valid mark of the cache block is updated to 1110.

[0215] When the second and third read requests with data addresses of 0x30020 and 0x30040 and sector number of 1 are received respectively, the cache block hits and the sector hits, and the read tags are updated to 1100 and 1110 respectively.

[0216] When the fourth read request with data address 0x30060 and sector number 1 is received, the cache block hits but the sector misses, the block mark is 1, and the read mark is 1111. At this time, the sum of the block marks is 4, the sum of the read marks is 13, and the prediction value is 4. However, when the prediction value is 4, the data storage range determined according to the prediction value 4 exceeds the boundary of the cache block corresponding to 0x30060, and the prediction value is adjusted to within the boundary of the corresponding cache block, that is, the prediction value is 1. When the cache module reads data from the downstream module according to the prediction value 1 and stores it in a sector starting from 0x30060, the valid mark of the cache block is updated to 1111.

[0217] When the fifth read request with data address 0x30080 and sector number 1 is received, the cache block corresponding to 0x30080 is replaced, and its block mark is 1 and the read mark is 1000. At this time, the sum of the block marks is 4, and the sum of the read marks is 4 + 1 + 3 + 3 = 11, so the prediction value is 3. The cache module reads data from the downstream module according to the prediction value 3 and stores it in the three sectors starting from 0x30080. At this time, the valid mark of the cache block is updated to 1110.

[0218] When the sixth and seventh read requests with data addresses of 0x30a0 and 0x30c0 and sector number of 1 are received respectively, the cache block hits and the sector hits, and the read tags are updated to 1100 and 1110 respectively.

[0219] When the eighth read request with data address 0x300e0 and sector number 1 is received, the cache block hits but the sector misses, the block mark is 1, and the read mark is 1111, then the total block mark is 4, the total read mark is 15, and the prediction value is 4. However, when the prediction value is 4, the data storage range determined according to the prediction value 4 exceeds the boundary of the cache block corresponding to 0x300e0, and the prediction value is adjusted to within the boundary of the corresponding cache block, that is, the prediction value is 1. When the cache module reads data from the downstream module according to the prediction value 1 and stores it in a sector starting from 0x300e0, the valid mark of the cache block is updated to 1111.

[0220] When the ninth read request with data address 0x30100 and sector number 1 is received, the cache block corresponding to 0x30100 is replaced, and its block mark is 1 and the read mark is 1000. At this time, the sum of the block marks is 4, and the sum of the read marks is 4 + 4 + 1 + 3 = 12, so the prediction value is 3. The cache module reads data from the downstream module according to the prediction value 3 and stores it in the three sectors starting from 0x30100. At this time, the valid mark of the cache block is updated to 1110.

[0221] When the tenth and eleventh read requests with data addresses of 0x3120 and 0x3140 and sector number of 1 are received respectively, the cache block hits and the sector hits, and the read tags are updated to 1100 and 1110 respectively.

[0222] When the twelfth read request with data address 0x30160 and sector number 1 is received, the cache block hits but the sector misses, the block mark is 1, and the read mark is 1111, then the total block mark is 4, and the total read mark is 4 + 4 + 4 + 3 = 15, then the prediction value is 4, but when the prediction value is 4, the data storage range determined according to the prediction value 4 exceeds the boundary of the cache block corresponding to 0x30160, and the prediction value is adjusted to within the boundary of the corresponding cache block, that is, the prediction value is 1. When the cache module reads data from the downstream module according to the prediction value 1 and stores it in a sector starting from 0x30160, the valid mark of the cache block is updated to 1111.

[0223] When the thirteenth read request with data address 0x30180 and sector number 1 is received, the cache block corresponding to 0x30180 is replaced, and its block mark is 1 and the read mark is 1000. At this time, the sum of the block marks is 4, and the sum of the read marks is 4 + 4 + 4 + 1 = 13, so the prediction value is 4. The cache module reads data from the downstream module according to the prediction value 4 and stores it in the four sectors starting from 0x30180. At this time, the valid mark of the cache block is updated to 1111.

[0224] When the fourteenth, fifteenth and sixteenth read requests with data addresses of 0x31a0, 0x31c0 and 0x31e0 and sector number of 1 are received respectively, the cache block hits and the sector hits, and the read tags are updated to 1100, 1110 and 1111 respectively.

[0225] From now on, the first read request received by each cache block will determine the prediction value as 4, and the cache module will obtain data from the downstream module based on the prediction value 4. The second, third, and fourth read requests received by the cache block will hit. When multiple read requests are received to cover all cache blocks, that is, when pattern 3 is stable, the sum of the block tags is stable at 4, the sum of the read tags is stable at 13, 14, 15 and 16, and the prediction value is 4.

[0226] In other embodiments, if a storage group includes m cache blocks, each cache block includes n sectors, the sum of the read marks is stabilized at (m-1)*n+number of ways of the sector, and the sum of the block marks is the total number of ways m. Wherein, the n sectors are defined as the zeroth sector, the first sector, ..., and the n-1th sector in address order, then the number of ways of the zeroth sector is 1, the number of ways of the first sector is 2, ..., and the number of ways of the n-1th sector is n.

[0227] It can be seen from the example of the above data caching method that within a storage group, when switching between different patterns, after receiving multiple read requests covering all cache blocks, the prediction value will reach a stable value.

[0228] Based on the foregoing embodiments, an embodiment of the present application provides a data cache device, which includes the units included and the modules included in the units, and can be implemented by a processor in a computer device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0229] Fig.10 A schematic diagram of the structure of a data cache device provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, the data cache device 1000 includes: a receiving unit 1010, a first determining unit 1020, a second determining unit 1030, and an acquiring unit 1040, wherein:

[0230] The receiving unit 1010 is used to obtain a read request for a storage group; the read request carries a data address and a sector number;

[0231] A first determining unit 1020, configured to update the pre-fetch number of the storage group based on the data address and the number of sectors;

[0232] A second determining unit 1030, configured to determine a sector prefetch value based on the prefetch number and the sector number;

[0233] The acquisition unit 1040 is used to acquire data from a downstream module according to the sector pre-fetch value.

[0234] In some embodiments, the storage group includes multiple cache blocks, and the first determination unit 1020 is further used to: based on the data address, set a block mark of the cache block corresponding to the data address, the block mark indicates whether the cache block is a requested cache block; based on the data address and the number of sectors, determine a read mark of the cache block corresponding to the data address, the read mark indicates a requested data range in the cache block; determine the pre-fetch number based on the block mark and read mark of each cache block of the storage group.

[0235] In some embodiments, the block tag is set to a first value by default, and the first determination unit 1020 is further used to: determine the cache block corresponding to the data address based on the address and data address of each cache block; and set the block tag of the cache block corresponding to the data address to a second value.

[0236] In some embodiments, the read mark of the cache block includes a mark bit corresponding to each sector in the cache block, and each mark bit is set to a third value by default. The first determination unit 1020 is also used to: determine the number of sectors that need to be read in the cache block corresponding to the data address based on the data address and the number of sectors; set the mark bits corresponding to the number of sectors that need to be read to a fourth value.

[0237] In some embodiments, the first determination unit 1020 is further used to: determine the number of block tags in the storage group indicating that the cache block is a requested cache block; determine the number of reads of each cache block based on the read tag of each cache block in the storage group, and count the total number of reads corresponding to the storage group, the number of reads representing the number of requested sectors in the cache block; determine the pre-fetch number based on the sum of the number of tags and the number of reads.

[0238] In some embodiments, the first determination unit 1020 is further used to: determine the requested data range based on the read mark of each cache block; determine the first sector and the second sector at both ends of the requested data range; and determine the number of sectors spanned by the first sector, the second sector, and the first sector and the second sector as the number of reads.

[0239] In some embodiments, the first determination unit 1020 is further used to: determine the quotient of the sum of the number of tags and the number of reads, and round the obtained quotient to obtain the pre-fetched number.

[0240] In some embodiments, the first determination unit 1020 is further used to: determine the remaining mark based on the valid mark and the read mark of the cache block, wherein the remaining mark represents a sector in the cache block that has data and has not been requested, and the valid mark represents a sector in the cache block that has data; determine the read mark of the cache block based on the data address of the read request and the number of sectors, and determine the sum of the read numbers based on the read mark; determine the pre-fetch number based on the remaining mark, the sum of the read numbers and the number of marks.

[0241] In some embodiments, the first determination unit 1020 is further used to: determine the difference between the sum of the read numbers and the remaining marks, the difference representing the number of sectors read by the received read request target after excluding sectors that store data and have not been requested; determine the target number, the target number is the larger of the difference and the number of marks, and the target number is used to correct the number of sectors requested; determine the quotient of the target number and the number of marks, and round the quotient to obtain the pre-fetch number.

[0242] In some embodiments, the first determination unit 1020 is further used to: determine the data storage range of data obtained from the downstream module according to the pre-fetch number; when the data storage range is larger than the boundary range of the cache block, determine the pre-fetch number as the corresponding boundary range.

[0243] In some embodiments, the read request is generated by an upstream module according to a request mode; in different request modes, the data address and / or number of sectors carried in the read request are different.

[0244] In some embodiments, a read request is generated by an upstream module according to a request mode. Under the same request mode and when all cache blocks of a storage group have been requested, a fixed prefetch strategy is obtained. When a sector of a storage group receives a read request, a fixed number of prefetches corresponds to the fixed prefetch strategy.

[0245] In some embodiments, the acquisition unit 1040 is further configured to: store the acquired data into at least one sector of the cache block according to the data address.

[0246] The first determination unit 1020 is further used to: update a valid flag in response to the acquired data being stored; the valid flag is used to characterize the sector in the cache block where data is stored, and the valid flag is also used to determine whether the read request hits when a read request is received.

[0247] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0248] It should be noted that in the embodiments of the present application, if the above-mentioned data caching method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the data caching method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0249] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0250] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0251] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.

[0252] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented in hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.

[0253] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.

[0254] Fig.11 A hardware entity diagram of a computer device provided in an embodiment of the present application is shown in FIG. Fig.11 As shown, the hardware entity of the computer device 1100 includes: a processor 1101 and a memory 1102, wherein the memory 1102 stores a computer program that can be run on the processor 1101, and the processor 1101 implements the steps in the method of any of the above embodiments when executing the program.

[0255] The memory 1102 stores computer programs that can be run on the processor. The memory 1102 is configured to store instructions and applications executable by the processor 1101. It can also cache data to be processed or processed by the processor 1101 and various modules in the computer device 1100 (for example, image data, audio data, voice communication data, and video communication data). It can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0256] When the processor 1101 executes the program, the steps of any of the above data cache methods are implemented. The processor 1101 generally controls the overall operation of the computer device 1100.

[0257] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the data caching method of any of the above embodiments.

[0258] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0259] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application do not specifically limit this.

[0260] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc.

[0261] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.

[0262] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0263] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0264] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0265] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiments are executed; and the above storage medium includes: mobile storage devices, read-only memory (ROM), disks or optical disks, etc. Various media that can store program codes.

[0266] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the data caching method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0267] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A data caching method, characterized in that: Applied to a cache module, the cache module includes a plurality of storage groups, the method includes: Obtaining a read request for the storage group; the read request carries a data address and a sector number; updating the pre-fetch number of the storage group based on the data address and the number of sectors; Determining a sector prefetch value based on the prefetch number and the sector number; Data is obtained from a downstream module according to the sector pre-fetch value.

2. The data caching method according to claim 1, characterized in that: The storage group includes a plurality of cache blocks, and updating the pre-fetch number of the storage group based on the data address and the number of sectors includes: Based on the data address, setting a block mark of the cache block corresponding to the data address, the block mark indicating whether the cache block is the requested cache block; Based on the data address and the number of sectors, determining a read mark of the cache block corresponding to the data address, wherein the read mark represents a requested data range in the cache block; The pre-fetch number is determined based on the block tag of each cache block of the storage group and the read tag.

3. The data caching method according to claim 2, characterized in that: The block mark is set to a first value by default, and the step of setting the block mark of the cache block corresponding to the data address based on the data address includes: Based on the address of each cache block and the data address, determining the cache block corresponding to the data address; The block tag of the cache block corresponding to the data address is set to a second value.

4. The data caching method according to claim 2, characterized in that: The read mark of the cache block includes a mark bit corresponding to each sector in the cache block, and each mark bit is set to a third value by default; and determining the read mark of the cache block corresponding to the data address based on the data address and the number of sectors includes: Based on the data address and the number of sectors, determining the number of sectors to be read in the cache block corresponding to the data address; The mark bits corresponding to the number of sectors to be read are respectively set to a fourth value.

5. The data caching method according to claim 2, characterized in that: The determining the pre-fetch number based on the block tag of each cache block of the storage group and the read tag comprises: Determining the number of the block marks in the storage group indicating that a cache block is the requested cache block; Based on the read mark of each cache block of the storage group, determine the read count of each cache block, and count the sum of the read counts corresponding to the storage group, wherein the read count represents the number of sectors requested in the cache block; The pre-fetch number is determined according to the sum of the number of marks and the number of reads.

6. The data caching method according to claim 5, characterized in that: The determining the number of reads of each cache block based on the read mark of each cache block of the storage group includes: Determining a requested data range based on a read tag of each of the cache blocks; Determine a first sector and a second sector at both ends of the requested data range; The first sector, the second sector, and the number of sectors spanned by the first sector and the second sector are determined as the read number.

7. The data caching method according to claim 5, characterized in that: The step of determining the pre-fetch number according to the sum of the number of marks and the number of reads comprises: The quotient of the sum of the number of tags and the number of reads is determined, and the obtained quotient is rounded to obtain the pre-fetch number.

8. The data caching method according to claim 5, characterized in that: The step of determining the pre-fetch number according to the sum of the number of marks and the number of reads comprises: Determine a remaining mark according to the valid mark and the read mark of the cache block, wherein the remaining mark represents a sector in the cache block that has data stored and has not been requested, and the valid mark represents a sector in the cache block that has data stored; Determine a read tag of the cache block according to the data address and the number of sectors of the read request, and determine the sum of the read numbers based on the read tag; The pre-fetch number is determined according to the remaining tags, the sum of the read numbers and the number of tags.

9. The data caching method according to claim 8, characterized in that: The determining the pre-fetch number based on the remaining tags, the sum of the read numbers and the number of tags includes: Determine a difference between the sum of the read numbers and the remaining mark, the difference representing the number of sectors read by the received read request target after excluding sectors storing data and not requested; Determine a target number, the target number being the larger of the difference and the marked number, the target number being used to correct the number of sectors requested; The quotient of the target number and the marked number is determined, and the obtained quotient is rounded to obtain the pre-fetched number.

10. The data caching method according to any one of claims 2 to 9, characterized in that: The updating of the pre-fetch number of the storage group based on the data address and the number of sectors includes: Determine a data storage range for data acquired from a downstream module according to the pre-fetch number; In the case that the data storage range is larger than the boundary range of the cache block, the pre-fetch number is determined to correspond to the boundary range.

11. The data caching method according to any one of claims 1 to 9, characterized in that: The read request is generated by the upstream module according to the request mode; in different request modes, the data address and / or the number of sectors carried by the read request are different.

12. The data caching method according to any one of claims 2 to 9, characterized in that: After acquiring data from a downstream module according to the sector pre-fetch value, the method further includes: storing the acquired data in at least one sector of the cache block according to the data address; In response to the acquired data being stored, updating a valid flag; the valid flag is used to characterize a sector in the cache block where data is stored, and the valid flag is also used to determine whether the read request is a hit when the read request is received.

13. A data cache device, characterized in that: Applied to a cache module, the cache module includes a plurality of storage groups, and the data cache device includes: A receiving unit, configured to obtain a read request for the storage group; the read request carries a data address and a sector number; A first determining unit, configured to update the pre-fetch number of the storage group based on the data address and the number of sectors; A second determining unit, configured to determine a sector prefetch value based on the prefetch number and the sector number; The acquisition unit is used to acquire data from a downstream module according to the sector pre-fetch value.

14. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps of the data caching method according to any one of claims 1 to 12 are implemented.

15. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the data caching method according to any one of claims 1 to 12 are implemented.

16. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps in the data caching method according to any one of claims 1 to 12 are implemented.