A method and apparatus for determining a stream prefetch depth

CN122527042APending Publication Date: 2026-08-07HYGON INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610433514.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-02
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0004]本申请的目的在于提供一种流预取深度确定方法及装置,用于解决现有技术中流预取器的预取策略存在准确度低及浪费功率的问题

Benefits of technology

[0023]本申请提供的流预取深度确定方法及装置,通过对程序产生的历史流信息训练得到流长度预测表,利用流长度预测表确定新分配流的流长度预测信息,根据新分配流的流长度预测信息与流置信度确定预取深度,能够解决高置信度短流产生较多无用预取的问题,减少无用数据的预取,降低功耗浪费,提高预取准确度,进而提高带宽利用率和整体CPU性能。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122527042A_ABST
    Figure CN122527042A_ABST
Patent Text Reader

Abstract

The application relates to the field of stream prefetching, and provides a stream prefetching depth determination method and device. The method comprises the following steps: training a stream length prediction table according to historical stream information; the stream length prediction table records the association relationship between stream indexes and stream length characteristic information; determining stream length prediction information of a newly allocated stream according to the stream length prediction table; and determining a prefetching depth according to the stream length prediction information of the newly allocated stream and stream confidence. The application can solve the problem that a high-confidence short stream generates more useless prefetching, reduce useless data prefetching, reduce power consumption waste, improve prefetching accuracy, and further improve bandwidth utilization and overall CPU performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of stream prefetching, and particularly relates to a method and apparatus for determining stream prefetch depth. Background Technology

[0002] With the rapid development of processor technology, the speed gap between processors and memory continues to widen, and memory access latency (which typically requires hundreds of processor cycles) has become a key bottleneck restricting processor performance. While caching, as a core component to alleviate this gap, can reduce the number of memory accesses, its limited capacity often means that the application's working set cannot be fully loaded into the cache, still frequently triggering memory accesses.

[0003] Prefetching, as another core optimization technique, effectively reduces memory access latency by loading data / instructions into the cache before they are actually used. Existing data prefetching methods are based on the regularity and correlation of missing block addresses. Among them, stream prefetchers capture consecutive missing sequences (i.e., "streams") within a memory region, prefetching consecutive blocks in the same direction. Their simplicity and effectiveness have led to their application in commercial processors. In existing technologies, stream prefetchers typically determine the prefetch depth based on stream confidence; higher confidence results in a larger prefetch depth. This prefetching method allocates a large prefetch depth when there are many short, high-confidence streams in the program, leading to useless prefetching, reduced accuracy of the stream prefetcher, and wasted power. Summary of the Invention

[0004] The purpose of this application is to provide a method and apparatus for determining the prefetch depth of a stream, which solves the problems of low accuracy and wasted power in the prefetch strategy of the existing stream prefetcher.

[0005] To address the aforementioned technical problems, the first aspect of this application provides a method for determining stream prefetch depth, comprising: Based on historical flow information, a flow length prediction table is trained; the flow length prediction table records the correlation between flow index and flow length feature information. Based on the flow length prediction table, determine the flow length prediction information for the newly allocated flow; The prefetch depth is determined based on the predicted flow length and flow confidence of the newly allocated flow.

[0006] As a further embodiment of this application, the flow prefetch depth determination method further includes: obtaining the historical flow information in the following manner; Retrieve information about streams removed from the stream prefetcher's stream table; The removed stream information constitutes historical stream information.

[0007] In a further embodiment of this application, the training stream length prediction table, based on historical stream information, includes: For each historical stream information obtained, perform the following operations on that historical stream information: Extract the stream length from the historical stream information; Determine the first stream index based on the stream length; Update the flow length prediction table based on the first flow index.

[0008] In a further embodiment of this application, updating the flow length prediction table based on the first flow index includes: Detect whether the first flow index is included in the flow length prediction table; If the first flow index is not included in the flow length prediction table, then the first flow length feature information is determined; the first flow index and the first flow length feature information are associated and stored in the flow length prediction table; If the flow length prediction table includes the first flow index, then the newly associated first flow length feature information of the first flow index is calculated based on the first flow length feature information already associated with the first flow index; the first flow length feature information already associated with the first flow index in the flow length prediction table is updated to the newly associated first flow length feature information of the first flow index.

[0009] In a further embodiment of this application, the first stream index is a stream length level, and the first stream length feature information is the number of times the stream length level appears or the distribution ratio of the stream length level.

[0010] In a further embodiment of this application, determining the flow length prediction information of the newly allocated flow based on the flow length prediction table includes: Determine the maximum value of the number of times a flow length level occurs or the percentage of the flow length level distribution from the flow length prediction table; The flow length level associated with the maximum value is determined as the flow length prediction information for the newly assigned flow.

[0011] In a further embodiment of this application, the training stream length prediction table, based on historical stream information, includes: Extract the second stream index and stream length from the historical stream information; Update the flow length prediction table based on the second flow index and the flow length.

[0012] In a further embodiment of this application, updating the flow length prediction table based on the second flow index and the flow length includes: Detect whether the flow length prediction table includes the second flow index; If the second flow index is not included in the flow length prediction table, then the second flow length feature information is determined based on the flow length, and the second flow index and the second flow length feature information are associated and stored in the flow length prediction table; If the flow length prediction table includes the second flow index, then based on the flow length and the second flow length feature information already associated with the second flow index, the newly associated second flow length feature information of the second flow index is calculated; the second flow length feature information already associated with the second flow index in the flow length prediction table is updated to the newly associated second flow length feature information of the second flow index.

[0013] In a further embodiment of this application, the second stream index is a preset feature, and the second stream length feature information is the stream length.

[0014] In a further embodiment of this application, based on the flow length and the second flow length feature information already associated with the second flow index, the newly associated second flow length feature information of the second flow index is calculated, including: The average length of the stream and the lengths of the streams already associated with the second stream index are calculated to obtain the new length of the stream associated with the second stream index; or The stream length is determined as the stream length newly associated with the second stream index.

[0015] In a further embodiment of this application, determining the flow length prediction information of the newly allocated flow based on the flow length prediction table includes: Match the second flow index of the newly allocated flow with the flow length prediction table; Based on the flow length feature information associated with the second flow index of the newly allocated flow, the flow length prediction information of the newly allocated flow is determined.

[0016] In a further embodiment of this application, determining the prefetch depth based on the flow length prediction information and flow confidence of the newly allocated flow includes: Based on the predicted flow length information of the newly allocated flow, the flow length level of the newly allocated flow is determined; Based on the flow confidence of the newly allocated flow, determine the flow confidence level of the newly allocated flow; The prefetch depth is determined based on the flow length level and flow confidence level of the newly allocated flow.

[0017] In a further embodiment of this application, determining the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow includes: Calculate the prefetch coefficients based on the flow length level and flow confidence level of the newly allocated flow; The prefetch depth is determined based on the prefetch coefficient.

[0018] In a further embodiment of this application, the prefetch coefficient is calculated based on the flow length level and flow confidence level of the newly allocated flow, including: Based on the flow length level and flow confidence level of the newly allocated flow, calculate the prefetch coefficients using at least one of the following operations: The minimum of the flow length level and flow confidence of the newly allocated flow is taken as the prefetch coefficient; The newly allocated flow length level and flow confidence are weighted and averaged, and the weighted average is used as the prefetch coefficient.

[0019] A second aspect of this application provides a stream prefetch depth determination apparatus, comprising: The training unit is used to train a flow length prediction table based on historical flow information; the flow length prediction table records the correlation between flow index and flow length feature information. The prediction unit is used to determine the flow length prediction information of the newly allocated flow based on the flow length prediction table. The calculation unit is used to determine the prefetch depth based on the flow length prediction information and flow confidence of the newly allocated flow.

[0020] A third aspect of this application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the methods described in any of the foregoing embodiments.

[0021] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor of a computer device, implements the methods described in any of the foregoing embodiments.

[0022] The fifth aspect of this application provides a computer program product, the computer program product including a computer program that, when executed by a processor of a computer device, implements the method described in any of the foregoing embodiments.

[0023] The method and apparatus for determining the flow prefetch depth provided in this application obtain a flow length prediction table by training on historical flow information generated by the program, determine the flow length prediction information of newly allocated flows using the flow length prediction table, and determine the prefetch depth based on the flow length prediction information of newly allocated flows and flow confidence. This can solve the problem of a lot of useless prefetching generated by short flows with high confidence, reduce the prefetching of useless data, reduce power consumption waste, improve prefetch accuracy, and thus improve bandwidth utilization and overall CPU performance.

[0024] To make the above and other objects, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1 A structural diagram of the stream prefetch depth determination system according to an embodiment of this application is shown; Figure 2A A flowchart illustrating the interaction process of the stream prefetch depth determination system according to an embodiment of this application is shown. Figure 2B Another flowchart of the interaction process of the stream prefetch depth determination system according to an embodiment of this application is shown; Figure 3 A flowchart of a stream prefetch depth determination method according to an embodiment of this application is shown; Figure 4 A first flowchart of an embodiment of this application is shown, illustrating the training of a flow length prediction table based on historical flow information. Figure 5 A first flowchart of an embodiment of this application for updating the flow length prediction table is shown; Figure 6 A first flowchart illustrating the process of determining the flow length prediction information of a newly allocated flow according to an embodiment of this application is shown. Figure 7 A second flowchart illustrating the training of a flow length prediction table based on historical flow information according to an embodiment of this application is shown. Figure 8 A second flowchart of an embodiment of this application for updating the flow length prediction table is shown; Figure 9 A second flowchart illustrating the process of determining the flow length prediction information of a newly allocated flow according to an embodiment of this application is shown. Figure 10 This document illustrates a flowchart of the process for determining the prefetch depth based on the flow length prediction information and flow confidence of the newly allocated flow, according to an embodiment of this application. Figure 11 A flowchart illustrating the process of determining the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow, according to an embodiment of this application, is shown. Figure 12 A structural diagram of a flow prefetch depth determination apparatus according to an embodiment of this application is shown; Figure 13 A structural diagram of a computer device according to an embodiment of this application is shown.

[0027] Explanation of symbols in the attached drawings: 1201, Training Unit; 1202, Prediction Unit; 1203, Calculation Unit; 1204. Acquisition Unit; 1302. Computer equipment; 1304, Processor; 1306. Memory; 1308. Drive mechanism; 1310. Input / output module; 1312. Input devices; 1314. Output devices; 1316. Presentation equipment; 1318. Graphical User Interface; 1320. Network interface; 1322. Communication link; 1324. Communication bus. Detailed Implementation

[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, apparatus, product, or device that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.

[0030] This specification provides the operational steps of the methods described in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only possible execution order. In actual system or device products, the methods shown in the embodiments or drawings can be executed sequentially or in parallel.

[0031] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.

[0032] The following explains some of the technical terms related to this application.

[0033] Stream prefetcher: A hardware prefetching mechanism and a key component of the processor cache subsystem. Its core function is to identify continuous or regular memory access patterns (i.e., stream access) in a program and preload subsequent cache lines (typically 64 bytes) from slow memory into faster caches before the data is actually requested. Slow memory includes, for example, main memory / DRAM, and faster caches include, for example, L1 / L2 / L3 caches.

[0034] The method for stream prefetchers to identify continuous or regular memory access characteristics in a program is as follows: Monitor the processor's memory access address sequence and extract flow patterns based on the access address sequence. Examples include continuous address access, fixed-step access, and multi-dimensional stream access. Model the identified flow characteristics, use the established model to predict the data address the processor will access next, and proactively send a read request to memory based on the predicted data address, loading the prefetched data into the cache closest to the processor.

[0035] Stream length: In a stream prefetcher, stream length typically refers to the amount of data that a program continuously accesses during memory access. It is usually measured in cache lines.

[0036] Stream confidence: This is a quantitative confidence metric assigned by the stream prefetcher to the detected memory access sequences. It is used to evaluate whether each memory access sequence is a real, continuous, and valid stream pattern. After the stream prefetcher is trained, it can determine the confidence of the streams associated with each stream index.

[0037] Prefetch depth: The predetermined number of cache lines before the data currently loaded by the processing system. In a stream prefetcher, prefetch depth refers to the number of cache lines that the processor will automatically prefetch after the stream training is successful.

[0038] Existing stream prefetching techniques typically set a fixed prefetch depth based on stream confidence. Higher confidence results in a deeper prefetch, and lower confidence in a shallower prefetch. When a program contains a large number of short streams with high confidence (where short-circuit refers to streams shorter than a preset value), using stream confidence to determine the prefetch depth can lead to useless prefetching, reduced prefetcher accuracy, and wasted power. For example, for a short stream with a length of 100, if the maximum confidence corresponds to a prefetch depth of 50, then the last 50 prefetches will be useless, resulting in a prefetch accuracy of approximately 66%. Specifically, assuming the first access of this stream is A, the last access is A+100. With a prefetch depth of 50, this will result in A+150 accesses. Since there are no actual accesses from A+101 to A+150, this part of the prefetching is wasted. That is, 150 prefetches were issued, of which 50 were invalid and 100 were valid. Prefetch accuracy = valid prefetch count / total prefetch count, so the accuracy is 100 / 150. 100% = 66%. Furthermore, prefetching between A+101 and A150 will also be triggered by other accesses in the stream.

[0039] To address the issues of low accuracy and wasted power in existing flow prefetching strategies, this application trains the program with historical flow information and uses the training results to predict the flow length characteristics of newly allocated flows. When triggering prefetching, the prefetch depth is determined based on the predicted flow length characteristics and flow confidence, thereby reducing useless prefetching, lowering power consumption, improving prefetch accuracy, and ultimately enhancing bandwidth utilization and overall CPU performance.

[0040] In some embodiments, a prefetch depth determination system is provided, such as Figure 1 As shown, the prefetch depth determination system includes a flow prefetcher 101 and a prefetch depth determination device 102.

[0041] The stream prefetcher 101 is used to provide historical stream information.

[0042] The prefetch depth determination device 102 is used to train a flow length prediction table based on historical flow information, wherein the flow length prediction table records the correlation between flow index and flow length feature information; determine the flow length prediction information of newly allocated flows based on the flow length prediction table; and determine the prefetch depth based on the flow length prediction information of newly allocated flows and flow confidence.

[0043] Historical flow information refers to the flow information successfully trained in the flow prefetcher. Historical flow information includes at least the flow length. It may also include predefined features, prefetch count, flow confidence, and the address of the most recent access. Predicted features include, but are not limited to, program counter (pc) and region addresses.

[0044] In some implementations, the flow index is the flow length level, and the flow length feature information is the frequency of occurrence of the flow length level or the distribution ratio of the flow length level. Correspondingly, the flow length prediction information is the flow length level.

[0045] In some implementations, the flow index is a preset feature, and the flow length feature information is the flow length. Correspondingly, the flow length prediction information is the flow length.

[0046] When the flow index is a flow length level and the flow length feature information is the number of times the flow length level appears, such as Figure 2A As shown, the process of determining the prefetch depth based on the prefetch depth determination system includes: Step 211, the flow prefetcher 101 removes the historical flow information that was successfully trained in the flow table to the prefetch depth determination device 102.

[0047] Step 212: The prefetch depth determination device 102 extracts the flow length from the historical flow information; determines the flow length level of the historical flow information based on the flow length of the historical flow information; and updates the flow length prediction table based on the flow length level of the historical flow information.

[0048] This includes updating the flow length prediction table based on the flow length levels of historical flow information, including: Check whether the flow length prediction table includes the flow length level (abbreviated as the flow length level) of historical flow information. If the flow length prediction table does not include the flow length level, it means that the flow length prediction table has not yet learned the knowledge related to the flow length level. In this case, the occurrence count of the flow length level is determined to be 1. The flow length level and the occurrence count of the flow length level are associated and stored in the flow length prediction table. If the flow length prediction table includes the flow length level, it means that the flow length prediction table has learned the knowledge related to the flow length level. In this case, the number of occurrences associated with the flow length level in the flow length prediction table is incremented by 1.

[0049] Step 213, the stream prefetcher 101 sends the stream confidence information of the newly allocated stream to the depth determination device 102.

[0050] Step 214: The depth determination device 102 determines the maximum number of occurrences of the flow length level from the flow length prediction table; and determines the flow length level associated with the maximum value as the flow length level of the newly allocated flow.

[0051] Step 215: The depth determination device 102 determines the prefetch depth based on the flow length level and flow confidence of the newly allocated flow.

[0052] When implementing this step, first determine the flow confidence level of the newly allocated flow based on the flow confidence level of the newly allocated flow; finally, determine the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow.

[0053] The process of determining the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow includes: calculating the prefetch coefficient based on the flow length level and flow confidence level of the newly allocated flow; and determining the prefetch depth based on the prefetch coefficient.

[0054] The prefetching coefficients are calculated based on the flow length level and flow confidence level of the newly allocated flow, including: Calculate the prefetch coefficients using at least one of the following operations, based on the flow length level and flow confidence level of the newly allocated flow: The minimum of the flow length level and flow confidence of the newly assigned flow is taken as the prefetch coefficient; The flow length level and flow confidence of the newly allocated flow are weighted and averaged, and the weighted average is used as the prefetch coefficient.

[0055] The prefetch depth is determined based on the prefetch coefficient, including at least one of the following methods: The prefetch depth is obtained by multiplying the prefetch factor by the unit prefetch depth; Based on the prefetch coefficients, query the mapping relationship between the preset prefetch coefficients and the prefetch depth to obtain the prefetch depth associated with the prefetch coefficients.

[0056] When the stream index is a preset feature and the stream length feature information is the stream length, such as Figure 2B As shown, the process of determining the prefetch depth based on the prefetch depth determination system includes: Step 221, the flow prefetcher 101 removes the historical flow information that was successfully trained in the flow table to the prefetch depth determination device 102.

[0057] Step 222: The pre-fetch depth determination device 102 extracts preset features and flow length from historical flow information; and updates the flow length prediction table based on the preset features and flow length of historical flow information.

[0058] This includes updating the flow length prediction table based on preset features and flow lengths of historical flow information, including: Check whether the flow length prediction table includes preset features of historical flow information; If the preset features of historical flow information are not included in the flow length prediction table, then the preset features of historical flow information and flow length are associated and stored in the flow length prediction table; If the flow length prediction table includes preset features of historical flow information, then the new flow length is calculated based on the flow length of the historical flow information and the flow length associated with the preset feature; the flow length associated with the preset feature in the flow length prediction table is updated to the new flow length.

[0059] Specifically, the new flow length is calculated based on the flow length of historical flow information and the flow length associated with preset features, including calculating the new flow length using at least one of the following methods: Method 1: Average the length of historical stream information with the length of streams associated with preset features to obtain a new stream length.

[0060] Method 2: Determine the length of the historical stream information as the new stream length.

[0061] The following example, using the preset feature pc and the new flow length calculated in method two, illustrates the flow length training process: The flow length prediction table entry contains pc and the flow length training result of pc. When a flow of pc1 is removed from the flow table, the flow length 'a' of this flow is obtained, and pc1 and 'a' are recorded in the flow length prediction table. When another flow of pc1 is removed from the flow table, and the flow length of this flow is 'b', the flow length prediction table is updated using pc1 and 'b', that is, 'a' corresponding to pc1 in the flow length prediction table is replaced with 'b'.

[0062] Step 223, the stream prefetcher 101 sends the stream confidence information of the newly allocated stream to the depth determination device 102.

[0063] Step 224: The depth determination device 102 matches the preset characteristics of the newly allocated flow with the flow length prediction table; then it assigns the flow length associated with the preset characteristics of the newly allocated flow to the newly allocated flow.

[0064] For example, the flow length prediction table is shown in Table 1 below.

[0065] Table 1

[0066] Assuming the flow index of the newly allocated flow is A2, this step will determine that the flow length of the newly allocated flow A2 is B2.

[0067] Step 225: The depth determination device 102 determines the prefetch depth based on the flow length of the newly allocated flow and the flow confidence of the newly allocated flow.

[0068] In this step, first, the flow length level of the newly allocated flow is determined based on the flow length of the newly allocated flow; then, the flow confidence level of the newly allocated flow is determined based on the flow confidence level of the newly allocated flow; finally, the prefetch depth is determined based on the flow length level and flow confidence level of the newly allocated flow.

[0069] Specifically, the mapping relationship between the flow length range and the flow length level can be predetermined, for example, including n flow length levels L1~Ln, each flow length level corresponding to a prefetch depth.

[0070] Similarly, the mapping relationship between the stream confidence range and the stream confidence level can be predetermined, for example, including n stream confidence levels S1-Sn, with each stream confidence level corresponding to a prefetch depth.

[0071] In some embodiments, determining the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow includes: calculating a prefetch coefficient based on the flow length level and flow confidence level of the newly allocated flow; and determining the prefetch depth based on the prefetch coefficient.

[0072] The prefetching coefficients are calculated based on the flow length level and flow confidence level of the newly allocated flow, including: Calculate the prefetch coefficients using at least one of the following operations, based on the flow length level and flow confidence level of the newly allocated flow: The minimum of the flow length level and flow confidence of the newly assigned flow is taken as the prefetch coefficient; The flow length level and flow confidence of the newly allocated flow are weighted and averaged, and the weighted average is used as the prefetch coefficient.

[0073] The prefetch depth is determined based on the prefetch coefficient, including at least one of the following methods: The prefetch depth is obtained by multiplying the prefetch factor by the unit prefetch depth; Based on the prefetch coefficients, query the mapping relationship between the preset prefetch coefficients and the prefetch depth to obtain the prefetch depth associated with the prefetch coefficients.

[0074] This embodiment can solve the problem of a lot of useless prefetching generated by high-confidence short flows, reduce the prefetching of useless data, reduce power consumption waste, improve prefetch accuracy, improve bandwidth utilization and overall CPU performance.

[0075] In some embodiments, a method for determining the stream prefetch depth is also provided, such as Figure 3 As shown, it includes: Step 301: Train a flow length prediction table based on historical flow information; the flow length prediction table records the correlation between flow index and flow length feature information.

[0076] Step 302: Determine the flow length prediction information for the newly allocated flow based on the flow length prediction table.

[0077] Step 303: Determine the prefetch depth based on the predicted flow length and flow confidence of the newly allocated flow.

[0078] In this application, the flow length prediction information for the newly allocated flow refers to the information predicted using the flow length prediction table for the newly allocated flow.

[0079] This embodiment utilizes historical flow information to train a flow length prediction table, enabling the prediction of the flow length of newly allocated flows. When determining the prefetch depth of a newly allocated flow, in addition to considering the flow confidence level, the flow length characteristics of the newly allocated flow are also taken into account. This makes the prefetch depth more consistent with reality, solving the problem of high-confidence short flows generating a lot of useless prefetching, reducing the prefetching of useless data, lowering power consumption waste, and thus improving prefetch accuracy, bandwidth utilization, and overall CPU performance.

[0080] In some embodiments, the flow prefetch depth determination scheme further includes: obtaining historical flow information in the following manner; Obtain the flow information removed from the flow table of the flow prefetcher; the removed flow information constitutes the historical flow information.

[0081] The length of the stream removed in the stream prefetcher remains essentially unchanged, which matches the actual stream length. In this embodiment, the accuracy of the stream length prediction table can be improved by using the stream information removed by the stream prefetcher to train the stream length prediction table.

[0082] In some embodiments, such as Figure 4 As shown, step 301 trains a flow length prediction table based on historical flow information, including: Step 401: Extract the stream length from the historical stream information.

[0083] Step 402: Determine the first stream index based on the stream length.

[0084] Step 403: Update the flow length prediction table based on the first flow index.

[0085] In some embodiments, such as Figure 5 As shown, step 403 updates the stream length prediction table based on the first stream index, including: Step 501: Check whether the first flow index is included in the flow length prediction table.

[0086] Step 502: If the first flow index is not included in the flow length prediction table, then determine the first flow length feature information; associate the first flow index and the first flow length feature information and store them in the flow length prediction table.

[0087] Step 503: If the flow length prediction table includes the first flow index, calculate the newly associated first flow length feature information based on the first flow length feature information already associated with the first flow index; update the first flow length feature information already associated with the first flow index in the flow length prediction table to the newly associated first flow length feature information.

[0088] Initially, the flow index and flow length fields in the flow length prediction table are empty. Step 502 adds incremental flow index-related flow length feature information to the flow length prediction table. Step 503 updates the flow length prediction table using the newly added historical flow index and flow length feature information. This embodiment can establish a comprehensive and highly accurate flow length prediction table.

[0089] In some embodiments, the flow index in the flow length prediction table is the flow length level, and the flow length feature information in the flow length prediction table is the frequency of occurrence of the flow length level or the distribution ratio of the flow length level. Correspondingly, the first flow index is the flow length level, the first flow length feature information is the frequency of occurrence of the flow length level or the distribution ratio of the flow length level, and the flow length prediction information is the flow length level.

[0090] Furthermore, such as Figure 6 As shown, step 302 determines the flow length prediction information of the newly allocated flow based on the flow length prediction table, including: Step 601: Determine the maximum value of the number of times the flow length level occurs or the distribution percentage of the flow length level from the flow length prediction table.

[0091] Step 602: Determine the flow length level associated with the maximum value as the flow length prediction information for the newly allocated flow.

[0092] In some embodiments, such as Figure 7 As shown, step 301 trains a flow length prediction table based on historical flow information, including: Step 701: Extract the second stream index and stream length from the historical stream information.

[0093] Step 702: Update the flow length prediction table based on the second flow index and the flow length.

[0094] In some embodiments, such as Figure 8 As shown, step 702 updates the flow length prediction table based on the second flow index and the flow length, including: Step 801: Detect whether the flow length prediction table includes the second flow index.

[0095] Step 802: If the flow length prediction table does not include the second flow index, then determine the second flow length feature information based on the flow length, associate the second flow index and the second flow length feature information and store them in the flow length prediction table.

[0096] Step 803: If the flow length prediction table includes a second flow index, then calculate the newly associated second flow length feature information of the second flow index based on the flow length and the second flow length feature information already associated with the second flow index; update the second flow length feature information already associated with the second flow index in the flow length prediction table to the newly associated second flow length feature information of the second flow index.

[0097] Initially, the flow index and flow length fields in the flow length prediction table are empty. Step 802 adds incremental flow index-related flow length feature information to the flow length prediction table. Step 803 updates the flow length prediction table using the newly added historical flow index and flow length feature information. This embodiment can establish a comprehensive and highly accurate flow length prediction table.

[0098] In some embodiments, the flow index in the flow length prediction table is a preset feature, and the flow length feature information in the flow length prediction table is the flow length. Correspondingly, the second flow index is a preset feature, the second flow length feature information is the flow length, and the flow length prediction information is the flow length.

[0099] Further, step 803 calculates the newly associated second flow length feature information of the second flow index based on the flow length and the second flow length feature information already associated with the second flow index, including: The average length of the current stream and the current stream length associated with the second current stream index are used to obtain the new current stream length associated with the second current stream index; or, the current stream length is determined as the new current stream length associated with the second current stream index.

[0100] like Figure 9 As shown, step 302 determines the flow length prediction information of the newly allocated flow based on the flow length prediction table, including: Step 901: Match the flow index of the newly allocated flow with the flow length prediction table.

[0101] Step 902: Determine the predicted flow length information of the newly allocated flow based on the flow length feature information associated with the flow index of the newly allocated flow.

[0102] In some embodiments, such as Figure 10 As shown, step 303 determines the prefetch depth based on the predicted flow length and flow confidence of the newly allocated flow, including: Step 1001: Determine the flow length level of the newly allocated flow based on the flow length prediction information of the newly allocated flow.

[0103] Step 1002: Determine the flow confidence level of the newly allocated flow based on the flow confidence of the newly allocated flow.

[0104] Step 1003: Determine the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow.

[0105] In some implementations, the flow length levels and flow confidence levels are classified in the same way, and the level values ​​are the same. For example, the flow length levels include three levels: Level 1, Level 2, and Level 3. Level 1 corresponds to a prefetch depth of A, Level 2 corresponds to a prefetch depth of B, and Level 3 corresponds to a prefetch depth of C. The confidence levels also include three levels: Level 1, Level 2, and Level 3. Level 1 corresponds to a prefetch depth of A, Level 2 corresponds to a prefetch depth of B, and Level 3 corresponds to a prefetch depth of C.

[0106] This embodiment determines the flow length level and flow confidence level, and then determines the prefetch depth based on the flow length level and flow confidence level, thereby achieving the unification of flow length and flow confidence and improving the accuracy of prefetch depth determination.

[0107] In some embodiments, such as Figure 11 As shown, step 1003 determines the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow, including: Step 1101: Calculate the prefetch coefficients based on the flow length level and flow confidence level of the newly allocated flow.

[0108] Step 1102: Determine the prefetch depth based on the prefetch coefficient.

[0109] During this step, the prefetch depth can be obtained by multiplying the prefetch coefficient by the unit prefetch depth. Alternatively, the mapping relationship between the preset prefetch coefficient and the prefetch depth can be queried based on the prefetch coefficient to obtain the prefetch depth associated with the prefetch coefficient.

[0110] In some implementations, step 1101 calculates prefetch coefficients based on the flow length level and flow confidence level of the newly allocated flow, including: Calculate the prefetch coefficients using at least one of the following operations, based on the flow length level and flow confidence level of the newly allocated flow: The minimum of the flow length level and flow confidence of the newly assigned flow is taken as the prefetch coefficient; The flow length level and flow confidence of the newly allocated flow are weighted and averaged, and the weighted average is used as the prefetch coefficient.

[0111] This embodiment uses the minimum of the flow length level and the flow confidence as the prefetch coefficient, or the weighted average of the flow length level and the flow confidence as the prefetch coefficient. This balances the difference between the flow length level and the flow confidence, making the prefetch length determined based on the prefetch coefficient more consistent with the actual situation, reducing useless prefetching, reducing power consumption waste, improving prefetch accuracy, improving bandwidth utilization and overall CPU performance.

[0112] Based on the same inventive concept, this application also provides a flow prefetch depth determination apparatus, as described in the following embodiments. Since the principle of the flow prefetch depth determination apparatus in solving the problem is similar to that of the flow prefetch depth determination method, the implementation of the flow prefetch depth determination apparatus can refer to the flow prefetch depth determination method, and repeated details will not be elaborated further.

[0113] Figure 12 A structural diagram of the flow prefetch depth determination apparatus according to an embodiment of this application is shown, as follows: Figure 12 As shown, the flow prefetching depth determination device includes: Training unit 1201 is used to train a flow length prediction table based on historical flow information. The flow length prediction table records the correlation between flow index feature information and flow length.

[0114] The prediction unit 1202 is used to determine the flow length prediction information of the newly allocated flow based on the flow length prediction table.

[0115] The calculation unit 1203 is used to determine the prefetch depth based on the flow length prediction information and flow confidence of the newly allocated flow.

[0116] This embodiment obtains a flow length prediction table by training on historical flow information generated by the program, uses the flow length prediction table to predict the flow length prediction information of newly allocated flows, and determines the prefetch depth based on the flow length prediction information of newly allocated flows and flow confidence. This can solve the problem of a lot of useless prefetching generated by short flows with high confidence, reduce the prefetching of useless data, reduce power consumption waste, improve prefetch accuracy, improve bandwidth utilization and overall CPU performance.

[0117] In some embodiments, such as Figure 12 As shown, the flow prefetching depth determination device also includes: The acquisition unit 1204 is used to acquire the flow information removed from the flow table of the flow prefetcher; the removed flow information constitutes the historical flow information.

[0118] In some embodiments, the training unit 1201 trains a stream length prediction table based on historical stream information, including: For each historical stream information obtained, perform the following operations on that historical stream information: Extract the stream length from the historical stream information; determine the first stream index based on the stream length; update the stream length prediction table based on the first stream index.

[0119] Training unit 1201 updates the stream length prediction table based on the first stream index, including: Check if the first flow index is included in the flow length prediction table; If the first flow index is not included in the flow length prediction table, then the first flow length feature information is determined; the first flow index and the first flow length feature information are associated and stored in the flow length prediction table; If the flow length prediction table includes a first flow index, then the newly associated first flow length feature information of the first flow index is calculated based on the first flow length feature information already associated with the first flow index; the first flow length feature information already associated with the first flow index in the flow length prediction table is updated to the newly associated first flow length feature information of the first flow index.

[0120] In some implementations, the flow index in the flow length prediction table is the flow length level, and the flow length feature information in the flow length prediction table is the frequency of occurrence of the flow length level or the distribution ratio of the flow length level. Correspondingly, the first flow index is the flow length level, the first flow length feature information is the frequency of occurrence of the flow length level or the distribution ratio of the flow length level, and the flow length prediction information is the flow length level.

[0121] Prediction unit 1202 determines the flow length prediction information of the newly allocated flow based on the flow length prediction table, including: Determine the maximum value of the frequency of occurrence of a flow length level or the maximum percentage of the flow length level distribution from the flow length prediction table; determine the flow length level associated with the maximum value as the flow length prediction information for newly assigned flows.

[0122] In some embodiments, the training unit 1201 trains a stream length prediction table based on historical stream information, including: Extract the second stream index and stream length from the historical stream information; update the stream length prediction table based on the second stream index and stream length.

[0123] Training unit 1201 updates the flow length prediction table based on the second flow index and the flow length, including: Check if the second flow index is included in the flow length prediction table; If the flow length prediction table does not include the second flow index, then the second flow length feature information is determined based on the flow length, and the second flow index and the second flow length feature information are associated and stored in the flow length prediction table; If the flow length prediction table includes a second flow index, then based on the flow length and the second flow length feature information already associated with the second flow index, the newly associated second flow length feature information of the second flow index is calculated; the second flow length feature information already associated with the second flow index in the flow length prediction table is updated to the newly associated second flow length feature information of the second flow index.

[0124] In some implementations, the flow index in the flow length prediction table is a preset feature, and the flow length feature information in the flow length prediction table is the flow length. Correspondingly, the second flow index is a preset feature, the second flow length feature information is the flow length, and the flow length prediction information is the flow length.

[0125] Training unit 1201 calculates the newly associated second flow length feature information of the second flow index based on the flow length and the second flow length feature information already associated with the second flow index, including: The average length of the current stream and the current stream length associated with the second current stream index are used to obtain the new current stream length associated with the second current stream index; or, the current stream length is determined as the new current stream length associated with the second current stream index.

[0126] Prediction unit 1202 determines the flow length prediction information of the newly allocated flow based on the flow length prediction table, including: The flow index of the newly allocated flow is matched with the flow length prediction table; the flow length prediction information of the newly allocated flow is determined based on the flow length feature information associated with the flow index of the newly allocated flow.

[0127] In some embodiments, the calculation unit 1203 determines the prefetch depth based on the flow length prediction information and flow confidence of the newly allocated flow, including: Based on the predicted flow length information of the newly allocated flow, determine the flow length level of the newly allocated flow; Determine the flow confidence level of the newly allocated flow based on its flow confidence. The prefetch depth is determined based on the flow length level and flow confidence level of the newly allocated flow.

[0128] In some embodiments, the calculation unit 1203 determines the prefetch depth based on the flow length level and flow confidence level of the newly allocated flow, including: Calculate the prefetch coefficients based on the flow length level and flow confidence level of the newly allocated flow; The prefetch depth is determined based on the prefetch coefficient.

[0129] In some embodiments, the calculation unit 1203 calculates prefetch coefficients based on the flow length level and flow confidence level of the newly allocated flow, including: Calculate the prefetch coefficients using at least one of the following operations, based on the flow length level and flow confidence level of the newly allocated flow: The minimum of the flow length level and flow confidence of the newly assigned flow is taken as the prefetch coefficient; The flow length level and flow confidence of the newly allocated flow are weighted and averaged, and the weighted average is used as the prefetch coefficient.

[0130] In some embodiments of this application, a computer device is also provided, such as Figure 13As shown, computer device 1302 may include one or more processors 1304, such as one or more central processing units (CPUs), each of which may implement one or more hardware threads. Computer device 1302 may also include any memory 1306 for storing information of any kind, such as code, settings, data, etc. Non-limitingly, for example, memory 1306 may include any type of RAM, any type of ROM, flash memory, hard disk, optical disk, etc. More generally, any memory can use any technology to store information. Furthermore, any memory may provide volatile or non-volatile retention of information. Furthermore, any memory may represent a fixed or removable component of computer device 1302. In one case, when processor 1304 executes associated instructions stored in any memory or combination of memories, computer device 1302 may perform any operation of the associated instructions. Computer device 1302 also includes one or more drive mechanisms 1308 for interacting with any memory, such as hard disk drive mechanisms, optical disk drive mechanisms, etc. In one case, the memory 1306 stores a computer program, and when the processor 1304 executes the computer program, it implements the method described in any of the foregoing embodiments.

[0131] Computer device 1302 may also include an input / output module 1310 (I / O) for receiving various inputs (via input device 1312) and providing various outputs (via output device 1314). A specific output mechanism may include a presentation device 1316 and an associated graphical user interface (GUI) 1318. In other embodiments, the input / output module 1310 (I / O), input device 1312, and output device 1314 may be omitted, and the device may function solely as a computer device within a network. Computer device 1302 may also include one or more network interfaces 1320 for exchanging data with other devices via one or more communication links 1322. One or more communication buses 1324 couple the components described above together.

[0132] Communication link 1322 can be implemented in any way, such as via a local area network, a wide area network (e.g., the Internet), a point-to-point connection, or any combination thereof. Communication link 1322 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.

[0133] In some embodiments, a computer-readable storage medium, such as a non-transient computer-readable storage medium, is also provided, on which a computer program is stored, which, when executed by a processor, performs the steps of the above-described method.

[0134] In some embodiments, a computer program product is also provided, the computer program product including a computer program that, when executed by a processor of a computer device, performs the steps of the above-described method.

[0135] In some embodiments, a computer-readable instruction is also provided, wherein when the processor executes the instruction, the program therein causes the processor to perform the steps of the method described above.

[0136] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0137] It should also be understood that, in the embodiments of this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this application generally indicates that the preceding and following related objects have an "or" relationship.

[0138] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented 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 this application.

[0139] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0140] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through some interfaces, apparatuses, or units, or they may be electrical, mechanical, or other forms of connection.

[0141] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of this application, depending on actual needs.

[0142] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0143] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0144] This application uses specific embodiments to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for determining the prefetch depth of a stream, characterized in that, include: Based on historical stream information, train the stream length prediction table; The flow length prediction table records the correlation between the flow index and flow length feature information; Based on the flow length prediction table, determine the flow length prediction information for the newly allocated flow; The prefetch depth is determined based on the predicted flow length and flow confidence of the newly allocated flow.

2. The method as described in claim 1, characterized in that, It also includes: obtaining the historical stream information through the following methods; Retrieve information about streams removed from the stream prefetcher's stream table; The removed stream information constitutes historical stream information.

3. The method as described in claim 1, characterized in that, Based on historical stream information, the training stream length prediction table includes: Extract the stream length from the historical stream information; Determine the first stream index based on the stream length; Update the flow length prediction table based on the first flow index.

4. The method as described in claim 3, characterized in that, Update the flow length prediction table based on the first flow index, including: Detect whether the first flow index is included in the flow length prediction table; If the first flow index is not included in the flow length prediction table, then the first flow length feature information is determined; the first flow index and the first flow length feature information are associated and stored in the flow length prediction table; If the flow length prediction table includes the first flow index, then the newly associated first flow length feature information of the first flow index is calculated based on the first flow length feature information already associated with the first flow index; the first flow length feature information already associated with the first flow index in the flow length prediction table is updated to the newly associated first flow length feature information of the first flow index.

5. The method as described in claim 4, characterized in that, The first stream index is the stream length level, and the first stream length feature information is the number of times the stream length level appears or the distribution ratio of the stream length level.

6. The method as described in claim 5, characterized in that, Based on the flow length prediction table, the flow length prediction information for the newly allocated flow is determined, including: Determine the maximum value of the number of times a flow length level occurs or the percentage of the flow length level distribution from the flow length prediction table; The flow length level associated with the maximum value is determined as the flow length prediction information for the newly assigned flow.

7. The method as described in claim 1, characterized in that, Based on historical stream information, the training stream length prediction table includes: Extract the second stream index and stream length from the historical stream information; Update the flow length prediction table based on the second flow index and the flow length.

8. The method as described in claim 7, characterized in that, Update the flow length prediction table based on the second flow index and the flow length, including: Detect whether the flow length prediction table includes the second flow index; If the second flow index is not included in the flow length prediction table, then the second flow length feature information is determined based on the flow length, and the second flow index and the second flow length feature information are associated and stored in the flow length prediction table; If the flow length prediction table includes the second flow index, then based on the flow length and the second flow length feature information already associated with the second flow index, the newly associated second flow length feature information of the second flow index is calculated; the second flow length feature information already associated with the second flow index in the flow length prediction table is updated to the newly associated second flow length feature information of the second flow index.

9. The method as described in claim 8, characterized in that, The second stream index is a preset feature, and the second stream length feature information is the stream length.

10. The method as described in claim 9, characterized in that, Based on the flow length and the second flow length feature information already associated with the second flow index, the newly associated second flow length feature information of the second flow index is calculated, including: The average length of the stream and the lengths of the streams already associated with the second stream index are calculated to obtain the new length of the stream associated with the second stream index; or The stream length is determined as the stream length newly associated with the second stream index.

11. The method as described in claim 7, characterized in that, Based on the flow length prediction table, the flow length prediction information for the newly allocated flow is determined, including: Match the flow index of the newly allocated flow with the flow length prediction table; Based on the flow length feature information associated with the flow index of the newly allocated flow, the flow length prediction information of the newly allocated flow is determined.

12. The method as described in claim 1, characterized in that, Based on the predicted flow length and flow confidence of the newly allocated flow, the prefetch depth is determined, including: Based on the predicted flow length information of the newly allocated flow, the flow length level of the newly allocated flow is determined; Based on the flow confidence of the newly allocated flow, determine the flow confidence level of the newly allocated flow; The prefetch depth is determined based on the flow length level and flow confidence level of the newly allocated flow.

13. The method as described in claim 12, characterized in that, Based on the flow length level and flow confidence level of the newly allocated flow, the prefetch depth is determined, including: Calculate the prefetch coefficients based on the flow length level and flow confidence level of the newly allocated flow; The prefetch depth is determined based on the prefetch coefficient.

14. The method as described in claim 13, characterized in that, Based on the flow length level and flow confidence level of the newly allocated flow, calculate the prefetch coefficients, including: Based on the flow length level and flow confidence level of the newly allocated flow, calculate the prefetch coefficients using at least one of the following operations: The minimum of the flow length level and flow confidence of the newly allocated flow is taken as the prefetch coefficient; The newly allocated flow length level and flow confidence are weighted and averaged, and the weighted average is used as the prefetch coefficient.

15. A flow prefetching depth determination device, characterized in that, include: Training unit, used to train the stream length prediction table based on historical stream information; The flow length prediction table records the correlation between the flow index and flow length feature information; The prediction unit is used to determine the flow length prediction information of the newly allocated flow based on the flow length prediction table. The calculation unit is used to determine the prefetch depth based on the flow length prediction information and flow confidence of the newly allocated flow.

16. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 14.

17. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor of the computer device, it implements the method according to any one of claims 1 to 14.

18. A computer program product, the computer program product comprising a computer program, characterized in that, When the computer program is executed by the processor of the computer device, it implements the method according to any one of claims 1 to 14.