Data prefetch method and device

By dividing the space level in the cache and determining the prefetch level based on historical data requests, the cache pollution problem is solved, the coverage and accuracy of data prefetching are improved, and the CPU execution performance is improved.

WO2025161779A1PCT designated stage Publication Date: 2025-08-07SMARTER SILICON (SHANGHAI) TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/142156
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-01-31
Filing Date
2024-12-25
Publication Date
2025-08-07

AI Technical Summary

Technical Problem

The existing prefetch mechanism is prone to caching pollution, causing CPU execution performance to decline, and the existing technology has failed to effectively solve the problems of cache space utilization efficiency and data prefetch accuracy.

Method used

By dividing different spatial levels in the cache and determining the prefetch level of the prefetch request based on the historical data request of the cache data user, the prefetch data is extracted into the spatial level matching it, avoiding useless data entering the cache and improving the coverage and accuracy of data prefetching.

Benefits of technology

It effectively avoids cache pollution, improves the accuracy of cache hit rate and data prefetching, and improves the execution performance of the CPU.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024142156_07082025_PF_FP_ABST
    Figure CN2024142156_07082025_PF_FP_ABST
Patent Text Reader

Abstract

The present application discloses a data prefetch method and device. The method comprises: obtaining a prefetch request, wherein the prefetch request is used for indicating prefetch data extracted from a memory to a cache, and the cache comprises a plurality of spaces with different spatial levels; on the basis of a historical data request of a cache data user, determining a prefetch level of the prefetch request, wherein the prefetch level is used for representing the usefulness of the prefetch data; and extracting the prefetch data corresponding to the prefetch request from the memory to a space whose spatial level matches the prefetch level of the prefetch request.
Need to check novelty before this filing date? Find Prior Art

Description

Data prefetching method and device

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on January 31, 2024, with application number 202410139398.0 and invention name “Data Prefetching Method and Device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of computer technology, and in particular to a data prefetching method and device. Background Art

[0003] Prefetching is a technique used by the CPU (Central Processing Unit) to fetch the data required for an instruction from memory into the cache before the instruction is actually executed. This allows the CPU to access this data immediately, thereby improving execution performance. Existing prefetching mechanisms are not well-designed and can easily cause cache contamination (for example, extra prefetched data takes up limited cache space, displacing useful data in the cache), resulting in reduced CPU performance. Summary of the Invention

[0004] This application provides a data pre-fetching method and device, including the following technical solutions:

[0005] A data prefetching method, comprising:

[0006] Obtaining a prefetch request; the prefetch request is used to instruct prefetch data to be extracted from the memory into the cache; the cache includes multiple spaces of different space levels;

[0007] Determining a prefetch level of the prefetch request based on historical data requests of a cache data user; the prefetch level is used to characterize the usefulness of the prefetched data;

[0008] The prefetch data corresponding to the prefetch request is extracted from the memory to a space whose spatial level matches the prefetch level of the prefetch request.

[0009] Optionally, extracting the prefetch data corresponding to the prefetch request from the memory to a space whose space level matches the prefetch level of the prefetch request includes:

[0010] determining a target space having a spatial rank matching the prefetch rank of the prefetch request;

[0011] Determining a response status of the target space based on the data request to which the target space responds;

[0012] If the response status of the target space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the target space.

[0013] Optionally, if the response status of the target space is busy, the prefetch data corresponding to the prefetch request is extracted from the memory to the first space; the first space includes a space level lower than the space level of the target space, and the response status is free; the usefulness of the data stored in the first space is lower than the usefulness of the data stored in the target space.

[0014] Optionally, if the response status of the target space is busy and the space level of the target space is the lowest level, the prefetch request is canceled.

[0015] Optionally, determining the prefetch level of the prefetch request based on historical data requests of the cache data user includes:

[0016] Determining the confidence level of the prefetch request based on historical data requests of the cached data user; the confidence level is used to characterize the probability that the prefetched data corresponding to the prefetch request is used by the cached data user;

[0017] Based on the confidence of the prefetch request, a prefetch level of the prefetch request is determined; wherein, the higher the confidence, the higher the prefetch level.

[0018] Optionally, determining the prefetch level of the prefetch request based on historical data requests of the cache data user includes:

[0019] determining an initial prefetch level for the prefetch request based on historical data requests of a cache data user;

[0020] determining, based on a preset matching relationship between the spatial level and the prefetch level, an initial space whose spatial level matches the initial prefetch level;

[0021] A prefetch level of the prefetch request is determined based on data characteristics of the initial space.

[0022] Optionally, the data feature includes a data utilization rate, and the data utilization rate is determined based on the number of data prefetches and the number of data hits in a historical time period. Determining a prefetch level of the prefetch request based on the data feature of the initial space includes:

[0023] Determining data utilization of the initial space;

[0024] If the data utilization rate of the initial space meets a threshold, a prefetch level of the prefetch request is determined based on the initial prefetch level.

[0025] Optionally, if the data utilization rate of the initial space is greater than the threshold, it is determined that the prefetch level of the prefetch request is higher than the initial prefetch level; wherein, if the initial prefetch level is the highest level of prefetch level, the prefetch level of the prefetch request is determined based on the initial prefetch level.

[0026] Optionally, if the data utilization rate of the initial space is less than the threshold, it is determined that the prefetch level of the prefetch request is lower than the initial prefetch level; wherein, if the initial prefetch level is the lowest level of prefetch level, the prefetch request is canceled.

[0027] A data pre-fetching device, comprising:

[0028] A request determining unit, configured to obtain a prefetch request; the prefetch request is configured to indicate prefetch data to be extracted from the memory into a cache; the cache includes a plurality of spaces of different space levels;

[0029] a level determination unit, configured to determine a prefetch level of the prefetch request based on historical data requests of a cache data user; the prefetch level being used to characterize the usefulness of the prefetched data;

[0030] A data extraction unit is configured to extract the prefetched data corresponding to the prefetch request from the memory to a space whose space level matches the prefetch level of the prefetch request.

[0031] Optionally, the data extraction unit is specifically configured to:

[0032] determining a target space having a spatial rank matching the prefetch rank of the prefetch request;

[0033] Determining a response status of the target space based on the data request to which the target space responds;

[0034] If the response status of the target space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the target space.

[0035] Optionally, the data extraction unit is specifically configured to:

[0036] If the response status of the target space is busy, the prefetch data corresponding to the prefetch request is extracted from the memory to the first space; the first space includes a space whose space level is lower than the space level of the target space and whose response status is free; the usefulness of the data stored in the first space is lower than the usefulness of the data stored in the target space.

[0037] Optionally, the data extraction unit is specifically configured to:

[0038] If the response status of the target space is busy and the space level of the target space is the lowest level, the prefetch request is canceled.

[0039] Optionally, the level determination unit is specifically configured to:

[0040] Determining the confidence level of the prefetch request based on historical data requests of the cached data user; the confidence level is used to characterize the probability that the prefetched data corresponding to the prefetch request is used by the cached data user;

[0041] Based on the confidence of the prefetch request, a prefetch level of the prefetch request is determined; wherein, the higher the confidence, the higher the prefetch level.

[0042] Optionally, the level determination unit is specifically configured to:

[0043] determining an initial prefetch level for the prefetch request based on historical data requests of a cache data user;

[0044] determining, based on a preset matching relationship between the spatial level and the prefetch level, an initial space whose spatial level matches the initial prefetch level;

[0045] A prefetch level of the prefetch request is determined based on data characteristics of the initial space.

[0046] Optionally, the data feature includes data utilization, and the data utilization is determined based on the number of data pre-fetches and the number of data hits in a historical time period. The level determination unit is specifically configured to:

[0047] Determining data utilization of the initial space;

[0048] If the data utilization rate of the initial space meets a threshold, a prefetch level of the prefetch request is determined based on the initial prefetch level.

[0049] Optionally, the level determination unit is specifically configured to:

[0050] If the data utilization rate of the initial space is greater than the threshold, it is determined that the prefetch level of the prefetch request is higher than the initial prefetch level; wherein, if the initial prefetch level is the highest level of prefetch level, the prefetch level of the prefetch request is determined based on the initial prefetch level.

[0051] Optionally, the level determination unit is specifically used to: if the data utilization rate of the initial space is less than the threshold, determine that the prefetch level of the prefetch request is lower than the initial prefetch level; wherein, if the initial prefetch level is the lowest level of prefetch level, cancel the prefetch request. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0053] FIG1 is a flow chart of a data prefetching method provided in an embodiment of the present application;

[0054] FIG2 is a schematic diagram of a flow chart of another data prefetching method provided in an embodiment of the present application;

[0055] FIG3 is a flow chart of another data prefetching method provided in an embodiment of the present application;

[0056] FIG4 is a flow chart of another data prefetching method provided in an embodiment of the present application;

[0057] FIG5 is a flow chart of another data prefetching method provided in an embodiment of the present application;

[0058] FIG6 is a flow chart of another data prefetching method provided in an embodiment of the present application;

[0059] FIG7 is a schematic diagram of a flow chart of another data prefetching method provided in an embodiment of the present application;

[0060] FIG8 is a schematic diagram of component relationships provided in an embodiment of the present application;

[0061] FIG9 is a schematic flow chart of another data prefetching method provided in an embodiment of the present application;

[0062] FIG10 is a schematic diagram of the architecture of a data pre-fetching device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0063] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0064] In this application, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. The terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or apparatus comprising the element.

[0065] Example 1

[0066] As shown in FIG1 , a flow chart of a data prefetching method provided in an embodiment of the present application is provided, which can be used in a chip of an electronic device and includes the following steps.

[0067] S101: Obtain a prefetch request.

[0068] The prefetch request is used to instruct to extract prefetched data from the memory into the cache, and the cache includes a plurality of spaces of different space levels.

[0069] In some examples, the CPU is preset with a prefetcher, which estimates the data required by the CPU in the future based on the data required by the CPU to currently execute instructions, and generates one or more prefetch requests based on the estimation results. Each prefetch request is used to indicate the prefetch data extracted from the memory to the cache, and the prefetch data corresponding to each prefetch request has an execution order. The execution order of each prefetch data represents the order in which each prefetch data is used by the CPU.

[0070] In some examples, multiple spaces in a cache have different spatial levels. The higher the spatial level, the closer the space is to the CPU's computing components. Accordingly, the CPU access speed of spaces with higher spatial levels is higher than the CPU access speed of spaces with lower spatial levels. Because spaces of different spatial levels have different CPU access speeds, the usefulness of data stored in spaces of different spatial levels (the so-called usefulness refers to the probability of being read by the CPU) can be distinguished. Data with higher usefulness can be allocated to spaces with higher spatial levels, while data with lower usefulness can be allocated to spaces with lower spatial levels.

[0071] In one possible implementation, the multiple cache spaces may include L2 (secondary cache) space, L3 (third level cache) space, and LLC (last level cache) space. The L2 space has a higher spatial hierarchy than the L3 space, and the L3 space has a higher spatial hierarchy than the LLC space. Furthermore, the allocation of the various cache spaces and the spatial hierarchy of each space can be configured based on the chip's hardware architecture.

[0072] S102: Determine a prefetch level of the prefetch request based on historical data requests of the cache data user.

[0073] The prefetch level is used to characterize the usefulness of prefetched data.

[0074] It should be noted that the cache data user may be a CPU, and the historical data request of the CPU specifically refers to data read within a historical time period of the CPU (ie, data required by the CPU to execute multiple instructions in the past).

[0075] In some examples, a CPU executes 100 instructions during a historical time period. The data required for each instruction is obtained based on the CPU's historical data requests. To this end, the historical data requests corresponding to the 100 instructions can be analyzed to determine the prefetch level of the expected request.

[0076] It can be understood that determining the prefetch level of an expected request is essentially determining the usefulness of the prefetched data corresponding to the prefetch request, that is, performing data analysis on the data historically requested by the CPU to determine the usefulness of the prefetched data, so as to determine the space to which the prefetched data belongs based on the usefulness of the prefetched data.

[0077] Optionally, for a specific implementation process of determining the prefetch level of a prefetch request based on historical data requests of a cache data user, reference may be made to the steps shown in FIG. 2 and the explanations of the steps.

[0078] S103: extracting the prefetch data corresponding to the prefetch request from the memory to a space whose space level matches the prefetch level of the prefetch request.

[0079] Among them, after determining the prefetch level of the prefetch request, the prefetch data is extracted from the memory to the space whose space level matches the prefetch level, and the usefulness of the prefetch data is referred to, so as to avoid extracting useless prefetch data into the cache and effectively avoid cache pollution.

[0080] It's important to note that when prefetching data into a cache, the pre-stored data in that cache may be interfered with by the pre-fetched data. For example, if data in a cache is currently being used by the CPU, pre-fetching data into that cache can interfere with the CPU's access to data in that cache, impacting CPU performance. Therefore, when pre-fetching data into a cache, the response state of that cache must be considered to avoid interfering with the CPU's access to data already in the cache.

[0081] In some examples, the response status can be used to represent the frequency of data accesses by the CPU to the space. The data access frequency can be determined based on the data requests responded to by the space within a specified time.

[0082] Optionally, for a specific implementation process of extracting the prefetch data corresponding to the prefetch request from the memory to a space whose spatial level matches the prefetch level of the prefetch request, please refer to the steps shown in Figure 5 and the explanation of the steps.

[0083] In some examples, the steps shown in this embodiment can be run in a preset dynamic adjuster, which is part of the chip and is used to receive prefetch requests sent by the prefetcher, and in response to the prefetch requests, extract the prefetch data corresponding to the prefetch requests from the memory to the space shown in the cache.

[0084] In one possible implementation, the relationship between the cache, dynamic adjuster, prefetcher, and processor is shown in Figure 8. In the relationship diagram shown in Figure 8, the prefetcher generates a prefetch request based on the processed data request and sends the prefetch request to the dynamic adjuster. The dynamic adjuster obtains the response status from each cache space and, based on the response status and the prefetch level of the prefetch request, determines the space where the prefetched data is stored. It then extracts the prefetched data from the memory into the cache. If the prefetch request does not meet the prefetch conditions, it cancels the prefetch request and sends a cancellation notification to the prefetcher.

[0085] In some examples, combined with the methods shown in subsequent Examples 2, 3, 4, and 5, the specific process of implementing data prefetching by the dynamic adjuster shown in Figure 8 can also be summarized as the steps shown in Figure 9: based on the confidence of the prefetch request, determining the initial prefetch level of the prefetch request (i.e., adjusting the target according to the prefetch confidence as shown in Figure 9, the so-called target can be understood as the initial prefetch level); determining the prefetch level of the prefetch request according to the data utilization of the initial space whose spatial level matches the initial prefetch level (i.e., adjusting according to the prefetch data utilization as shown in Figure 9); determining the final storage space of the prefetched data corresponding to the prefetch request based on the response status of the target space whose spatial level matches the prefetch level (i.e., adjusting according to the cache busyness as shown in Figure 9, the busyness is used to characterize the response status); for prefetch requests that do not meet the prefetch conditions, canceling the execution of the prefetch request (i.e., sending a cancellation prompt to the prefetcher as shown in Figure 9).

[0086] The process shown in the above S101-S103, by determining the prefetch level of the prefetch request and extracting the prefetch data corresponding to the prefetch request from the memory to the space whose spatial level matches the prefetch level, can prevent useless prefetch data from being extracted into the cache and avoid cache pollution. In addition, based on the matching of the prefetch level and the spatial level, the coverage of data prefetching can also be improved, and the accuracy and coverage of data prefetching can be balanced.

[0087] Example 2

[0088] As shown in FIG2 , a flow chart of another data prefetching method provided in an embodiment of the present application includes the following steps.

[0089] S201: Determine the confidence level of a pre-fetch request based on historical data requests of a cache data user.

[0090] The confidence level is used to characterize the probability that the prefetched data corresponding to the prefetch request is used by the cache data user. In one possible implementation, the confidence level can be used to characterize the probability that the prefetched data corresponding to the prefetch request is directly read by the CPU in the cache.

[0091] In some examples, based on the CPU's historical data requests, the memory address of the data historically used by the CPU can be obtained, and by performing data analysis on the memory addresses of each historically used data, at least one memory address data pattern and the confidence of each memory address data pattern can be obtained. Finally, based on the confidence of each memory address data pattern and the memory address data pattern that the memory address of the prefetched data corresponding to the prefetch request conforms to, the confidence of the prefetch request is determined.

[0092] The so-called memory address data rule can be used to characterize the mathematical association rule between the memory addresses of multiple historical usage data. For example, the memory addresses of multiple historical usage data are 0 bit, 1 bit, 2 bit...8 bit respectively. By performing data analysis on the memory addresses of multiple historical usage data, the first memory address data rule can be determined (that is, the memory address between the data between two adjacent sequence positions differs by 1 bit).

[0093] In one possible implementation, based on the 100 pieces of historical data indicated by the historical data request of the CPU, multiple memory address data patterns are determined, namely, a first memory address data pattern (indicating that the memory address difference between the data between two adjacent sequences is 1 bit), a second memory address data pattern (indicating that the memory address difference between the data between two adjacent sequences is 5 bits), and a third memory address data pattern (indicating that the memory address difference between the data between two adjacent sequences is 10 bits), wherein the confidence of the first memory address data pattern is 50% (representing that 50 pieces of historical data conform to the first memory address data pattern), the confidence of the second memory address data pattern is 30% (representing that 30 pieces of historical data conform to the second memory address data pattern), and the confidence of the third memory address data pattern is 20% (representing that 20 pieces of historical data conform to the third memory address data pattern). If the memory address of the prefetched data corresponding to the currently obtained prefetch request conforms to the first memory address data pattern, then the confidence of the prefetch request is determined to be 50%.

[0094] It should be noted that in the related art, in order to improve the efficiency of data prefetching, multiple prefetch requests are usually executed concurrently. For the execution scenario of multiple prefetch requests, when determining the confidence of multiple prefetch requests, the confidence of each prefetch request can also be adjusted based on the execution order corresponding to each prefetch request to provide a more reliable confidence for each prefetch request. Generally speaking, the earlier the execution order, the earlier the prefetch data corresponding to the prefetch request will be used by the CPU, and the later the execution order, the later the prefetch data corresponding to the prefetch request will be used by the CPU. For this reason, the confidence of the prefetch request with an earlier execution order is higher than that of the prefetch request with a later execution order.

[0095] In some instances, based on the execution order of multiple prefetch requests, weighted coefficients matching the confidence of the multiple prefetch requests can be determined, where the earlier the execution order, the larger the weighted coefficient, and the later the execution order, the smaller the weighted coefficient.

[0096] In one possible embodiment, multiple prefetch requests include request A, request B, and request C. The execution order corresponding to request A is first, the execution order corresponding to request B is second, and the execution order corresponding to request C is third. The initial confidence of request A (i.e., the confidence determined according to the memory address data rule) is 50%, the initial confidence of request B is 40%, and the initial confidence of request C is 10%. The execution order of the first is higher than the second, and the execution order of the second is higher than the third. Based on the respective execution orders of requests A, request B, and request C, the weighted coefficient matched by the confidence of request A is determined to be 0.5, the weighted coefficient matched by the confidence of request B is 0.3, and the weighted coefficient matched by the confidence of request C is 0.2. According to each weighting coefficient, the confidence levels of request A, request B, and request C are weighted and coupled, and the adjusted confidence level of request A is 50%×0.5=25%, the adjusted confidence level of request B is 40%×0.3=12%, and the adjusted confidence level of request C is 10%×0.2=2%.

[0097] S202: Determine a prefetch level of the prefetch request based on the confidence level of the prefetch request.

[0098] Among them, the higher the confidence, the higher the prefetch level.

[0099] In some examples, the prefetch level corresponding to the confidence level of the prefetch request may be determined based on a preset correspondence between the confidence level and the prefetch level.

[0100] It should be noted that the division of prefetch levels is consistent with the division of space levels of each space in the cache. In a possible implementation, if the space level is divided into N levels, then the prefetch level is also divided into N levels, where N is a positive integer.

[0101] In some examples, the division of prefetch levels can also be achieved by dynamically allocating registers. The implementation process of dynamic allocation can be: based on the number N of spaces in the cache, N registers are determined, and the preset thresholds of each register are different. The thresholds are used to distinguish the prefetch levels corresponding to the confidence levels, and each register is called to classify the confidence levels of the prefetch requests. Based on the registers to which the prefetch requests belong, the prefetch levels of the prefetch requests are determined.

[0102] In one possible implementation, the cache includes L2 space, L3 space, and LLC space. Correspondingly, the register includes a first register, a second register, and a third register. The first register corresponds to the L2 space, the second register corresponds to the L3 space, and the third register corresponds to the LLC space. If the confidence of the prefetch request belongs to the first register, the prefetch level of the prefetch request is determined to be level_L2. If the confidence of the prefetch request belongs to the second register, the prefetch level of the prefetch request is determined to be level_L3. If the confidence of the prefetch request belongs to the third register, the prefetch level of the prefetch request is determined to be level_LLC.

[0103] In a possible implementation, level_L2 is higher than level_L3, and level_L3 is higher than level_LLC.

[0104] It should be noted that after determining the prefetch level of the prefetch request based on the confidence of the prefetch request, the cache space where the prefetch data corresponding to the prefetch request is stored can be determined based on the prefetch level. However, the allocation of each space in the cache is determined in advance based on the hardware structure, and the data utilization probability of the space (that is, the probability of being accessed by the CPU) will change at any time. Therefore, the expected level of the prefetch request can be further determined based on the data utilization probability of the space, thereby further improving the coverage and accuracy of the prefetch.

[0105] In related technologies, the quality of prefetch mechanisms is generally evaluated from two dimensions: coverage and accuracy. Coverage refers to the ratio of prefetched data misses (misses, where a hit means the CPU directly obtains data from the cache) to all misses. For example, without a prefetch mechanism, 100 misses occur. After the prefetch mechanism is introduced, the number of misses is reduced to 30, which means that the prefetch mechanism successfully avoided 70 misses, with a coverage of 70 / 100 = 70%. Accuracy refers to the ratio of used prefetched data to all prefetch requests issued. For example, if the prefetch mechanism issues a total of 140 prefetch requests, and the prefetched data corresponding to 70 prefetch requests is used by the CPU, the accuracy is 70 / 140 = 50%.

[0106] Obviously, extracting the prefetched data from the memory to a space whose spatial level matches the prefetch level of the prefetch request can also realize the storage of the prefetched data. Compared with the existing technology of storing the prefetched data in each cache space based only on factors such as the cache space size (for example, the remaining storage space of the L2 space is higher than the remaining storage space of the L3 space, and directly extracting the prefetched data whose data usefulness matches the L3 space from the memory to the L2 space will cause cache pollution in the L2 space), the hit rate of each space in the cache can be improved.

[0107] In related technologies, hit rate is a key performance indicator of cache, and the hit rate is related to the accuracy of data prefetching. As the hit rate increases, the accuracy will also increase. Because the capacity of the cache is much smaller than the memory, the cache stores less data than the memory. The CPU naturally accesses the cache first and then accesses the memory. If the data is in the cache, it is considered a hit, and if the data is in the memory, it is considered a miss. Assuming that the CPU accesses 100 times and 99 times the data is accessed in the cache, the hit rate is 99%.

[0108] Optionally, for a specific implementation process of determining the prefetch level of a prefetch request based on historical data requests of a cache data user, reference may also be made to the steps shown in FIG. 3 and the explanations of the steps.

[0109] The process shown in the above S201-S202 can use the confidence of the prefetch request to determine the prefetch level of the prefetch request, and realize the confidence grading of the prefetch request, so that the prefetch level refers to the data usage habits of the cached data user and can represent the probability of the prefetched data being used by the cached data user.

[0110] Example 3

[0111] As shown in FIG3 , a flow chart of another data prefetching method provided in an embodiment of the present application is provided, which includes the following steps.

[0112] S301: Determine an initial prefetch level of a prefetch request based on historical data requests of a cache data user.

[0113] The initial prefetch level of the prefetch request is determined based on the historical data requests of the cache data user, and the initial prefetch level is not the final prefetch level of the prefetch request.

[0114] S302: Based on a preset matching relationship between the spatial level and the prefetch level, determine an initial space whose spatial level matches the initial prefetch level.

[0115] Among them, the initial space is the space initially allocated for the prefetched data corresponding to the prefetch request. The usefulness of the pre-stored data in the initial space is similar to the usefulness of the pre-fetched data. However, as time shifts (which can be understood as the CPU using more and more data), the usefulness of the pre-stored data in the initial space will change. Therefore, it is necessary to re-evaluate the usefulness of the pre-stored data in the initial space to determine whether to allocate the pre-fetched data to the initial space.

[0116] In one possible implementation, the spatial level division includes L2, L3 and LLC, and the prefetch level division includes level_L2, level_L3 and level_LLC. Level_L2 matches L2, level_L3 matches L3, and level_LLC matches LLC. If the initial prefetch level is level_L2, the initial space is determined to be L2 space. If the initial prefetch level is level_L3, the initial space is determined to be L3 space. If the initial prefetch level is level_LLC, the initial space is determined to be LLC space.

[0117] S303: Determine a prefetch level of the prefetch request based on the data characteristics of the initial space.

[0118] Among them, by analyzing the data characteristics of the initial space, the usefulness of the pre-stored data in the initial space can be obtained, and based on the usefulness of the pre-stored data in the initial space, the pre-fetch level of the pre-fetch request can be further adjusted, which can further improve the accuracy of data pre-fetching.

[0119] It is understandable that if the initial prefetch level determined based on the confidence of the prefetch request is incorrect, determining the prefetch level of the prefetch request again based on the data characteristics of the initial space can timely eliminate the error caused by the initial prefetch level.

[0120] It should be noted that the data characteristics of the initial space can be used to characterize the CPU's data read and write operation patterns in the initial space. Based on the CPU's data read and write operation patterns in the initial space, the usefulness of the pre-stored data in the initial space can be determined, that is, the data usefulness of all data in the initial space can be determined. The so-called data read operation is the CPU reading data from the initial space, and the so-called data write operation (including data prefetch operations and non-data prefetch operations) is the writing of data from the memory to the initial space.

[0121] In some examples, the initial space includes data A and data B, data A is written to the initial space via a data prefetch operation, data B is written to the initial space via a non-data prefetch operation, and data B is read once by the CPU, then the data usefulness of all data in the initial space is 1 / 2=50%.

[0122] The so-called non-data prefetch operation means that after the CPU initiates a data use request, it responds to the CPU's needs and moves the corresponding data from the memory to the cache for CPU use.

[0123] Optionally, the data write operation includes a data prefetch operation and a non-data prefetch operation. Since this solution is mainly aimed at improving the prefetch solution, the inclusion of non-prefetch data operations cannot accurately reflect the usefulness of the prefetched data in the initial space. Therefore, the usefulness of all prefetched data in the initial space can be characterized based on data utilization (data utilization is determined based on the number of data prefetches and the number of data hits), thereby improving the reliability of the usefulness of the prefetched data. In some examples, the specific implementation process of determining the prefetch level of a prefetch request based on the data utilization of the initial space can be seen in the steps shown in Figure 4 and the explanation of the steps.

[0124] The process shown in the above S301-S303 is based on the historical data requests of the cache data user and the data characteristics of the initial space, which serves as a reference for the prefetching level determination process. It can effectively improve the accuracy of data prefetching, so that prefetched data with higher usefulness can be allocated to the cache space with higher data usefulness, thereby avoiding cache pollution.

[0125] Example 4

[0126] As shown in FIG4 , a flow chart of another data prefetching method provided in an embodiment of the present application is provided, which includes the following steps.

[0127] S401: Determine data utilization of the initial space.

[0128] Data utilization is determined based on the number of data prefetches and data hits within a historical time period. The number of data prefetches represents the number of times the CPU prefetches data from the initial space. The number of data hits represents the number of times the CPU directly reads data from the initial space.

[0129] In some examples, data utilization can be characterized as the ratio between the number of data hits and the number of data prefetches. In one possible implementation, if the number of data hits in the initial space during a historical period is 200 and the number of data prefetches is 1000, the data utilization of the initial space is determined to be 200 / 1000 = 20%.

[0130] S402: Compare the data utilization of the initial space with a threshold.

[0131] The cache includes multiple spaces, and the comparison threshold corresponding to the data utilization rate of each space can be the same or different.

[0132] In some examples, the cache includes L2 space, L3 space, and LLC space, and the L2 space, L3 space, and LLC space may each correspond to the same threshold (e.g., 50%), or the L2 space corresponds to a first threshold (e.g., 60%), the L3 space corresponds to a second threshold (e.g., 50%), and the LLC space corresponds to a third threshold (e.g., 40%).

[0133] S403: If the data utilization rate of the initial space meets the threshold, determine the prefetch level of the prefetch request based on the initial prefetch level.

[0134] Among them, the data utilization rate of the initial space meets the threshold, which means that the usefulness of the pre-stored data in the initial space has not changed significantly. The data usefulness shown by the initial pre-fetch level of the pre-fetch request matches the usefulness of the pre-stored data in the initial space. Therefore, based on the initial pre-fetch level, the pre-fetch level of the pre-fetch request is determined.

[0135] It should be noted that determining the prefetch level of the prefetch request based on the initial prefetch level is essentially allocating the prefetch data corresponding to the prefetch request to the initial space.

[0136] In a possible implementation, the initial space is L2 space, the initial prefetch level is level_L2, and if the data utilization of the initial space meets a threshold, the prefetch level of the prefetch request is determined based on level_L2.

[0137] S404: If the data utilization rate of the initial space is greater than the threshold, determine that the prefetch level of the prefetch request is higher than the initial prefetch level.

[0138] If the initial prefetch level is the highest prefetch level, the prefetch level of the prefetch request is determined based on the initial prefetch level.

[0139] It should be noted that if the data utilization rate of the initial space is greater than the threshold, it means that the usefulness of the pre-stored data in the initial space has increased. Correspondingly, the usefulness of the pre-fetched data corresponding to the pre-fetch request will also increase. To this end, it is necessary to increase the pre-fetch level of the pre-fetch request so that the pre-fetch level of the pre-fetch request is higher than the initial pre-fetch level. Of course, if the initial pre-fetch level is the highest pre-fetch level and the pre-fetch level of the pre-fetch request cannot be increased based on the initial pre-fetch level, the pre-fetch level of the pre-fetch request will be determined based on the highest pre-fetch level.

[0140] In a possible implementation, the initial space is L2 space, and the initial prefetch level is level_L2. If the data utilization of the initial space is greater than a threshold, and level_L2 is the highest prefetch level, the prefetch level of the prefetch request is determined to be level_L2.

[0141] In a possible implementation, the initial space is L3 space, and the initial prefetch level is level_L3. If the data utilization of the initial space is greater than a threshold, and there is level_L2 above level_L3, the prefetch level of the prefetch request is determined to be level_L2.

[0142] In a possible implementation, the initial space is LLC space, and the initial prefetch level is level_LLC. If the data utilization of the initial space is greater than a threshold, and there are level_L2 and level_L3 above level_LLC, the prefetch level of the prefetch request is determined to be level_L2 or level_L3.

[0143] Preferably, if the data utilization rate of the initial space is greater than a threshold, and there are multiple prefetch levels above the initial prefetch level, the prefetch level for the prefetch request may be determined based on the previous level closest to the initial prefetch level. In one possible embodiment, the initial space is LLC space, and the initial prefetch level is level_LLC. If the data utilization rate of the initial space is greater than a threshold, and there are level_L2 and level_L3 above level_LLC, the prefetch level for the prefetch request is determined to be level_L3.

[0144] Preferably, the thresholds corresponding to the various spaces in the cache are different, and the higher the space level of the space, the higher the threshold corresponding to the space. The prefetch level of the prefetch request can also be determined in combination with the gap between the threshold corresponding to each space and the data utilization rate. In one possible implementation, the initial space is LLC space, and the initial prefetch level is level_LLC. If the data utilization rate of the initial space is 52%, there are level_L2 and level_L3 above level_LLC, the threshold corresponding to the LLC space is 30%, the threshold corresponding to the L3 space is 50%, and the threshold corresponding to the L2 space is 80%. Based on the gap between the threshold corresponding to each space and the data utilization rate, it is determined that the gap between the threshold corresponding to the L3 space and the data utilization rate of the initial space is the smallest. For this reason, the prefetch level of the prefetch request is determined to be level_L3.

[0145] S405: If the data utilization rate of the initial space is less than the threshold, determine that the prefetch level of the prefetch request is lower than the initial prefetch level.

[0146] If the initial prefetch level is the lowest prefetch level, the prefetch request is canceled.

[0147] It's important to note that canceling a prefetch request essentially cancels the fetching of the corresponding prefetch data from memory to the cache. This indicates that the usefulness of the prefetch data corresponding to the current prefetch request no longer meets the prefetch criteria, and the prefetch request needs to be canceled to avoid cache pollution. Generally speaking, if the prefetch request is initiated by a prefetcher, a cancellation notification is also sent to the prefetcher so that it can regenerate a new prefetch request.

[0148] It is understandable that if the data utilization rate of the initial space is less than the threshold, it means that the usefulness of the pre-stored data in the initial space has decreased. Correspondingly, the usefulness of the pre-fetched data corresponding to the pre-fetch request will also decrease. Therefore, it is necessary to lower the pre-fetch level of the pre-fetch request so that the pre-fetch level of the pre-fetch request is lower than the initial pre-fetch level. Of course, if the initial pre-fetch level is the lowest pre-fetch level and the pre-fetch level of the pre-fetch request cannot be lowered based on the initial pre-fetch level, it means that the pre-fetched data corresponding to the pre-fetch request does not meet the pre-fetch conditions, and the pre-fetch request is canceled to avoid cache pollution.

[0149] In a possible implementation, the initial space is L2 space, and the initial prefetch level is level_L2. If the data utilization of the initial space is less than a threshold, and there are level_L3 and level_LLC below level_L2, then the prefetch level of the prefetch request is determined to be level_L3 or level_LLC.

[0150] Preferably, if the data utilization rate of the initial space is less than a threshold, and there are multiple prefetch levels below the initial prefetch level, the prefetch level for the prefetch request may be determined based on the next level closest to the initial prefetch level. In one possible embodiment, the initial space is L2 space, and the initial prefetch level is level_L2. If the data utilization rate of the initial space is less than a threshold, and there are level_L3 and level_LLC below level_L2, the prefetch level for the prefetch request is determined to be level_L3.

[0151] Preferably, the thresholds corresponding to the various spaces in the cache are different, and the lower the space level of the space, the lower the threshold corresponding to the space. The prefetch level of the prefetch request can also be determined in combination with the gap between the threshold corresponding to each space and the data utilization rate. In one possible implementation, the initial space is the L2 space, and the initial prefetch level is level_L2. If the data utilization rate of the initial space is 52%, there are level_L2 and level_L3 above level_LLC, the threshold corresponding to the LLC space is 30%, the threshold corresponding to the L3 space is 50%, and the threshold corresponding to the L2 space is 80%. Based on the gap between the threshold corresponding to each space and the data utilization rate, it is determined that the gap between the threshold corresponding to the L3 space and the data utilization rate of the initial space is the smallest. For this reason, the prefetch level of the prefetch request is determined to be level_L3.

[0152] In a possible implementation, the initial space is L3 space, and the initial prefetch level is level_L3. If the data utilization of the initial space is less than a threshold, and there is level_LLC below level_L3, the prefetch level of the prefetch request is determined to be level_LLC.

[0153] In a possible implementation, the initial space is LLC space, the initial prefetch level is level_LLC, and if the data utilization of the initial space is less than a threshold and level_LLC is the lowest prefetch level, the prefetch request is canceled.

[0154] In some examples, the implementation process of determining the prefetch level of a prefetch request based on the data utilization of the initial space can be summarized as the steps shown in Figure 6: for a prefetch request with an initial prefetch level of level_L2, if the data utilization of the L2 space corresponding to level_L2 is less than a threshold, the prefetch level of the prefetch request is adjusted to level_L3; if the data utilization of the L2 space is greater than or equal to the threshold, the prefetch level of the prefetch request is determined to be level_L2; for a prefetch request with an initial prefetch level of level_L3, if the data utilization of the L3 space corresponding to level_L3 is less than the threshold, the prefetch level of the prefetch request is adjusted to level_LLC; if the data utilization of the L3 space is greater than or equal to the threshold, the prefetch level of the prefetch request is adjusted to level_L2; for a prefetch request with an initial prefetch level of level_LLC, if the data utilization of the LLC space corresponding to level_LLC is less than the threshold, the prefetch request is canceled; if the data utilization of the LLC space is greater than or equal to the threshold, the prefetch level of the prefetch request is adjusted to level_L3.

[0155] The process shown in S401-S405 above can effectively adjust the prefetch level of the prefetch request based on the data utilization of the initial space, so that the coverage of each space in the cache is effectively met, and can also cancel the prefetch request that does not meet the prefetch conditions to avoid cache pollution.

[0156] Example 5

[0157] As shown in FIG5 , a flow chart of another data prefetching method provided in an embodiment of the present application is provided, which includes the following steps.

[0158] S501: Determine a target space whose space level matches the prefetch level of the prefetch request.

[0159] Herein, based on a preset matching relationship between the spatial level and the prefetch level, a target space whose spatial level matches the prefetch level of the prefetch request may be determined.

[0160] In some examples, the preset matching relationship between the spatial levels and the prefetch levels is: L2 matches level_L2, L3 matches level_L3, and L4 matches level_LLC.

[0161] S502: Determine a response status of the target space based on the data request responded to by the target space.

[0162] Among them, the data access frequency of the target space can be determined through the data request responded to by the target space, thereby further determining the response status of the target space.

[0163] In some examples, the data access frequency can be determined based on the total number of data requests. Optionally, the specific implementation process of determining the response status of the target space based on the data requests responded to by the target space can be: determining the total number of data requests responded to by the target space per unit time; if the total number meets the specified quantity condition, determining that the response status of the target space is busy; if the total number does not meet the specified quantity condition, determining that the response status of the target space is idle.

[0164] In some examples, the response state of the target space may also be determined by the cache occupancy in the target space. In one possible implementation, if the cache occupancy is greater than a specified limit, the response state of the target space is determined to be busy, and if the cache occupancy is less than or equal to the specified limit, the response state of the target space is determined to be idle.

[0165] S503: If the response status of the target space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the target space.

[0166] Among them, the response status of the target space is idle, which means that the pre-stored data in the target space will not be interfered with by the pre-fetched data. Extracting the pre-fetched data corresponding to the pre-fetch request from the memory to the target space will not affect the CPU's data access in the target space.

[0167] In a possible implementation, the target space is the L2 space, and the response status of the L2 space is idle, and the prefetch data corresponding to the prefetch request is extracted from the memory to the L2 space.

[0168] S504: If the response status of the target space is busy, extract the prefetch data corresponding to the prefetch request from the memory to the first space.

[0169] The first space includes a space having a lower space level than the target space and a response state of free space, and the usefulness of data stored in the first space is lower than the usefulness of data stored in the target space.

[0170] It should be noted that if the response status of the target space is busy, and the prefetch data corresponding to the prefetch request is still extracted from the memory to the target space, it may affect the CPU's data access. For this reason, the prefetch data corresponding to the prefetch request can be extracted from the memory to the first space.

[0171] In a possible implementation, the target space is the L2 space, the response status of the L2 space is busy, the space level of the L2 space is higher than the L3 space and the LLC space, and the response status of the L3 space and the LLC space are each idle, then the prefetch data corresponding to the prefetch request can be extracted from the memory to any one of the L3 space and the LLC space.

[0172] Preferably, if the response status of the target space is busy, and the response status of the remaining multiple spaces whose space levels are lower than the target space is idle, the prefetched data corresponding to the prefetch request can be extracted from the memory to the space in the remaining multiple spaces whose space level is closest to the space level of the target space. In one possible embodiment, the target space is the L2 space, the response status of the L2 space is busy, the space level of the L2 space is higher than the space level of the L3 space and the LLC space, the space level of the L3 space is higher than the LLC space, and the response status of the L3 space and the LLC space is idle, the prefetched data corresponding to the prefetch request is extracted from the memory to the L3 space.

[0173] In a possible implementation, the target space is L2 space, the response status of L2 space is busy, the space level of L2 space is higher than L3 space and LLC space, and the response status of L3 space is busy, and the response status of LLC space is idle, then the prefetch data corresponding to the prefetch request can be extracted from the memory to the LLC space.

[0174] In a possible implementation, the target space is L3 space, the response status of L3 space is busy, the space level of L3 space is higher than LLC space, and the response status of LLC space is idle, then the prefetch data corresponding to the prefetch request can be extracted from the memory to the LLC space.

[0175] It should be emphasized that if the response status of the target space is busy and the response status of the remaining spaces with a higher space level than the target space is idle, it is prohibited to extract the prefetched data corresponding to the prefetch request from the memory to the remaining spaces to avoid cache pollution caused by the prefetched data to the remaining spaces (based on the division of space levels, it can be seen that the data in the remaining spaces with a higher space level than the target space is more useful than the prefetched data. Extracting the prefetched data to the remaining spaces will replace the data with higher usefulness in the remaining spaces, thereby causing cache pollution and reducing the accuracy of data prefetching).

[0176] S505: If the response status of the target space is busy and the space level of the target space is the lowest level, cancel the prefetch request.

[0177] Among them, if the response status of the target space is busy and the space level of the target space is the lowest level of space level, it means that the prefetched data corresponding to the prefetch request can no longer be extracted from the memory to the cache. Because the execution of the prefetch request will affect the CPU's access to the cached data, the prefetch request is canceled.

[0178] In a possible implementation manner, the target space is the LLC space, the response status of the LLC space is busy, and the space level of the LLC space is the lowest level, then the prefetch request may be canceled.

[0179] In some examples, the specific implementation process of determining the execution of the prefetch request based on the response status of the target space can be summarized as the steps shown in Figure 7: for a prefetch request with a prefetch level of level_L2, if the response status of the L2 space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the L2 space; if the response status of the L2 space is busy and the response status of the L3 space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the L3 space; if the response status of the L2 space and the L3 space is busy and the response status of the LLC space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the LLC space; if the response status of the L2 space, the L3 space, and the LLC space is busy, If the status is busy, the prefetch request is canceled; for the prefetch request with a prefetch level of level_L3, if the response status of the L3 space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the L3 space; if the response status of the L3 space is busy and the response status of the LLC space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the LLC space. If the response status of the L3 space and the LLC space are busy, the prefetch request is canceled; for the prefetch request with a prefetch level of level_LLC, if the response status of the LLC space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the LLC space. If the response status of the LLC space is busy, the prefetch request is canceled.

[0180] It can be understood that in the process shown in Figure 7, for the prefetch request with a prefetch level of level_L3, if the response status of the L3 space and the LLC space is busy, and the response status of the L2 space is space, in order to avoid cache pollution to the L2 space, it is prohibited to extract the prefetch data corresponding to the prefetch request from the memory to the L2 space. For this reason, the prefetch request is canceled.

[0181] The process shown in S501-S505 above adjusts the storage space of the pre-fetch request based on the response status of the target space, so as to avoid affecting the use of the pre-stored data in the target space and effectively improve the performance of data pre-fetching.

[0182] Example 6

[0183] Corresponding to the data pre-fetching method provided in the above-mentioned embodiment of the present application, the embodiment of the present application also provides a data pre-fetching device.

[0184] As shown in FIG10 , it is a schematic diagram of the architecture of a data pre-fetching device provided in an embodiment of the present application, which includes the units shown below.

[0185] The request determination unit 100 is used to obtain a prefetch request; the prefetch request is used to indicate prefetch data extracted from the memory into the cache; the cache includes multiple spaces of different space levels.

[0186] The level determination unit 200 is used to determine the prefetch level of the prefetch request based on the historical data requests of the cache data user; the prefetch level is used to represent the usefulness of the prefetched data.

[0187] Optionally, the level determination unit 200 is specifically used to: determine the confidence of the prefetch request based on the historical data requests of the cache data user; the confidence is used to characterize the probability that the prefetch data corresponding to the prefetch request is used by the cache data user; based on the confidence of the prefetch request, determine the prefetch level of the prefetch request; wherein, the higher the confidence, the higher the prefetch level.

[0188] Optionally, the level determination unit 200 is specifically used to: determine the initial prefetch level of the prefetch request based on the historical data requests of the cache data user; determine the initial space that matches the space level with the initial prefetch level based on the preset matching relationship between the space level and the prefetch level; and determine the prefetch level of the prefetch request based on the data characteristics of the initial space.

[0189] Optionally, the data characteristics include data utilization, which is determined based on the number of data prefetches and the number of data hits in a historical time period. The level determination unit 200 is specifically used to: determine the data utilization of the initial space; if the data utilization of the initial space meets the threshold, based on the initial prefetch level, determine it as the prefetch level of the prefetch request.

[0190] Optionally, the level determination unit 200 is specifically used to: if the data utilization rate of the initial space is greater than a threshold, determine that the prefetch level of the prefetch request is higher than the initial prefetch level; wherein, if the initial prefetch level is the highest level of prefetch level, based on the initial prefetch level, determine the prefetch level of the prefetch request.

[0191] Optionally, the level determination unit 200 is specifically configured to: if the data utilization rate of the initial space is less than a threshold, determine that the prefetch level of the prefetch request is lower than the initial prefetch level; wherein, if the initial prefetch level is the lowest level of prefetch level, cancel the prefetch request.

[0192] The data extraction unit 300 is configured to extract the prefetched data corresponding to the prefetch request from the memory to a space whose space level matches the prefetch level of the prefetch request.

[0193] Optionally, the data extraction unit 300 is specifically used to: determine a target space whose spatial level matches the prefetch level of the prefetch request; determine the response status of the target space based on the data request responded to by the target space; if the response status of the target space is idle, extract the prefetch data corresponding to the prefetch request from the memory to the target space.

[0194] Optionally, the data extraction unit 300 is specifically used to: if the response status of the target space is busy, extract the prefetched data corresponding to the prefetch request from the memory to the first space; the first space includes a space level lower than the space level of the target space, and the response status is free; the usefulness of the data stored in the first space is lower than the usefulness of the data stored in the target space.

[0195] Optionally, the data extraction unit 300 is specifically configured to: cancel the prefetch request if the response status of the target space is busy and the space level of the target space is the lowest level of space level.

[0196] The above-mentioned units can prevent useless prefetched data from being extracted into the cache and avoid cache pollution by determining the prefetch level of the prefetch request and extracting the prefetch data corresponding to the prefetch request from the memory to the space whose spatial level matches the prefetch level. In addition, based on the matching of the prefetch level and the spatial level, the coverage of data prefetching can also be improved, and the accuracy and coverage of data prefetching can be balanced.

[0197] The present application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the data prefetching method provided by the present application.

[0198] The present application also provides an electronic device comprising: a processor, a memory, and a bus. The processor and the memory are connected via the bus, the memory is used to store a program, and the processor is used to run the program, wherein the data prefetching method provided by the present application is executed when the program is run.

[0199] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

[0200] Although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this application. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented in multiple embodiments individually or in any suitable sub-combination.

[0201] The above description is merely a preferred embodiment of the present application and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this application is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this application.

Claims

1. A data prefetching method, comprising: Get prefetch request; The prefetch request is used to instruct prefetch data to be extracted from the memory into the cache; the cache includes a plurality of spaces of different space levels; determining a prefetch level of the prefetch request based on historical data requests of a cache data user; The prefetch level is used to characterize the usefulness of the prefetched data; The prefetch data corresponding to the prefetch request is extracted from the memory to a space whose space level matches the prefetch level of the prefetch request.

2. The method according to claim 1, extracting the prefetch data corresponding to the prefetch request from the memory to a space whose space level matches the prefetch level of the prefetch request, comprising: determining a target space having a spatial rank matching the prefetch rank of the prefetch request; Determining a response status of the target space based on the data request to which the target space responds; If the response status of the target space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the target space.

3. According to the method of claim 2, if the response status of the target space is busy, the prefetch data corresponding to the prefetch request is extracted from the memory to the first space; the first space includes a space level lower than the space level of the target space and the response status is free; the usefulness of the data stored in the first space is lower than the usefulness of the data stored in the target space. 4 . The method according to claim 2 , further comprising canceling the prefetch request if the response status of the target space is busy and the space level of the target space is the lowest level.

5. The method according to claim 1, wherein determining the prefetch level of the prefetch request based on historical data requests of the cache data user comprises: Determining the confidence level of the prefetch request based on historical data requests of the cache data user; The confidence level is used to represent the probability that the pre-fetched data corresponding to the pre-fetch request is used by the cached data user; Based on the confidence of the prefetch request, a prefetch level of the prefetch request is determined; wherein, the higher the confidence, the higher the prefetch level.

6. The method according to claim 1 , wherein determining the prefetch level of the prefetch request based on historical data requests of the cache data user comprises: determining an initial prefetch level for the prefetch request based on historical data requests of a cache data user; determining, based on a preset matching relationship between the spatial level and the prefetch level, an initial space whose spatial level matches the initial prefetch level; A prefetch level of the prefetch request is determined based on data characteristics of the initial space.

7. The method according to claim 6, wherein the data characteristics include data utilization, the data utilization is determined based on the number of data prefetches and the number of data hits in a historical time period, and determining the prefetch level of the prefetch request based on the data characteristics of the initial space comprises: Determining data utilization of the initial space; If the data utilization rate of the initial space meets a threshold, a prefetch level of the prefetch request is determined based on the initial prefetch level.

8. The method according to claim 7, wherein if the data utilization rate of the initial space is greater than the threshold, determining that the prefetch level of the prefetch request is higher than the initial prefetch level; If the initial prefetch level is the highest level of prefetch level, a prefetch level for the prefetch request is determined based on the initial prefetch level.

9. The method according to claim 7, wherein if the data utilization rate of the initial space is less than the threshold, determining that the prefetch level of the prefetch request is lower than the initial prefetch level; If the initial prefetch level is the lowest prefetch level, the prefetch request is canceled.

10. A data pre-fetching device, comprising: a request determining unit, configured to obtain a prefetch request; The prefetch request is used to indicate prefetch data to be extracted from the memory into the cache; The cache includes a plurality of spaces of different spatial levels; a level determination unit, configured to determine a prefetch level of the prefetch request based on historical data requests of a cache data user; The prefetch level is used to characterize the usefulness of the prefetched data; A data extraction unit is configured to extract the prefetched data corresponding to the prefetch request from the memory to a space whose space level matches the prefetch level of the prefetch request.

11. The device according to claim 10, wherein the data extraction unit is specifically configured to: determining a target space having a spatial rank matching the prefetch rank of the prefetch request; Determining a response status of the target space based on the data request to which the target space responds; If the response status of the target space is idle, the prefetch data corresponding to the prefetch request is extracted from the memory to the target space.

12. The device according to claim 11, wherein the data extraction unit is specifically configured to: If the response status of the target space is busy, the prefetch data corresponding to the prefetch request is extracted from the memory to the first space; the first space includes a space whose space level is lower than the space level of the target space and whose response status is free; the usefulness of the data stored in the first space is lower than the usefulness of the data stored in the target space.

13. The device according to claim 11, wherein the data extraction unit is specifically configured to: If the response status of the target space is busy and the space level of the target space is the lowest level, the prefetch request is canceled.

14. The apparatus according to claim 10, wherein the level determination unit is specifically configured to: Determining the confidence level of the prefetch request based on historical data requests of the cached data user; the confidence level is used to characterize the probability that the prefetched data corresponding to the prefetch request is used by the cached data user; Based on the confidence level of the prefetch request, a prefetch level of the prefetch request is determined; wherein, The higher the confidence level, the higher the pre-fetch level.

15. The apparatus according to claim 10 or 14, wherein the level determination unit is specifically configured to: determining an initial prefetch level for the prefetch request based on historical data requests of a cache data user; determining, based on a preset matching relationship between the spatial level and the prefetch level, an initial space whose spatial level matches the initial prefetch level; A prefetch level of the prefetch request is determined based on data characteristics of the initial space.

16. The apparatus according to claim 15, wherein the data feature comprises a data utilization rate, the data utilization rate being determined based on a number of data pre-fetches and a number of data hits within a historical time period, and the level determination unit being specifically configured to: Determining data utilization of the initial space; If the data utilization rate of the initial space meets a threshold, a prefetch level of the prefetch request is determined based on the initial prefetch level.

17. The apparatus according to claim 16, wherein the level determination unit is specifically configured to: If the data utilization rate of the initial space is greater than the threshold, determining that the prefetch level of the prefetch request is higher than the initial prefetch level; wherein, If the initial prefetch level is the highest level of prefetch level, a prefetch level for the prefetch request is determined based on the initial prefetch level.

18. The apparatus according to claim 16, wherein the level determination unit is specifically configured to: If the data utilization rate of the initial space is less than the threshold, it is determined that the prefetch level of the prefetch request is lower than the initial prefetch level; wherein, If the initial prefetch level is the lowest prefetch level, the prefetch request is canceled.

Citation Information

Patent Citations

  • Data prefetching method and device

    CN117992364A

  • Prefetching to a cache based on buffer fullness

    CN104769560A

  • Self-adaptive segmented caching method and system based on classification prediction

    CN113419976A

  • Prefetch level degradation

    CN114830100A

  • Data prefetch ramp implemenation based on memory utilization

    US20160034400A1