Data prefetching method and electronic device
By dynamically evaluating the confidence score of read request sequences and employing differentiated management strategies, the problem of invalid prefetched data occupying cache space was solved, thereby improving cache efficiency and optimizing storage system performance.
Patent Information
- Application Number
- CN202511404571.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-09-29
AI Technical Summary
In existing technologies, static strategies with fixed prefetch distance and prefetch size are difficult to adapt to the dynamic changes in host access patterns, resulting in invalid prefetched data occupying cache space, causing low cache efficiency and wasted storage bandwidth.
By dynamically evaluating the confidence score of the read request sequence, prefetch parameters are generated, and prefetched data is allocated to the first and second prefetch queues with differentiated management strategies. Periodic elimination verification is implemented, and prefetch parameters are adjusted to adapt to workload changes and reduce invalid prefetches.
It improves the utilization efficiency of cache resources, reduces waste from invalid prefetching, and enhances the efficiency of input/output request processing in the storage system.
Smart Images

Figure CN120892359B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and particularly relates to a data prefetching method and an electronic device. BACKGROUND
[0002] In a modern storage system, data prefetching technology is a key means to optimize sequential read input / output performance and reduce access delay. However, the related technology generally adopts fixed prefetch distance and prefetch size parameters. Such a static prefetching strategy is difficult to adapt to the dynamically changing access mode of the host, resulting in that the prefetched data is evicted due to insufficient cache space before being accessed, or invalid prefetch data occupies cache space, which not only consumes storage bandwidth, but also may cause cache pollution due to invalid data occupying cache space, and finally leads to the decline of overall system performance. SUMMARY
[0003] The present application provides a data prefetching method and an electronic device to at least solve the technical problem that invalid prefetch data occupies cache space, resulting in prefetching waste and low cache efficiency.
[0004] The present application provides a data prefetching method, which comprises: in response to receiving a plurality of read requests, generating a sequential read stream based on the sequential nature of the data prefetching of the plurality of read requests; evaluating a confidence score of the sequential read stream, and in response to the data prefetching confidence score exceeding a confidence score threshold, generating a corresponding prefetch parameter according to the sequential read stream; allocating the prefetch data corresponding to the sequential read stream to a prefetch queue according to the data prefetching parameter, wherein the data prefetch queue at least includes a first prefetch queue and a second prefetch queue; in response to the prefetch data being in the first prefetch queue, performing a period eviction verification according to the accessed state of the prefetch data in a first period; in response to the prefetch data being in the second prefetch queue, performing a period eviction verification according to the accessed state of the prefetch data in a first period and a second period, wherein the second period is a period adjacent to the first period after the first period; evaluating whether there is prefetching waste of the prefetch data in the prefetch queue; and in response to the existence of the prefetching waste, adjusting the prefetch parameter.
[0005] The present application also provides an electronic device, which comprises:
[0006] A memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above prefetching data methods.
[0007] The application triggers the prefetch operation by dynamically evaluating the confidence score of the read request sequence, ensures that the prefetch is only started in the high-deterministic sequential access mode, thereby avoiding the resource overhead caused by invalid prefetch operation, further realizes the hierarchical management of the prefetch data life cycle by distributing the prefetch data to the first prefetch queue and the second prefetch queue with differentiated management strategies according to the prefetch parameters, and then implements the effectiveness check with different tolerances for the prefetch data in different prefetch queues through the periodic elimination verification mechanism, reduces the invalid occupation of the cache space through the check mechanism, finally forms the adaptive optimization path of the prefetch parameter adjustment by evaluating the prefetch waste and dynamically feeding back the adjustment of the prefetch parameters, so that the prefetch strategy can have a high matching degree with the actual workload characteristics, improve the cache efficiency, reduce the prefetch waste, and thereby improve the utilization efficiency of the cache resources and the efficiency of the storage system in processing the input / output requests.
[0008] Therefore, the method can solve the technical problems of invalid prefetch data occupying cache space, causing prefetch waste and low cache efficiency, and achieve the technical effect of improving cache efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0009] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0010] Figure 1 An application environment diagram of a data prefetch method provided by an embodiment of the present application is shown in the figure.
[0011] Figure 2 A flowchart of a data prefetch method provided by an embodiment of the present application is shown in the figure.
[0012] Figure 3 A flowchart of another data prefetch method provided by an embodiment of the present application is shown in the figure.
[0013] Figure 4 A flowchart of another data prefetch method provided by an embodiment of the present application is shown in the figure.
[0014] Figure 5 A structural diagram of a data prefetch device provided by an embodiment of the present application is shown in the figure.
[0015] Figure 6 A structural diagram of an electronic device provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0016] With reference to the drawings and the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.
[0017] It should be noted that, in the description of the present application, the terms "comprise", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. The terms "first", "second" and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0018] It should be noted that the terms "S1", "S2" and the like are only used for the purpose of describing the steps, and are not intended to specifically indicate the order or sequence, nor to limit the present application. They are only used to facilitate the description of the method of the present application, and cannot be understood as indicating the sequence of the steps. In addition, the technical solutions of various embodiments can be combined with each other, but it must be based on the fact that a person skilled in the art can realize it. When the combination of technical solutions contradicts each other or cannot be realized, it should be considered that the combination of technical solutions does not exist, nor is it within the protection scope claimed by the present application.
[0019] To solve the technical problem that invalid prefetch data occupies cache space, resulting in waste of prefetch and low cache efficiency, the present application generates a sequential read stream based on the sequentiality of a plurality of read requests in response to receiving the plurality of read requests; evaluates the confidence score of the sequential read stream, and in response to the confidence score exceeding a confidence score threshold, generates corresponding prefetch parameters for the sequential read stream; allocates prefetch data corresponding to the sequential read stream to a prefetch queue according to the prefetch parameters, wherein the prefetch queue at least includes a first prefetch queue and a second prefetch queue; in response to the prefetch data being in the first prefetch queue, performs cycle eviction verification according to the accessed state of the prefetch data in a first cycle; in response to the prefetch data being in the second prefetch queue, performs cycle eviction verification according to the accessed state of the prefetch data in a first cycle and a second cycle, wherein the second cycle is a cycle adjacent to the first cycle after the first cycle; evaluates whether there is a waste of prefetch data in the prefetch queue; and in response to the existence of the waste of prefetch, adjusts the prefetch parameters, thereby achieving the technical effect of improving cache efficiency.
[0020] For those skilled in the art of the technical field, the present application will be better understood in the following detailed description of the application in conjunction with the accompanying drawings and specific embodiments. The data prefetching method provided by the present application can be applied to, for example Figure 1 , Figure 1 An application environment diagram of a data prefetching method provided by an embodiment of the present application. In the diagram, a terminal 12 communicates with a server 14 through a network. The terminal 12 can be, but is not limited to, various personal computers, notebook computers, smartphones, tablet computers, and portable wearable devices, and the server 14 can be implemented by a standalone server or a server cluster composed of multiple servers.
[0021] For those skilled in the art of the technical field, the present application will be better understood in the following detailed description of the application in conjunction with the accompanying drawings and specific embodiments.
[0022] An embodiment of the present application provides a data prefetching method, which is described in detail in combination with the execution flow of the data prefetching method.
[0023] In one embodiment, as shown in Figure 2 , Figure 2 A flowchart of a data prefetching method provided by an embodiment of the present application.
[0024] S101: In response to receiving a plurality of read requests, generating a sequential read stream based on the sequentiality of the plurality of read requests.
[0025] In the embodiment, a read request represents an instruction issued by a host, such as a server or a CPU (Central Processing Unit), to a storage system, requesting to read data from a storage medium, such as a hard disk or an SSD (Solid State Drive). The read request usually contains information such as the starting logical address and length of the request, etc.
[0026] Sequentiality means that the data accessed by the plurality of read requests is continuous in the logical address space, or presents a predictable and regular pattern.
[0027] Sequential read stream represents a collection of a series of related read requests identified as having sequentiality characteristics. Sequential read stream is a logical concept representing a continuous sequential read operation sequence.
[0028] Specifically, the request information of the request can be acquired in real time, the access mode of the request can be analyzed according to the request information, and a continuous access track or mode can be abstracted from discrete requests by identifying dimensions such as address continuity, request timing correlation or data block size regularity. The order of the request is analyzed to perceive the access intention of the host, and a relatively accurate target object is provided for subsequent prefetching operation based on the perception. Based on this, blind prefetching of request data can be avoided, the accuracy of data prefetching is improved, and the prefetching efficiency is improved.
[0029] S102: evaluating a confidence score of the sequential read stream, and generating a corresponding prefetch parameter for the sequential read stream in response to the confidence score exceeding a confidence score threshold.
[0030] In the embodiment, the confidence score represents a quantitative evaluation value for measuring the credibility or certainty of a read request sequence being determined as a sequential read stream. The higher the score of the confidence score, the greater the possibility that the sequence is a true and stable sequential access mode. Conversely, the lower the score of the confidence score, the smaller the possibility that the sequence is a true and stable sequential access mode.
[0031] The confidence score threshold represents a preset threshold value for evaluating the confidence score of the sequential read stream. When the calculated confidence score is higher than the confidence score threshold, the corresponding prefetching action can be triggered; when the calculated confidence score is not higher than the confidence score threshold, it is considered that the sequentiality of the sequential read stream is low, and the sequential read stream is not a true and stable sequential access mode, and thus is processed as a non-sequential stream. The confidence score threshold is used to filter accidental and pseudo-sequential accesses, and ensures that the prefetching resources can be effectively invested based on the high sequentiality of the sequential read stream.
[0032] The prefetch parameter represents a key variable for controlling the prefetching behavior, and usually includes at least a prefetch distance and a prefetch size. The prefetch distance represents the amount of data to be prefetched in advance, and the prefetch size represents the amount of data of a single prefetching operation.
[0033] Specifically, a multi-factor fusion decision model can be used to quantitatively evaluate and verify the credibility of the identified access mode. Only when the confidence is high enough, the resource allocation and control strategy, i.e., the prefetch parameter, are initialized for the sequential access mode. The decision model based on the confidence score can avoid unnecessary prefetching behavior caused by misjudgment, thereby saving system computing resources, ensuring that the prefetching operation is only started in a scenario with high sequentiality, and improving the overall efficiency and economy of the system.
[0034] S103: allocating the prefetch data corresponding to the sequential read stream to a prefetch queue according to the prefetch parameter, wherein the prefetch queue includes at least a first prefetch queue and a second prefetch queue.
[0035] In the present embodiment, the prefetch data represents data blocks read from the storage medium into the cache in advance of the actual request by the host, according to the prefetch parameters.
[0036] The prefetch queue represents a logical area or linked list structure in the cache management system for storing and managing the prefetch data. The prefetch queue can be divided into different queues. Specifically, the division of the prefetch queue is not limited again, and the purpose is to implement differentiated management strategies for different prefetch queues.
[0037] Further, the prefetch queue can include a first prefetch queue and a second prefetch queue. The first prefetch queue and the second prefetch queue represent two management queues with different priorities or different eviction strategies. For example, the first queue can be used to manage prefetch data with high priority and expected to be accessed soon; the second queue can be used to manage prefetch data with low priority, expected to be accessed later or need further observation.
[0038] Specifically, the prefetch data can be classified and stored in cache partitions with different management strategies according to the urgency and importance of the data predicted to be accessed by the prefetch strategy. The prefetch strategy is determined by the prefetch parameters. By dividing different prefetch queues, the classification management of the prefetch data is implemented, so as to implement differentiated cycle monitoring or eviction mechanisms, thereby more effectively utilizing the limited cache space to improve cache hit rate.
[0039] S104: In response to the prefetch data being in the first prefetch queue, performing cycle eviction verification according to the accessed state of the prefetch data in the first cycle.
[0040] In the present embodiment, the first cycle represents a preset observation time window or cache scanning cycle.
[0041] The accessed state represents whether the prefetch data is hit and used by the read request of the host within the cycle.
[0042] Cycle eviction verification represents a cache management mechanism that periodically checks the access state of the data in a specific cycle and decides whether to remove it from the cache.
[0043] Specifically, the data in the high-priority cache partition can be subjected to relatively strict cycle management, for example, if it is not used within the first monitoring cycle, it is immediately determined as invalid prefetch and evicted. The cycle eviction verification performs a fast eviction mechanism for data expected to be used soon, which can quickly release the cache space occupied by invalid prefetch, reduce cache pollution, and ensure that high-value data has sufficient space to be stored, so as to keep the cache clean and efficient hit.
[0044] S105: in response to the prefetch data being in the second prefetch queue, performing a cycle eviction verification according to the accessed state of the prefetch data in the first cycle and a second cycle, wherein the second cycle is a cycle adjacent to the first cycle after the first cycle.
[0045] In the embodiment, the second cycle represents another observation time window or cache scanning cycle immediately after the first cycle.
[0046] Specifically, for the data in the low-priority cache partition, a relatively lenient and multi-stage cycle management can be implemented, for example, if it is not used continuously for multiple monitoring cycles, it is finally determined as invalid prefetch and evicted. It can be seen that the cycle eviction verification method and the cycle eviction verification method of the first prefetch queue have different tolerance degrees for the prefetch data. The data with a later expected access opportunity is given a longer survival time, avoiding the deletion of valid prefetch data due to the short observation period. The differential cycle eviction verification can improve the effectiveness of the prefetch operation, thereby reducing the risk of prefetch waste.
[0047] S106: evaluating whether there is a prefetch waste for the prefetch data in the prefetch queue.
[0048] In the embodiment, the prefetch waste represents a situation where the resources consumed by the prefetch operation, such as input / output bandwidth and cache space, do not produce positive benefits. The specific performance can be that the prefetched data is evicted from the cache before being accessed by the host.
[0049] Specifically, by monitoring and counting the relevant data information of the prefetch waste, the efficiency of the prefetch operation is continuously evaluated, and whether there is an invalid operation without return after resource investment is detected through quantitative indicators. Thus, the effectiveness of the prefetch strategy is monitored, and the prefetch strategy is continuously adjusted through the monitored data information, so as to make the prefetch strategy reach a relatively optimal state, thereby providing the system with a self-aware ability. Through the cycle of adjustment and feedback, the prefetch parameters are driven to adaptively optimize, thereby improving the overall performance of the system.
[0050] S107: in response to the existence of the prefetch waste, adjusting the prefetch parameter.
[0051] In the embodiment, the evaluation feedback result in step S106 can be used to dynamically adjust the resource allocation and control strategy, that is, to adjust the prefetch parameter, for example, to adjust the prefetch advance or the single operation amount. The effect of the subsequent prefetch operation is optimized by adjusting the prefetch parameter. Further, a self-adaptive optimization path of monitoring and evaluation and adjustment is formed, so that the prefetch system can adapt to the changes of the host workload, and the traditional static prefetch strategy is changed to a dynamic prefetch strategy. The system continuously converges to an optimal or relatively optimal performance state, thereby improving the adaptive ability and overall performance of the system.
[0052] In the embodiment, the application triggers the prefetch operation by dynamically evaluating the confidence score of the read request sequence, ensures that the prefetch is only started in the high-deterministic sequential access mode, thereby avoiding the resource overhead caused by invalid prefetch operation, further realizes the hierarchical management of the prefetch data life cycle by allocating the prefetch data to the first prefetch queue and the second prefetch queue with differentiated management strategies according to the prefetch parameters, and then implements the effectiveness check with different tolerance degrees to the prefetch data in different prefetch queues through the periodic eviction verification mechanism, reduces the invalid occupation of the cache space through the check mechanism, finally forms the adaptive optimization path of the prefetch parameter adjustment by evaluating the prefetch waste and dynamically feeding back the adjustment of the prefetch parameters, so that the prefetch strategy can have a high matching degree with the actual workload characteristics, improves the cache efficiency, reduces the prefetch waste, and thereby improves the utilization efficiency of the cache resources and the efficiency of the storage system in processing the input / output requests.
[0053] In one embodiment, as Figure 3 , Figure 3 The flowchart of another data prefetch method provided by the embodiment of the application is shown. A lightweight dynamic access track library is introduced, which is stored in a ring buffer and is a fixed-capacity time sliding window. The oldest record is automatically evicted when a new request arrives, ensuring the real-time performance of the data. The request parameters of the read request are obtained through the dynamic access track library, and the confidence score of the sequential read stream is evaluated. The request parameters of the read request can include the request time, the request start address and the request length, and a triple can be recorded for each host read request, and the form of the triple can be [request time T, request start address A, request length L], for example, [T=1680000000ns, A=0x1000, L=8KB]. Based on the request parameters, the address continuity factor, the timing tightness and the request size similarity factor of the sequential read stream are evaluated, including the following specific steps:
[0054] S201: Evaluate the address continuity factor of the sequential read stream.
[0055] In the embodiment, first, it is judged whether the read request has continuity. That is, the request start address and the request length of the current read request are obtained, the end address of the current read request is obtained based on the request start address and the request length, and in response to the end address of the current read request being the request start address of the next read request adjacent to the current read request, it is determined that the current read request and the next read request are continuously matched.
[0056] Specifically, the current read request represents a read data instruction from the host that the storage system has just received and is processing.
[0057] The request start address usually refers to a logical block address (LBA), which is a unique identifier of the starting position of the data on the storage device, similar to the starting page number of a book.
[0058] Request length indicates the size of data to be read in this read request, usually in units of bytes or blocks, similar to how many pages to be read continuously.
[0059] When a read request is sent from the host, for example, READ(T=1680000000ns, A=0x1000, L=8KB), the drive layer or dedicated hardware of the storage system will parse the command packet and extract the key fields. In software implementation, it is usually done by parsing the corresponding fields in the protocol command. The parameters in the read request are the most basic inputs for subsequent logical address analysis and prefetch decision.
[0060] End address indicates the end position of the data range accessed by the current read request in the logical address space.
[0061] That is, end address=request start address+(request length / logical block size);
[0062] For example, start address LBA=1000, request length=8KB, system logical block size=4KB. Then end address=1000+(8 / 4)=1000+2=1002, which means that the request accesses data from LBA 1000 to LBA 1001, a total of 2 blocks. Converting the request into a continuous linear address segment [start address, end address] is the key to determining whether two requests are continuous.
[0063] Further, the following calculation logic can be referred to.
[0064] if (A+L) == A +1 : #current request end address and next request start address are continuous;
[0065] continuous_count += 1;
[0066] a= continuous_count / window_size #address continuity factor
[0067] Where A represents the request start address, A +1 next request start address, L represents the request length, and a represents the address continuity factor. If the end address of the current request is exactly the request start address of the next request after adding the request length of the current request, it is considered that the current request and the next request are continuous.
[0068] Where the next read request adjacent to the current read request means the read request received immediately after the current read request in the time sequence.
[0069] Continuous match means that two requests are completely continuous in logical address space, the end of the former request is exactly the beginning of the latter request.
[0070] Through the continuity judgment, the number of matches of the continuous match, i.e., the number of pairs of continuous address requests, can be determined. The ratio of the number of matches of the continuous match to the total number of requests in the track library is taken as an address continuity factor. The calculation method of the address continuity factor can refer to formula 1-1:
[0071] Address continuity factor = number of matches of continuous match / total number of requests (formula 1-1);
[0072] In the embodiment, the address continuity factor is a quantitative index, which ranges from 0 to 1, and is used to represent how large the possibility of strict continuity of read requests in the recent history is. The closer to 1, the stronger the continuity. The system temporarily stores the information of a plurality of read requests in a recent order by maintaining a temporary queue or buffer, i.e., a track library. By detecting the total number of continuous match events and the total number of read requests for analysis in a certain observation window for evaluating the order, the address continuity factor is determined, and the qualitative continuous judgment is converted into a quantitative and comparable value.
[0073] S202: Evaluate the time sequence tightness of the sequential read stream.
[0074] In the embodiment, the discrete degree value of the request time interval of the plurality of read requests is evaluated according to the request time and the total number of requests, and the discrete degree value is taken as the time sequence tightness.
[0075] wherein the request time represents the accurate time point at which the storage system receives each read request. The time is usually obtained by a high-precision clock source, and the unit is nanosecond (ns) or microsecond (μs). A related function can be called in an entry function of a drive layer or an IO scheduling layer to process the request to obtain a current time stamp, and the time stamp is bound to the request object for storage. A special timing circuit in the controller can also stamp the time when the request command is received to provide raw data for time sequence analysis.
[0076] The request time interval represents the time difference between the reception of two adjacent read requests. For example, it is assumed that there are requests arranged in time sequence, Req1, Req2, Req3,..., ReqN. n The time interval between the i-th request and the i+1-th request is calculated as Δt i = Time(Req i+1 ) - Time(Req i ), and a total of N-1 interval values can be calculated.
[0077] In statistics, the dispersion value represents a set of data; in this example, it refers to all Δt values. i The degree of deviation from the mean. Variance, or standard deviation, is an indicator of dispersion. A higher dispersion value indicates that the data points are more scattered and unstable. First, calculate the mean μ = (Δt1 + Δt2 + ... + Δt) for all time intervals. N-1 ) / (N-1). Then calculate the average of the squares of the differences between each interval and the mean, as shown in Equation 2-1:
[0078] σ 2 =Σ(Δt i -μ) 2 / (N-1) (Equation 2-1);
[0079] Where, Δt i It is the time interval between the i-th and i+1-th requests, and μ is Δt. i The average value, N is the total number of requests, σ 2 Let Variance be the variance.
[0080] Furthermore, the timing tightness can be calculated using Equation 2-2:
[0081] b = 1 / (1 + σ) 2 (Equation 2-2);
[0082] Where b represents temporal density, b approaching 1 indicates a stable rhythm of visits, σ 2 Let Variance be the variance.
[0083] In this embodiment, a standardized quantification index b is determined, which can be weighted and fused with other dimensional indices such as the address continuity factor a in step S201 to jointly generate the final confidence score of the sequential read stream.
[0084] S203: Evaluate the request size similarity factor for sequential read streams.
[0085] In this embodiment, the request size of multiple read requests is obtained; the average request size of multiple read requests is evaluated; the difference between the read request with the largest request size and the read request with the largest request size is calculated, and the ratio of the difference to the average request size is used as a size evaluation factor. Based on the size evaluation factor, a request size similarity factor is determined.
[0086] The request size indicates the amount of data that each read request requires to be read, usually in bytes, kilobytes (KB), or blocks.
[0087] The average request size represents the arithmetic mean of the sizes of all read requests within a given analysis window, and it represents the level of read operation scale during that period.
[0088] The size evaluation factor represents a preliminary, non-normalized intermediate calculation value for quantifying the fluctuation range of the request size. It is obtained by calculating the proportion of the range relative to the average value.
[0089] The request size similarity factor represents a final normalized measurement value ranging between (0, 1].
[0090] Specifically, there are N requests, whose sizes are L1, L2, L3,..., LN respectively. n The average size L avg = (L1+L2+... + LN) / N. n
[0091] The sizes of all N requests in the track library are traversed to find the maximum value L max and the minimum value L min . The request size similarity factor can be calculated with reference to formula 3-1:
[0092] c= 1- (L max - L min ) / L avg (3-1).
[0093] Wherein, L avg represents the average value of the request size, and the request size similarity factor is closer to 1 when all request sizes are similar.
[0094] In this embodiment, the request size similarity factor is used as a component of the confidence score of the sequential read stream. A stable sequential stream usually exhibits high factor values in address continuity, timing stability and size consistency. Therefore, the request size similarity factor can effectively filter out the read stream with chaotic behavior, further improve the accuracy of the prefetch decision, and avoid prefetch errors caused by size mutations.
[0095] S204: Evaluate the confidence score of the sequential read stream.
[0096] In this embodiment, the address continuity factor, the timing tightness and the request size similarity factor of the sequential read stream have been calculated based on the request parameters of the read requests recorded in real time by the track library. Further, the address continuity factor is given a first weight factor, the timing tightness is given a second weight factor, and the data block similarity is given a third weight factor. Based on the address continuity factor, the timing tightness and the data block similarity after the weight factors are assigned, the confidence score is calculated.
[0097] wherein the weight factor represents a pre-set coefficient, and the value of the weight factor represents the contribution of the corresponding evaluation factor, such as the address continuity, the time sequence tightness factor, and the request size similarity factor, in the final decision. For example, the first weight factor, the second weight factor, and the third weight factor respectively refer to the weight assigned to the address continuity factor, the time sequence tightness factor, and the request size similarity factor.
[0098] Specifically, the feature that contributes most to the judgment sequence is given a higher weight. For example, the spatial continuity of the address is generally considered to be the most core feature, and therefore its first weight factor is the highest. For example, the first weight factor w a = 0.4, the second weight factor w b = 0.3, and the third weight factor w c = 0.3, and the weights can be dynamically adjusted according to the scene.
[0099] The confidence score represents a final and comprehensive quantitative value, ranging between [0, 1]. It represents the degree of certainty of the system in determining that the current request sequence is a real and stable sequential flow based on multi-dimensional indicators. The higher the score, the greater the certainty. The confidence score can be calculated according to formula 4-1:
[0100] Confidence score = (a* w a ) + (b* w b ) + (c* w c ) (formula 4-1);
[0101] The sum of the above three weighted results is the confidence score.
[0102] In this embodiment, the limitations of single-dimensional judgment are reduced by multi-dimensional request indicators. For example, even if the address is completely continuous, if the request rhythm is extremely unstable, the final confidence score will be lowered, thereby avoiding misjudgment, converting the pattern recognition problem into a comparable numerical judgment to drive the start and stop of the subsequent prefetch controller.
[0103] S205: Distribute the sequential read stream with a confidence score exceeding the confidence score threshold to the prefetch queue according to the prefetch parameters.
[0104] In this embodiment, a confidence score evaluation period is pre-set, and a continuous confidence score is obtained based on the confidence score evaluation period; it is determined whether the continuous confidence scores of the pre-set continuous number of times exceed the confidence score threshold; and in response to the continuous confidence scores of the pre-set continuous number of times exceeding the confidence score threshold, a target prefetch controller is created, and the target prefetch controller is configured to the sequential read stream, wherein the target controller inherits the multiple request parameters of the trajectory library since the creation time of the target prefetch controller.
[0105] The pre-set confidence evaluation period represents a pre-set time interval or event interval for checking and decision making. The pre-set confidence evaluation period defines how often the system calculates the confidence score and makes a decision.
[0106] The continuous confidence score represents a time series data composed of the confidence scores calculated in each of the continuous evaluation periods.
[0107] The pre-set continuous number of times represents a pre-set threshold value, which can be denoted as K. The pre-set continuous number of times requires that the condition be met in the continuous evaluation periods to trigger the final action.
[0108] The confidence score threshold is the confidence threshold in step S204, which can be denoted as θ.
[0109] The target prefetch controller is a dedicated and instantiated management entity. It is created to be responsible for managing the entire prefetch life cycle of a specific and confirmed sequential read stream, including parameter initialization, dynamic adjustment, data management, etc. The target prefetch controller can be an object or a structure, which contains various state variables required by the sequential read stream, or a set of allocated registers or a dedicated state machine.
[0110] Specifically, an evaluation period can be set after receiving N new read requests. A timer can also be set, for example, every 10 milliseconds, to periodically wake up a detection task to perform confidence evaluation. The system maintains a small queue or sliding window dedicated to storing the confidence scores calculated in the last K evaluation periods. The latest score is added to the queue and the oldest score is removed every time a new evaluation period ends. At the same time, the pre-set continuous number of times is set according to experience, for example, K = 3. In each evaluation period, the calculated confidence score is compared with the confidence score threshold θ. If the confidence score exceeds the confidence score threshold θ and the continuous K periods all exceed θ, the target prefetch controller is created and configured to the sequential read stream. That is, only the sequential read stream that passes through the two levels of confirmation will be allocated a dedicated prefetch controller by the system.
[0111] Further, when the creation action is triggered, the system will pass the latest historical data about this sequential stream in the current track library, such as the addresses, sizes, and times of the last K requests, to the newly created prefetch controller as initialization parameters. The controller uses these latest and most relevant real data to calculate the initial average IO size, etc.
[0112] In the embodiment, the accuracy and reliability of the pre-fetch operation start are improved by the trigger condition of multi-cycle continuous verification. Specifically, the confidence score of the sequential read stream is continuously monitored by pre-setting the confidence evaluation period, and the pre-fetch controller is created only when the pre-set continuous number of scores exceeds the threshold value, filtering the short-term or accidental sequential access mode, and avoiding invalid pre-fetch and resource waste caused by misjudgment. At the same time, the target pre-fetch controller inherits the real-time request parameters in the track library when it is created, ensuring that the initialization of the pre-fetch strategy matches the current actual workload characteristics.
[0113] In one of the embodiments, generating the corresponding pre-fetch parameters according to the sequential read stream further includes identifying the media type of the storage device where the data accessed by the sequential read stream is located, selecting a corresponding parameter calculation strategy based on the identified media type to initialize the pre-fetch distance and the pre-fetch size. Among them, if the media type is a solid state disk, a first coefficient is used to calculate the initial value of the pre-fetch distance and the pre-fetch size; if the media type is a mechanical hard disk, a second coefficient greater than the first coefficient is used to calculate the initial value of the pre-fetch distance and the pre-fetch size. Since the random read performance of the solid state disk is high, but the high-speed bandwidth resource is limited, a smaller coefficient is used to focus on avoiding bandwidth waste and cache pollution caused by excessive pre-fetching. The initialization formula tends to moderate pre-fetch distance and pre-fetch size. Similarly, since the mechanical hard disk has a head seek delay, and the sequential read-write bandwidth utilization is high, a larger coefficient is used for initialization, which can reduce the delay and effectively utilize the sequential bandwidth. By judging the media type where the accessed data is located, the performance suboptimal problem that may occur on a certain medium when a single initialization strategy is used when the system provides services on storage devices with different characteristics such as solid state disks and mechanical hard disks can be avoided.
[0114] In one of the embodiments, the pre-fetch parameters at least include the pre-fetch distance, and the pre-fetch data corresponding to the sequential read stream is allocated to the pre-fetch queue according to the pre-fetch parameters, which includes judging whether the pre-fetch distance is greater than a pre-set request data average based on the pre-fetch distance; in response to the pre-fetch distance being greater than the pre-set request data average, the pre-fetch data is allocated to a first pre-fetch queue; and in response to the pre-fetch distance being less than or equal to the pre-set request data average, the pre-fetch data is allocated to a second pre-fetch queue.
[0115] Among them, the pre-fetch parameters are a core variable set for controlling the pre-fetch behavior, and the pre-fetch distance (PrefetchDistance, PD) is one of the most critical parameters. The pre-fetch distance defines the amount of advance of the pre-fetch operation, that is, how far to offset from the current host read position to start pre-fetching data.
[0116] The pre-set request data average represents a threshold value for decision-making. The threshold value is a fixed value obtained by multiplying the average request data size by a pre-set multiple, such as 2 times. It is a decision value for distinguishing between long-distance pre-fetching and short-distance pre-fetching.
[0117] The prefetch size represents a data block that is initiated and read into the cache in advance by the prefetch controller according to the prefetch parameters. These data have not been requested by the host and are loaded predictively.
[0118] The prefetch queues include at least a first prefetch queue and a second prefetch queue, which are logical sub-queues in the cache management system for storing and managing prefetch data. The first prefetch queue is used to store prefetch data that is considered to be accessed by the host after a longer time, i.e., data with a larger prefetch distance. The second prefetch queue is used to store prefetch data that is considered to be accessed by the host soon, i.e., data with a smaller prefetch distance.
[0119] Specifically, for example, the system calculates an average request data value of 64 KB according to the monitored recent history requests, and a preset multiple of 2. The preset request data mean is 128 KB. The prefetch controller calculates a current prefetch distance of 160 KB for the sequential read stream. The current read position of the host is LBAX. The prefetch controller decides to initiate a prefetch operation. The prefetch engine reads data with a prefetch size of 96 KB from the logical address X + 160 KB and loads the data into the cache. At this time, the newly cached data is regarded as a prefetch data block.
[0120] Further, the system needs to decide which management queue to put the prefetch data block into. Therefore, the current prefetch distance = 160 KB is compared with the decision threshold preset request data mean = 128 KB. Since 160 KB > 128 KB, it is determined that the prefetch is a long-distance prefetch, and the prefetch data block is allocated to the first prefetch queue. Similarly, if the prefetch distance is 100 KB, since 100 KB <= 128 KB, it is determined that the prefetch is a short-distance prefetch, and the data block is allocated to the second prefetch queue.
[0121] In this embodiment, the prefetch data obtained by different prefetch operations is allocated to different prefetch queues by comparing the prefetch distance with the dynamically calculated request data mean, for subsequent differentiated life cycle management strategies.
[0122] In one of the embodiments, a background detection thread periodically scans the prefetch queue, identifies prefetch data in the prefetch queue that is not accessed, and removes the prefetch data from the prefetch queue in response to the prefetch data not being accessed within a first period.
[0123] The background detection thread represents an execution unit independent of the host input / output processing flow, which is used to perform management and maintenance tasks.
[0124] Unvisited prefetch data means a data block that has been loaded into the prefetch queue by the prefetch operation but has never been hit by any host read request since being stored.
[0125] The first period represents a preset time window for defining the length of a scanning period of the background detection thread. For example, a complete queue scanning is triggered after every 10 new prefetch data blocks are inserted.
[0126] Specifically, in the present embodiment, a separate background detection thread can be created, and a scanning period triggered by a fixed time interval or an event is set. The thread periodically traverses the prefetch queue, acquires the unvisited prefetch data by checking the access state of each data block, and immediately performs the operation of unlinking the prefetch data from the queue linked list and recycling the occupied cache space when it is found that the prefetch data has not been accessed within the first period. Thus, the timing cleaning of invalid prefetch data can be realized, the invalid occupation of cache space is reduced, and the cache utilization and the overall system performance are improved.
[0127] S206: In response to the prefetch data being in the first prefetch queue, a period eviction verification is performed according to the access state of the prefetch data in the first period.
[0128] In the present embodiment, if the prefetch data belongs to the first prefetch queue and the prefetch data has not been accessed in the first period, the prefetch data is immediately removed.
[0129] S207: In response to the prefetch data being in the second prefetch queue, a period eviction verification is performed according to the access state of the prefetch data in the first period and the second period.
[0130] In the present embodiment, the second period is the period adjacent to the first period after the first period. If the prefetch data belongs to the second prefetch queue and the prefetch data has not been accessed in the first period, the prefetch data is first moved to the tail to extend a survival period, and then removed when it is verified that the prefetch data has not been accessed after the second period ends.
[0131] In the present embodiment, a differentiated period eviction strategy is implemented by judging the queue type of the prefetch data, and a differentiated survival window is provided for different queue data. The high-deterministic invalid data can be quickly cleaned, and the low-deterministic data can be provided with a secondary verification opportunity. The cache space recycling efficiency and the prefetch data fault tolerance can be balanced, so as to reduce the cache pollution risk and improve the prefetch hit rate.
[0132] S208: Evaluate and adjust the prefetch distance.
[0133] In the embodiment, in response to the prefetch queue being the first prefetch queue, a prefetch distance waste rate is calculated based on the prefetch distance waste value, it is determined whether the prefetch distance waste rate exceeds a prefetch distance waste threshold, and in response to the prefetch distance waste rate exceeding the prefetch distance waste threshold, the prefetch distance is shortened.
[0134] The prefetch distance waste rate is used to represent a time characteristic between the prefetch data and the prefetch distance.
[0135] Specifically, the prefetch distance waste rate = the prefetch distance waste value / the total prefetch operation value. In the last 1000 prefetch operations, 50 long distance prefetch waste events occurred, so the prefetch distance waste rate = 50 / 1000 = 5%.
[0136] When the system determines that the prefetch distance waste rate > the prefetch distance waste threshold, the prefetch controller performs an adjustment operation, so that the new prefetch distance = the current prefetch distance * the decay factor, where the decay factor is a value less than 1. The embodiment identifies the failure mode of the prefetch timing being too far in advance, and shortens the prefetch distance to reduce the storage bandwidth consumption and cache space occupation caused by invalid prefetch operations.
[0137] It should be noted that the basis for shortening the prefetch distance is the time characteristic of the host access. If the variance σ² of the request interval is large, it indicates that the access mode is unstable, and a too long prefetch distance will cause more waste, so the distance must be tightened. Conversely, when the request interval is stable and the host access rhythm is tight, the system will appropriately increase the prefetch distance, so that the prefetch operation is more in advance, and the hit rate is improved. As can be seen, the adjustment of the prefetch distance is completely driven by the dynamic characteristics of the time dimension.
[0138] S209: Evaluate and adjust the prefetch size.
[0139] In the embodiment, in response to the prefetch queue being the second prefetch queue, a prefetch data consumption rate is calculated based on the prefetch data consumption value, it is determined whether the prefetch data consumption rate is lower than a first prefetch data consumption rate threshold, in response to the prefetch data consumption rate being lower than the prefetch data consumption rate threshold, the prefetch size is reduced, in response to the prefetch data consumption rate not being lower than the prefetch data consumption rate threshold, it is determined whether the prefetch data consumption rate is higher than a second prefetch data consumption rate threshold, in response to the prefetch data consumption rate being higher than the prefetch data consumption rate threshold, the prefetch size is increased, and the second prefetch data consumption rate threshold is greater than the first prefetch data consumption rate threshold.
[0140] The prefetch distance waste rate is used to represent a space characteristic between the prefetch data and the prefetch size.
[0141] Specifically, for example, the first prefetch data consumption rate threshold is 60%, and the second prefetch data consumption rate threshold is 85%. In a detection period, the prefetch controller performs 10 prefetch operations, each time prefetching 128 KB of data, and a total of 10*128 KB=1280 KB of data is prefetched. If only 700 KB is accessed by the host, the rest is wasted in the cache. The prefetch data consumption rate = consumed data amount / total prefetch data amount = 700 KB / 1280 KB ≈ 54.7%. It is determined that the prefetch data consumption rate is less than the first prefetch data consumption rate threshold, and the new prefetch size can be adjusted to the current prefetch size-step. By reducing the amount of single prefetch, the completion speed of single prefetch can be accelerated, and the waste caused by single prefetch failure can be reduced. Similarly, if the prefetch data consumption rate is greater than the second prefetch data consumption rate threshold, the current prefetch size is increased. By increasing the amount of single prefetch, the efficiency of single input and output can be improved, the storage bandwidth can be better utilized, and the demand for higher throughput can be met.
[0142] It should be noted that the adjustment of the prefetch size is driven by the space utilization rate. If the consumption ratio is higher than the second prefetch data consumption rate threshold, it means that the prefetch block is almost fully utilized, and the prefetch size is increased to reduce the number of input and output times. The driving factor of the adjustment is the actual consumption ratio of the prefetch block, which is irrelevant to the time rhythm of the access, and can reflect the optimization idea of the space utilization rate.
[0143] In one embodiment, as Figure 4 , Figure 4 A flowchart of another data prefetching method provided by an embodiment of the present application is shown.
[0144] In the embodiment, hierarchical management of the prefetched data is performed by creating a data identifier, which includes a prefetch identifier (PrefetchFlag) for distinguishing whether the data block is generated by the prefetch engine, and a requeue identifier (RequeueFlag) for recording whether the data block has entered the requeue state.
[0145] Specifically, when the prefetch data corresponding to the sequential read stream is allocated to the prefetch queue according to the prefetch parameter, it is determined whether the prefetch data is generated by the prefetch engine. In response to the prefetch data being generated based on the prefetch engine, the prefetch identifier of the prefetch data is set to a first preset value, which can be “1”. In response to the prefetch data not being generated based on the prefetch engine, the prefetch identifier of the prefetch data is set to a second preset value, which can be “0”. It is further determined whether the prefetch data is allocated to the prefetch queue for the first time. In response to the prefetch data not being allocated to the prefetch queue for the first time, the requeue identifier of the prefetch data is set to the first preset value. In response to the prefetch data being allocated to the prefetch queue for the first time, the requeue identifier of the prefetch data is set to the second preset value.
[0146] Further, when the prefetch data is moved to the tail of the second prefetch queue, the re-queue identifier of the prefetch data is set; in response to the prefetch data being moved to the tail of the second prefetch queue, the re-queue identifier of the prefetch data is set to a first preset value; and in response to the prefetch data being accessed, the prefetch identifier of the prefetch data is cleared.
[0147] In one embodiment, a waste counter is used to record the waste data, and in response to the prefetch data being removed from any prefetch queue, the waste data is counted into the prefetch waste counter.
[0148] The present embodiment introduces a prefetch identifier and a re-queue identifier, wherein the prefetch identifier can distinguish the prefetch data from the normal data, so that the system can implement a differentiated periodic eviction policy to avoid excessive occupation of cache space by the prefetch data. The re-queue identifier records the re-queue state of the data block, and by giving the prefetch data a second chance, the risk of mistakenly deleting valid prefetch data due to temporary non-access is reduced. At the same time, in combination with the monitoring of the waste counter, the waste data of the prefetch is quantified, and the prefetch strategy is optimized, thereby achieving effective utilization of storage bandwidth and cache space.
[0149] In one embodiment, as shown in Figure 5 , a structure diagram of a data prefetching device is provided. Figure 5 The data prefetching device can include a receiving module 41, a first evaluation module 42, an allocation module 43, a first verification module 44, a second verification module 45, a second evaluation module 46, and an adjustment module 47.
[0150] The receiving module 41 is configured to generate a sequential read stream based on the order of a plurality of read requests in response to receiving the plurality of read requests.
[0151] The first evaluation module 42 is configured to evaluate a confidence score of the sequential read stream, and in response to the confidence score exceeding a confidence score threshold, generate a corresponding prefetch parameter of the sequential read stream.
[0152] The allocation module 43 is configured to allocate the prefetch data corresponding to the sequential read stream to a prefetch queue according to the prefetch parameter, wherein the prefetch queue includes at least a first prefetch queue and a second prefetch queue.
[0153] The first verification module 44 is configured to perform periodic eviction verification according to the accessed state of the prefetch data in a first period in response to the prefetch data being in the first prefetch queue.
[0154] The second verification module 45 is configured to further perform periodic eviction verification according to the accessed state of the prefetch data in a second period in response to the prefetch data being in the second prefetch queue.
[0155] The second evaluation module 46 is configured to evaluate whether there is a prefetch waste of the prefetch data in the prefetch queue.
[0156] The adjustment module 47 is configured to adjust the prefetch parameter in response to the existence of the prefetch waste.
[0157] Embodiments of the present application also provide an electronic device, comprising a memory configured to store a computer program; and a processor configured to execute the computer program to perform at least the following steps:
[0158] In response to receiving a plurality of read requests, generating a sequential read stream based on the orderliness of the plurality of read requests; evaluating a confidence score of the sequential read stream, and in response to the confidence score exceeding a confidence score threshold, generating a corresponding prefetch parameter according to the sequential read stream; assigning prefetch data corresponding to the sequential read stream to a prefetch queue according to the prefetch parameter, wherein the prefetch queue comprises at least a first prefetch queue and a second prefetch queue; in response to the prefetch data being in the first prefetch queue, performing a period eviction verification according to the accessed state of the prefetch data in a first period; in response to the prefetch data being in the second prefetch queue, performing a period eviction verification according to the accessed state of the prefetch data in a first period and a second period, wherein the second period is a period adjacent to the first period after the first period; evaluating whether there is a prefetch waste of the prefetch data in the prefetch queue; and in response to the existence of the prefetch waste, adjusting the prefetch parameter.
[0159] In one embodiment, the electronic device can be a server, and its internal structure diagram can be as shown in Figure 6 The electronic device comprises a processor, a memory, a network interface and a database connected through a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The database of the electronic device is configured to store software management data. The network interface of the electronic device is configured to communicate with external terminals through network connection.
[0160] Those skilled in the art can understand that Figure 6 The structure shown in the above
[0161] Embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to perform at least the following steps:
[0162] In response to receiving the plurality of read requests, generating a sequential read stream based on a sequentiality of the plurality of read requests; evaluating a confidence score of the sequential read stream, in response to the confidence score exceeding a confidence score threshold, generating a corresponding prefetch parameter of the sequential read stream according to the sequential read stream; assigning prefetch data corresponding to the sequential read stream to a prefetch queue according to the prefetch parameter, wherein the prefetch queue comprises at least a first prefetch queue and a second prefetch queue; in response to the prefetch data being in the first prefetch queue, performing a cycle eviction verification according to an accessed state of the prefetch data in a first cycle; in response to the prefetch data being in the second prefetch queue, performing a cycle eviction verification according to an accessed state of the prefetch data in the first cycle and a second cycle, wherein the second cycle is a cycle adjacent to the first cycle after the first cycle; evaluating whether there is a prefetch waste to the prefetch data in the prefetch queue; in response to the existence of the prefetch waste, adjusting the prefetch parameter.
[0163] In one example embodiment, the computer readable storage medium described above can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0164] Embodiments of the present application also provide a computer program product comprising a computer program which, when executed by a processor, can at least perform the following steps:
[0165] In response to receiving the plurality of read requests, generating a sequential read stream based on a sequentiality of the plurality of read requests; evaluating a confidence score of the sequential read stream, in response to the confidence score exceeding a confidence score threshold, generating a corresponding prefetch parameter of the sequential read stream according to the sequential read stream; assigning prefetch data corresponding to the sequential read stream to a prefetch queue according to the prefetch parameter, wherein the prefetch queue comprises at least a first prefetch queue and a second prefetch queue; in response to the prefetch data being in the first prefetch queue, performing a cycle eviction verification according to an accessed state of the prefetch data in a first cycle; in response to the prefetch data being in the second prefetch queue, performing a cycle eviction verification according to an accessed state of the prefetch data in the first cycle and a second cycle, wherein the second cycle is a cycle adjacent to the first cycle after the first cycle; evaluating whether there is a prefetch waste to the prefetch data in the prefetch queue; in response to the existence of the prefetch waste, adjusting the prefetch parameter.
[0166] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct RAM bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0167] It can be further realized that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be realized in electronic hardware, computer software, or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been described in general terms above. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0168] The above provides a detailed introduction to the data prefetching method and electronic device provided by the present application. The principles and implementation methods of the present application are described by applying specific examples. The above description of the embodiments is only applicable to help understand the method and its core idea of the present application. It should be pointed out that for those skilled in the art, without departing from the principles of the present application, some improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the present application.
Claims
1. A data prefetching method, characterized in that, The data prefetching method includes: In response to receiving multiple read requests, a sequential read stream is generated based on the order of the multiple read requests; The confidence score of the sequential read stream is evaluated, and in response to the confidence score exceeding a confidence score threshold, a prefetch parameter corresponding to the sequential read stream is generated, wherein the prefetch parameter includes at least a prefetch distance; The prefetched data corresponding to the sequential read stream is allocated to the prefetch queue according to the prefetch parameters, wherein the prefetch queue includes at least a first prefetch queue and a second prefetch queue; In response to the prefetch data being in the first prefetch queue, a periodic eviction verification is performed based on the access status of the prefetch data in the first period. In response to the prefetch data being in the second prefetch queue, the cycle elimination verification is performed based on the access status of the prefetch data in the first cycle and the second cycle, wherein the second cycle is the cycle following the first cycle and adjacent to the first cycle; Assess whether there is any waste in the prefetching of the prefetched data in the prefetch queue; In response to the existence of the prefetch waste, the prefetch parameters are adjusted; The step of allocating the prefetched data corresponding to the sequential read stream to the prefetch queue according to the prefetch parameters includes: Based on the prefetch distance, determine whether the prefetch distance is greater than the preset average value of the requested data; If the prefetch distance is greater than the preset average value of the requested data, the prefetch data is allocated to the first prefetch queue. If the prefetch distance is less than or equal to the preset average value of the requested data, the prefetch data is allocated to the second prefetch queue.
2. The data prefetching method according to claim 1, characterized in that, The confidence score for evaluating the sequential read stream includes: The request parameters of the read request are recorded in real time through the trajectory library, including the request time, the request start address, and the request length. The address continuity factor, timing tightness, and request size similarity factor of the sequential read stream are evaluated based on the request parameters. Assign a first weighting factor to the address continuity factor, a second weighting factor to the temporal density, and a third weighting factor to the data block similarity; The confidence score is calculated based on the address continuity factor after weighting, the temporal tightness, and the data block similarity. The evaluation of the address continuity factor, timing tightness, and request size similarity factor of the sequential read stream based on the request parameters includes: Get the starting address and length of the current read request; The end address of the current read request is obtained based on the request start address and request length; In response to the fact that the end address of the current read request is the start address of the next read request adjacent to the current read request, it is determined that the current read request and the next read request are consecutively matched; The ratio of the number of consecutive matches to the total number of requests in the trajectory database is used as the address continuity factor. The dispersion value of the request time interval of the multiple read requests is evaluated based on the request time and the total number of requests, and the dispersion value is used as the temporal tightness. Obtain the request size of the multiple read requests; Evaluate the average request size of the multiple read requests; Calculate the difference between the read request with the largest request size and the read request with the largest request size. Use the ratio of the difference to the average request size as a size evaluation factor. Determine the request size similarity factor based on the size evaluation factor.
3. The data prefetching method according to claim 2, characterized in that, The step of generating corresponding prefetch parameters based on the sequential read stream in response to the confidence score exceeding the confidence score threshold includes: A pre-set confidence assessment period is used to obtain a continuous confidence score based on the confidence assessment period. Determine whether the consecutive confidence scores for a preset number of consecutive times all exceed the confidence score threshold; In response to the fact that the consecutive confidence scores for the preset number of consecutive times all exceed the confidence score threshold, a target prefetch controller is created and configured to the sequential read stream, wherein the target prefetch controller inherits multiple request parameters from the trajectory library from the creation time of the target prefetch controller.
4. The data prefetching method according to claim 1, characterized in that, The step of allocating the prefetched data corresponding to the sequential read stream to the prefetch queue according to the prefetch parameters further includes: A preset data identifier, wherein the data identifier includes a prefetch identifier and a reentry queue identifier; Determine whether the prefetched data was generated by the prefetch engine; In response to the fact that the prefetch data is generated based on the prefetch engine, the prefetch identifier of the prefetch data is set to a first preset value; In response to the fact that the prefetched data is not generated based on the prefetch engine, the prefetch identifier of the prefetched data is set to a second preset value; Determine whether the prefetched data is allocated to the prefetch queue for the first time; In response to the fact that the prefetched data is not being allocated to the prefetch queue for the first time, the re-entry queue identifier of the prefetched data is set to the first preset value; In response to the first allocation of the prefetched data to the prefetch queue, the re-entry queue identifier of the prefetched data is set to the second preset value.
5. The data prefetching method according to claim 1, characterized in that, The periodic elimination verification includes: The prefetch queue is periodically scanned by a background detection thread to identify unaccessed prefetch data in the prefetch queue. In response to the fact that the prefetched data has not been accessed within the first period, the prefetch queue in which the prefetched data is located is determined. If the prefetch queue containing the prefetched data is the first prefetch queue, then the prefetched data is removed from the first prefetch queue. If the prefetch queue containing the prefetched data is the second prefetch queue, then the prefetched data is moved to the tail of the second prefetch queue; Determine whether the prefetched data has not been accessed within the second period; If the prefetched data has not been accessed within the second period, the prefetched data is removed from the second prefetch queue.
6. The data prefetching method according to claim 5, characterized in that, The step of moving the prefetched data to the tail of the second prefetch queue includes: Obtain the reentry queue identifier setting of the prefetched data; In response to moving the prefetched data to the tail of the second prefetch queue, the reentry queue identifier of the prefetched data is set to a first preset value; In response to the access of the prefetched data, the prefetch identifier of the prefetched data is cleared; The step of removing the prefetched data from the prefetch queue includes: Prefetch waste counter to acquire waste data; In response to removing the prefetched data from any of the prefetch queues, the wasted data is counted in the prefetch waste counter.
7. The data prefetching method according to claim 6, characterized in that, The wasted data includes prefetch distance wastage value and prefetch data consumption value. Assessing whether there is prefetch waste in the prefetch queue includes: In response to the prefetch queue being a first prefetch queue, a prefetch distance waste rate is calculated based on the prefetch distance waste value, wherein the prefetch distance waste rate is used to characterize the temporal characteristics between the prefetched data and the prefetch distance; It is determined that the prefetch distance waste rate exceeds the prefetch distance waste threshold; If the prefetch distance waste rate exceeds the prefetch distance waste threshold, the prefetch distance is shortened.
8. The data prefetching method according to claim 7, characterized in that, The assessment of whether there is prefetch waste in the prefetch queue also includes: In response to the prefetch queue being a second prefetch queue, the prefetch data consumption rate is calculated based on the prefetch data consumption value, wherein the prefetch distance waste rate is used to characterize the spatial characteristics between the prefetch data and the prefetch data size; Determine whether the prefetched data consumption rate is lower than the first prefetched data consumption rate threshold; If the prefetch data consumption rate is lower than the prefetch data consumption rate threshold, then the prefetch data size is reduced. In response to the fact that the prefetch data consumption rate is not lower than the prefetch data consumption rate threshold, it is determined whether the prefetch data consumption rate is higher than the second prefetch data consumption rate threshold. In response to the prefetch data consumption rate being higher than the prefetch data consumption rate threshold, the prefetch data size is increased, wherein the second prefetch data consumption rate threshold is greater than the first prefetch data consumption rate threshold.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data prefetching method as described in any one of claims 1 to 8 when executing the computer program.
Citation Information
Patent Citations
SYSTEM AND METHOD FOR ADAPTIVE HYBRID Hardware PREFETCHING
CN115715390A
Data cache prefetching device and method and processor
CN116244218A