Cache allocation method and device, equipment, medium and program product
By acquiring multi-feature data streams and utilizing cache strategy decision models and cache capacity prediction models, combined with deep learning algorithm optimization models, the problem of cache size setting and data elimination rules being difficult to achieve global optimization in cache management is solved, thus achieving efficient utilization of cache resources and cost reduction.
Patent Information
- Application Number
- CN202511134810.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-14
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-08-14
AI Technical Summary
Existing cache management technologies, when given an expected cache miss rate, only consider cache size settings or data eviction rules, making it difficult to achieve globally optimal cache capacity and resource allocation.
By acquiring multi-feature data streams, extracting target feature vectors, and using cache policy decision models and cache capacity prediction models, the optimal cache eviction policy and target cache capacity allocation results are output. Combined with the deep learning algorithm optimization model, the optimal strategy selection of the cache eviction policy pool and the optimal resource allocation of cache capacity are achieved.
It achieves efficient utilization of cache resources, reduces management costs, improves resource efficiency, and solves the problem of difficulty in achieving global optimization in existing technologies.
Smart Images

Figure CN120653451A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of artificial intelligence technology, and in particular to a cache allocation method, apparatus, device, medium, and program product. Background Art
[0002] Currently, cache management technologies primarily focus on the construction of cache expansion and contraction mechanisms or the formulation of cache eviction policies. However, different eviction policies exhibit varying correlations between cache miss rates and cache capacity for data streams with varying characteristics. Given an expected cache miss rate (or hit rate), a one-sided consideration of cache sizing or data eviction rules fails to simultaneously consider optimal policy selection and optimal cache capacity resource allocation, making it difficult to achieve a global optimum. Summary of the Invention
[0003] Embodiments of the present invention provide a cache allocation method, apparatus, device, medium, and program product to solve the problem that it is difficult to achieve global optimization by one-sidedly considering cache size setting or data elimination rules when given an expected cache miss rate.
[0004] In order to solve the above-mentioned technical problems, the present invention is achieved as follows: In a first aspect, an embodiment of the present invention provides a cache allocation method, comprising: Acquire a multi-feature data stream, and extract a target feature vector of the multi-feature data stream; Inputting the expected cache miss rate preset by the user and the target feature vector into a cache policy decision model, the cache policy decision model outputting an optimal cache eviction policy based on the expected cache miss rate preset by the user and the target feature vector, then inputting the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector into a cache capacity prediction model, the cache capacity prediction model outputting a target cache capacity allocation result based on the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector; The cache capacity prediction model and the cache strategy decision model are trained in the following manner: The cache policy decision model inputs the predicted optimal cache eviction policy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache policy decision model according to the predicted capacity allocation result.
[0005] Optionally, the characteristic indicators used to extract the target feature vector in the multi-feature data stream include at least one of the following: data repetition frequency distribution, repeated data ratio, cumulative distribution of the number of data between repeated data, data stream information entropy, distribution of the shortest time interval between repeated data, distribution of time interval between adjacent data, data stream statistical period and data stream calendar effect.
[0006] Optionally, extracting a target feature vector from the multi-feature data stream includes: The multi-feature data stream is input into the feature engineering module, data preprocessing is performed on the multi-feature data stream to obtain a preprocessed multi-feature data stream, and feature extraction is performed on the preprocessed multi-feature data stream according to a preset data stream statistical time window size to obtain a target feature vector.
[0007] Optionally, also include: Training the cache capacity prediction model; Specifically include: Obtaining a first sample multi-feature data stream; Extracting a first feature vector of the first sample multi-feature data stream, and constructing a first cache miss rate curve data set of the first sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a first expected cache miss rate preset by a user, a cache eviction policy read from the first cache miss rate curve dataset, a first feature vector, and the first cache miss rate curve dataset into the cache capacity prediction model to be trained, training the cache capacity prediction model, and the cache capacity prediction model outputting a first cache capacity allocation result predicted under current conditions; A first loss is calculated based on the predicted first cache capacity allocation result and the optimal cache capacity allocation result corresponding to the cache eviction strategy read from the first cache miss rate curve data set, and the cache capacity prediction model is optimized by the first loss to obtain a trained cache capacity prediction model.
[0008] Optionally, also include: Training the cache strategy decision model; Specifically include: Obtaining a second sample multi-feature data stream; Extracting a second feature vector of the second sample multi-feature data stream, and constructing a second cache miss rate curve data set of the second sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a second expected cache miss rate, a second feature vector, and a second cache miss rate curve data set preset by a user into the cache policy decision model to be trained, and the cache policy decision model outputs an optimal cache eviction policy predicted under current conditions; Inputting the predicted optimal cache eviction policy into a cache capacity prediction model, the cache capacity prediction model outputting a predicted second cache capacity allocation result; A reward function is constructed based on the predicted second cache capacity allocation result and the optimal cache capacity allocation result output by the cache capacity prediction model under the same input, and the cache policy decision model is optimized by the reward function to obtain a trained cache policy decision model.
[0009] Optionally, constructing a first cache miss rate curve dataset of the first sample multi-feature data stream based on a cache miss rate curve algorithm includes: Step a: obtaining a first eviction policy and a first data flow according to a cache size range to be evaluated set by a user and a cache eviction policy pool given based on the cache size range, wherein the first eviction policy belongs to a cache eviction policy pool, the cache eviction policy pool includes at least one eviction policy, and the first data flow belongs to a first data flow group, the first data flow group includes at least one data flow; Step b: using the first data stream to simulate the cache operation of each access request under caches of different sizes, and calculating the miss rate of each access request under the size of each cache to obtain the cache miss rate; Step c: generating a cache miss rate curve according to the cache miss rate; Step d: determining whether the cache miss rate curve has been fitted for each eviction policy in the cache policy pool for the data flows in the first data flow group; if not all eviction policies have been traversed, repeating steps b and c until all eviction policies have been traversed; Step e: Determine whether the cache miss rate curve has been fitted for all collected data streams. If not all data streams have been traversed, repeat steps b to d until all data streams have been traversed to obtain the target cache miss rate curve dataset.
[0010] In a second aspect, an embodiment of the present invention provides a cache allocation device, including: A first processing module is used to obtain a multi-feature data stream and extract a target feature vector of the multi-feature data stream; a second processing module, configured to input an expected cache miss rate preset by a user and the target feature vector into a cache policy decision model, wherein the cache policy decision model outputs an optimal cache eviction policy based on the expected cache miss rate preset by the user and the target feature vector, and further input the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector into a cache capacity prediction model, wherein the cache capacity prediction model outputs a target cache capacity allocation result based on the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector; The cache capacity prediction model and the cache strategy decision model are trained in the following manner: The cache policy decision model inputs the predicted optimal cache eviction policy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache policy decision model according to the predicted capacity allocation result.
[0011] In a third aspect, an embodiment of the present invention provides an electronic device comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps in the cache allocation method as described in any one of the first aspects.
[0012] In a fourth aspect, an embodiment of the present invention provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps in the cache allocation method as described in any one of the first aspects are implemented.
[0013] In a fifth aspect, an embodiment of the present invention provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the steps in the cache allocation method as described in any one of the first aspects.
[0014] In the present invention, a multi-feature data stream is obtained, and the target feature vector of the multi-feature data stream is extracted; the expected cache miss rate preset by the user and the target feature vector are input into the cache policy decision model, and the optimal cache eviction policy is output; the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector are input into the cache capacity prediction model, and the target cache capacity allocation result is output. In the present invention, the data stream is used as input to respectively realize the optimal policy selection of the cache eviction policy pool and the optimal resource allocation of the cache capacity. Through the mutual promotion of the working capabilities of the cache policy decision model and the cache capacity prediction model, the two cache management methods are efficiently realized, which greatly reduces the management cost and improves the resource efficiency, and solves the problem that the existing one-sided consideration of cache size setting or data elimination rules when given an expected cache miss rate is difficult to achieve the global optimum. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present invention. The same reference symbols are used throughout the drawings to represent the same components. In the drawings: Figure 1 This is a flow chart of a cache allocation method provided by an embodiment of the present invention; Figure 2 Schematic diagram of MRC trends under various cache eviction strategies of a cache allocation method provided by an embodiment of the present invention; Figure 3 This is a flow chart of an MRC data set construction method for cache allocation provided by an embodiment of the present invention; Figure 4 Schematic diagram of a cache capacity intelligent allocation device of a cache allocation method provided by an embodiment of the present invention; Figure 5 This is a schematic diagram of training a cache capacity prediction model for a cache allocation method provided by an embodiment of the present invention; Figure 6 This is a schematic diagram showing the impact of cache eviction policy selection on optimal cache capacity allocation in a cache allocation method provided by an embodiment of the present invention; Figure 7 Schematic diagram of a cache eviction policy intelligent allocation device of a cache allocation method provided by an embodiment of the present invention; Figure 8 1 is a schematic diagram of a linear cost function of a cache allocation method provided by an embodiment of the present invention; Figure 9 1 is a schematic diagram of an exponential cost function of a cache allocation method provided by an embodiment of the present invention; Figure 10 is a schematic diagram of a parabolic cost function of a cache allocation method provided by an embodiment of the present invention; Figure 11 1 is a schematic diagram of a step-type cost function of a cache allocation method provided by an embodiment of the present invention; Figure 12 1 is a schematic diagram of a segmented cost function of a cache allocation method provided by an embodiment of the present invention; Figure 13 1 is a schematic diagram of a segmented cost function of another cache allocation method provided by an embodiment of the present invention; Figure 14 This is an overall flow chart of a cache allocation method provided by an embodiment of the present invention; Figure 15It is a structural diagram of a cache allocation device provided by an embodiment of the present invention; Figure 16 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0016] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0017] Please refer to Figure 1 , an embodiment of the present invention provides a cache allocation method, comprising: Step 11: Acquire a multi-feature data stream and extract a target feature vector from the multi-feature data stream; In the embodiment of the present invention, the multi-feature data streams come from different data sources, and the acquisition window length is set The acquisition window length can be consistent with the window size selected during the training phase of the cache strategy decision model and the cache capacity prediction model, and Time collection The multi-feature data stream of the time period ; and The moment will The data stream of the time period is input into the feature extraction module to obtain the corresponding target feature vector By extracting the target feature vector of the multi-feature data stream, cache resources can be allocated more reasonably, redundant storage can be avoided, and the utilization efficiency of storage and computing resources can be improved; and every Time will automatically and repeatedly acquire multi-feature data streams and perform subsequent operations, which is easy to operate and saves a lot of manpower management costs.
[0018] Step 12: Inputting the expected cache miss rate preset by the user and the target feature vector into a cache policy decision model, the cache policy decision model outputting an optimal cache eviction policy based on the expected cache miss rate preset by the user and the target feature vector, then inputting the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector into a cache capacity prediction model, the cache capacity prediction model outputting a target cache capacity allocation result based on the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector; The cache capacity prediction model and the cache strategy decision model are trained in the following manner: The cache policy decision model inputs the predicted optimal cache eviction policy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache policy decision model according to the predicted capacity allocation result.
[0019] In the embodiment of the present invention, the cache manager or user sets the expected cache miss rate according to the system operation status and access requirements of the method for implementing cache allocation. and determine the pool of alternative strategies , wherein the candidate strategy pool is consistent with the strategy pool used in the training phase of the cache strategy decision model and the cache capacity prediction model, and the state vector is constructed with the target feature vector And input to the cache policy decision model, the cache policy decision model will be Selected As a cache system The optimal cache eviction strategy used in the period; then the target feature vector , expected cache miss rate and optimal cache eviction strategy Combined input to the cache capacity prediction model, the cache capacity prediction model will output the target cache capacity allocation result As a cache system The cache size used in the time period is determined by the cache policy decision model, which is input into the cache capacity prediction model very quickly. Therefore, the cache policy decision model and the cache capacity prediction model can be efficiently and almost synchronously parallelized. By simultaneously realizing the method of intelligent allocation of eviction policy and intelligent allocation of cache capacity, the dilemma of the current two cache management paths of divide and rule is broken, and a reliable and trustworthy decision-making plan is formed from the perspective of global optimization, taking into account the service quality and system expenditure of the cache system, and making up for the shortcoming of traditional cache management in lacking timeliness in real-time demand feedback.
[0020] In the embodiment of the present invention, the cache eviction policy selection and cache expansion and contraction decision jointly determine the system service capability and benefits. Obtaining the optimal cache eviction policy is a necessary prerequisite for the cache capacity prediction model to output the global optimal solution. Accurate cache capacity prediction also provides a solid foundation for improving the performance of the cache policy decision model. Therefore, cache eviction policy selection and cache capacity allocation are indispensable in cache management. As the real-time data flow characteristics change and the user's expected cache miss rate varies, the cache policy decision model needs to adaptively and intelligently output the most appropriate eviction policy to the cache capacity prediction model, thereby jointly forming the optimal solution.
[0021] In an embodiment of the present invention, a multi-feature data stream is obtained, and a target feature vector of the multi-feature data stream is extracted; the expected cache miss rate preset by the user and the target feature vector are input into a cache policy decision model, and the cache policy decision model outputs an optimal cache eviction policy; and the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector are input into a cache capacity prediction model, and the cache capacity prediction model outputs a target cache capacity allocation result. In the present invention, the real-time data stream is used as input to respectively realize the optimal policy selection of the cache eviction policy pool and the optimal resource allocation of the cache capacity. By mutually promoting the working capabilities of the cache policy decision model and the cache capacity prediction model, the two cache management methods are efficiently synchronized and parallelized, which greatly reduces management costs and improves resource efficiency, solving the problem that the existing one-sided consideration of cache size setting or data elimination rules when given an expected cache miss rate is difficult to achieve global optimization.
[0022] In an embodiment of the present invention, optionally, the feature indicators used to extract the target feature vector in the multi-feature data stream include at least one of the following: data repetition frequency distribution, repeated data ratio, cumulative distribution of the number of data between repeated data, data stream information entropy, distribution of the shortest time interval between repeated data, distribution of time interval between adjacent data, data stream statistical period and data stream calendar effect.
[0023] In an embodiment of the present invention, in order to ensure the comprehensiveness and representativeness of the data feature collection of the multi-feature data stream, it is necessary to expand the feature pre-selection range as much as possible under the premise of data availability and reliable quality, and at the same time, it is necessary to construct new features through statistical processing between different indicators, such as frequency statistics, ratio calculation, distribution parameter fitting, etc. The feature indicators used to extract the target feature vector in the multi-feature data stream in the present invention mainly include distribution feature class, time period class, and other classes, among which the distribution feature class includes data repetition frequency distribution, repeated data ratio, cumulative distribution of the number of data intervals between repeated data, and data stream information entropy; the time period class includes the distribution of the shortest time interval between repeated data and the time interval distribution between adjacent data; and other classes include data stream statistical period and data stream calendar effect.
[0024] When extracting data stream features, it is necessary to manually specify the time window size for data stream statistics in advance, such as 60 seconds, 1 hour, 1 day, etc. The window size is closely related to the cache strategy and the frequency of adjusting the cache capacity. For example, collecting information every hour and extracting the data stream features within this hour means that the cache eviction strategy and capacity size can be adjusted once every hour based on the latest features.
[0025] Specifically, within a specific time window, the data repetition frequency distribution, a distribution characteristic, primarily measures the frequency distribution of duplicate data access requests, using the mean, standard deviation, kurtosis, and skewness of this distribution as its characteristic values. The duplicate data ratio measures the proportion of duplicate data accesses to the total data volume. The cumulative distribution of the number of intervals between duplicate data primarily measures the distribution of the sum of all other accesses between adjacent duplicate data accesses, using the mean, standard deviation, kurtosis, and skewness of this distribution as its characteristic values. The data stream information entropy first determines the probability of occurrence of each data value or access request in the data stream, and then calculates the data stream information entropy based on this probability distribution. The shortest time interval distribution between duplicate data, a time period indicator, primarily measures the distribution of the shortest time interval between all adjacent duplicate data accesses, using the mean, standard deviation, kurtosis, and skewness of this distribution as its characteristic values. The time interval distribution between adjacent data primarily measures the distribution of the time interval between all adjacent data accesses, using the mean, standard deviation, kurtosis, and skewness of this distribution as its characteristic values. In other indicators, the data flow statistical cycle uses seconds to calculate the time window size. For example, when the window period is 1 minute, the characteristic value is 60. The data flow calendar effect mainly examines whether the statistical window period falls on weekends and statutory holidays, and uses 0 or 1 to refer to weekdays or holidays, respectively. This is to take into account that data access may have obvious periodic characteristics.
[0026] In the embodiment of the present invention, optionally, extracting the target feature vector of the multi-feature data stream includes: The multi-feature data stream is input into a feature engineering module, the feature engineering module performs data preprocessing on the multi-feature data stream to obtain a preprocessed multi-feature data stream, and performs feature extraction on the preprocessed multi-feature data stream according to a preset time window size of data stream statistics to obtain a target feature vector.
[0027] In an embodiment of the present invention, to reduce model computational complexity and feature redundancy, the feature engineering module performs secondary processing on initially selected features, including but not limited to various dimensionality reduction methods such as feature selection and feature compression. For example, commonly used feature selection methods include Maximum Information Number (MIC), Correlated Feature Selection (CFS), Recursive Feature Elimination (RFE), Stability Selection (RL), Lasso Algorithm (LASSO), Ridge Regression (RR), and Random Forest (RF). Feature selection uses discriminant metrics such as information coefficient, correlation coefficient, and regression coefficient to directly select several important features from a set of features. Different methods select different numbers and categories of features. Feature compression methods include principal component analysis (PCA), factor analysis (FA), and singular value decomposition (SVD). Feature compression linearly combines the original features under certain rules to form new features with lower dimensionality but less information loss. The feature engineering module, through relevant code design, allows users to freely select or switch between desired feature dimensionality reduction methods, and even supports not using any dimensionality reduction strategy when the total number of features is small.
[0028] The feature engineering module selects the feature types, thereby obtaining a feature vector matrix, which is used for subsequent model training and actual systems. Taking into account the computational overhead of modeling, the most representative data flow feature types are uniformly extracted based on all available historical data flow information and the final feature vector is determined. After specifying the required feature types, the direct carrying information of the data flow and the system operation status information collected in real time within a certain time window are used for statistical processing, missing value filling, outlier detection and replacement, and normalization or standardization processing, and finally a real-time feature vector or feature matrix of the data flow is formed, thereby providing high-quality information input for model pre-training and real-time management of the cache system. The feature engineering module undertakes the feature extraction and feature compression work of the data flow. The feature engineering module effectively extracts representative features of multi-source and multi-category data flows and constructs feature vectors for subsequent model training, so that the cache strategy decision model and cache capacity prediction model that have learned a large amount of prior feature knowledge can use real-time data flow feature data to output results in real time during the actual operation of the system, ensuring the timeliness of the cache management process.
[0029] In the embodiment of the present invention, optionally, the method further includes: Training the cache capacity prediction model; Specifically include: Obtaining a first sample multi-feature data stream; Extracting a first feature vector of the first sample multi-feature data stream, and constructing a first cache miss rate curve data set of the first sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a first expected cache miss rate preset by a user, a cache eviction policy read from the first cache miss rate curve dataset, a first feature vector, and the first cache miss rate curve dataset into the cache capacity prediction model to be trained, training the cache capacity prediction model, and the cache capacity prediction model outputting a first cache capacity allocation result predicted under current conditions; A first loss is calculated based on the predicted first cache capacity allocation result and the optimal cache capacity allocation result corresponding to the cache eviction strategy read from the first cache miss rate curve data set, and the cache capacity prediction model is optimized by the first loss to obtain a trained cache capacity prediction model.
[0030] In an embodiment of the present invention, optionally, constructing a first cache miss rate curve dataset of the first sample multi-feature data stream based on a cache miss rate curve algorithm includes: Step a: obtaining a first eviction policy and a first data flow according to a cache size range to be evaluated set by a user and a cache eviction policy pool given based on the cache size range, wherein the first eviction policy belongs to a cache eviction policy pool, the cache eviction policy pool includes at least one eviction policy, and the first data flow belongs to a first data flow group, the first data flow group includes at least one data flow; Step b: using the first data stream to simulate the cache operation of each access request under caches of different sizes, and calculating the miss rate of each access request under the size of each cache to obtain the cache miss rate; Step c: generating a cache miss rate curve according to the cache miss rate; Step d: determining whether the cache miss rate curve has been fitted for each eviction policy in the cache policy pool for the data flows in the first data flow group; if not all eviction policies have been traversed, repeating steps b and c until all eviction policies have been traversed; Step e: Determine whether the cache miss rate curve has been fitted for all collected data streams. If not all data streams have been traversed, repeat steps b to d until all data streams have been traversed to obtain the target cache miss rate curve dataset.
[0031] In an embodiment of the present invention, the cache miss ratio curve (MRC) is one of the most effective tools for understanding and grasping the relationship between cache size and miss ratio. It can provide a scientific and reasonable basis for formulating cache expansion and contraction strategies. The present invention constructs a training data set through the MRC algorithm and uses it in a cache capacity prediction model, so that the cache capacity prediction model can pre-acquire the decision-making ability of cache expansion and contraction based on the real-time characteristics of the data flow and the prior knowledge from MRC, greatly reducing time consumption and significantly improving the decision-making efficiency of capacity allocation. In addition, for a group of identical data flows, the MRC curve usually shows different trends under different cache eviction strategies, such as Figure 2 As shown in Figure 2, by comprehensively examining the MRC curves of all strategies, the optimal cache eviction strategy and cache capacity under the data flow can be effectively determined. For example, Figure 2 Given an expected cache miss rate of 50%, the optimal cache eviction strategy and cache capacity for this data stream are FIFO and 50 GiB, respectively. Therefore, when constructing the MRC dataset, it is necessary to consider the curve trends of various methods in the cache eviction strategy pool under various characteristic data streams.
[0032] For details, please refer to Figure 3First, perform step a to determine the cache size range that needs to be evaluated. The upper limit of the range can usually be determined based on the cache capacity requirements or economic budget. Then, the range is evenly divided into certain intervals. The smaller the division granularity, the more accurate the cache miss rate curve fitting and the richer the data information, but the greater the workload. For example, when the evaluation range is 0~100GiB, if the cache shard size increases by 10GiB, a total of 10 caches of different sizes need to be simulated, while if it increases by 5GiB, a total of 20 simulation operations are required. The granularity of the division can be determined comprehensively based on the efficiency of the MRC generation algorithm, the required data set size, etc. Based on the given cache eviction policy pool, an eviction policy is selected, and a set of data flows are determined, wherein the data flows contain data access patterns; Step b is executed to simulate cache operations, and by using the collected access patterns, whether each access request is cache hit in caches of different sizes is simulated. For each cache size, the miss rate of all requests in that size, i.e., the cache miss rate, is calculated; Step c is executed to generate MRC, with different cache capacities as the horizontal coordinates and the miss rate as the vertical coordinates. Draw the corresponding MRC by linear interpolation or cubic spline interpolation for discrete points in the data set; execute step d to examine whether cache miss rate curves are fitted for various eviction strategies in the cache strategy pool under the same set of data flows. If all strategies have not been traversed, repeat steps b and c until all strategies have been traversed; execute step e to examine whether cache miss rate curves are fitted for all collected data flows. If all data flows (or data access patterns) have not been traversed, repeat steps b to d until all data flows have been traversed, thereby obtaining the target cache miss rate curve dataset.
[0033] In an embodiment of the present invention, the following algorithms may be used, but are not limited to: for example, the Mattson algorithm, the SHARDS algorithm, the MiniSim algorithm, and the Kosmo algorithm. Among them, the Mattson algorithm is the earliest algorithm that can be used to construct MRC and can be used for data simulation of the LRU cache strategy. It maintains an LRU stack to record all accessed objects, measures the reuse distance at each access and records it in a histogram, and finally generates MRC based on the histogram; SHARDS is a sampling algorithm for MRC generation, which can be combined with other MRC generation algorithms to significantly improve the MRC generation efficiency by processing only a sampled subset of access requests, and usually has a lower fitting error; the MiniSim algorithm can model and generate MRC for any cache eviction strategy by independently simulating caches of different sizes, and uses the SHARDS sampling method to improve generation efficiency; the Kosmo algorithm allows MRC to be generated for multiple cache eviction strategies at the same time, calculates reuse distances by using eviction maps, and reconstructs cache stacks of different sizes using a single data copy, with lower memory overhead and higher throughput. Among the aforementioned algorithms, the Mattson method, while offering high fitting accuracy, is limited in its application scenarios and is only suitable for MRC generation using an LRU strategy. The MiniSim method, while highly versatile, requires maintaining a complete cache structure for each cache size, resulting in high memory overhead. The Kosmo method, building on MiniSim, offers a more efficient and economical solution by optimizing memory usage and computational efficiency. Since the MRC algorithm-based generation of relevant datasets primarily serves model pre-training, dataset quality primarily impacts model performance and decision-making effectiveness, while the time overhead of constructing the dataset does not affect the real-time nature of subsequent intelligent cache allocation operations. Therefore, MRC generation algorithms with high fitting accuracy are preferred (accuracy refers to whether the cache miss rate values obtained in simulated data access experiments accurately reflect the actual situation). The time cost of acquiring the dataset can be appropriately prioritized based on individual needs and actual circumstances. In the embodiments of the present invention, the accuracy, robustness, and efficiency of the algorithm are comprehensively considered, and the Kosmo algorithm is used as a specific embodiment to realize the creation of the MRC dataset. Based on the multi-feature MRC dataset construction method, the MRC generation algorithm is used to construct a dataset for training and optimizing the cache allocation model for different data stream characteristics. For different data stream scenarios, high-precision MRC datasets are generated, which helps to significantly improve the model training effect and the accuracy of cache allocation decisions. By constructing and applying the multi-feature MRC dataset, new prediction scenarios and technical requirements are opened up, providing a solid data foundation for cache capacity prediction and miss rate prediction, thereby realizing accurate optimization and enhanced adaptability of cache capacity management.
[0034] Please refer to Figure 4In an embodiment of the present invention, the cache capacity prediction model in the cache capacity intelligent allocation device is trained to improve the accuracy and robustness of cache capacity prediction and provide scientific support for elastic cache expansion and contraction. Based on the feature engineering module, the features of the input data stream within a certain time period are extracted, and the MRC dataset creation module uses the same data stream and the MRC generation algorithm to output training data. For details, please refer to Figure 4 , given the user's pre-set expected cache miss rate and a set of data streams And obtain its feature vector based on the feature engineering module ( , is the total number of data flow sample groups), when the cache eviction strategy is hour( , is the cache eviction policy pool size), cache capacity prediction model Should be able to give the optimal cache capacity allocation under current conditions ,Right now Cache capacity prediction model The predictive ability is mainly achieved by learning the corresponding data flow MRC training set ;like Figure 5 As shown, the input of the cache capacity prediction model mainly includes three aspects: data flow feature vector , expected cache miss rate and cache eviction policies ,in is the vector formed by concatenating all characteristic index values after standardization or normalization. and Can be directly based on Get the form, is a numerical value, for dimensional vector, whose The first element is 1 and the rest are 0, so we can get the input label Similarly, the optimal cache capacity under this condition is Can also be directly , where the "optimal" in the embodiment of the present invention means that different cache capacity sizes may correspond to the same or very close cache miss rates under the same eviction strategy. In this case, the smallest cache capacity under the miss rate should be selected to obtain the final output label , which is the predicted first cache capacity allocation result. For example: Figure 5 Middle Inspection Group Data Flow and use the eviction policy hour, Corresponding , using the eviction policy hour, Corresponding As the cache partition step size decreases, The richer the information, the stronger the feature capture capability of the cache capacity prediction model. In addition, since the interpolation method can be used to Theoretically, for any given cache miss rate , the corresponding optimal cache capacity can be found.
[0035] After determining the input and output forms of the cache capacity prediction model, it is necessary to construct the cache capacity prediction model itself. Since the model input dimension is high and the structure is complex, and the MRC changes usually show nonlinearity and multi-fluctuation characteristics, the embodiment of the present invention selects a deep learning algorithm to model the cache capacity prediction model. Specifically, in the deep neural network, the input layer size is ,in is the number of selected characteristic indicators, is the total number of alternative eviction strategies, and the output layer size is The hidden layer network connecting the input layer and the output layer can introduce various forms of neural network models, optimization mechanisms or multiple combinations as needed, including but not limited to fully connected networks (Full-connected Networks), convolutional neural networks (CNN), recurrent neural networks (RNN), long short-term memory networks (LSTM), attention mechanisms (Attention), etc. The activation function connected to the output layer is selected as ReLu activation. When optimizing the neural network parameters, set the first loss function to the model prediction value and the true value The errors between them, including but not limited to root mean square error (RMSE), mean absolute error (MAE), mean absolute percentage error (MAPE), etc., are then updated based on the model loss and back propagation (BP) algorithm. The cache capacity prediction model is pre-trained on a large number of data stream samples and different eviction strategies. In subsequent actual use, for real-time data streams, after specifying the expected cache miss rate, the cache allocation amount can be output quickly, conveniently, and accurately based on the data stream feature vector processed by the feature engineering module and the optimal eviction strategy selection result given by the cache strategy decision model. This ensures the timeliness and reliability of service quality while minimizing economic costs. By intelligently predicting and outputting the optimal cache allocation quota, optimal utilization of cache resources under different loads and data characteristics is ensured. Combined with deep learning technology, the prediction model is trained using historical data to achieve intelligent allocation of cache capacity, greatly improving the system's resource management efficiency and effectively reducing resource usage costs.
[0036] In the embodiment of the present invention, the following may be optionally further included: Training the cache strategy decision model; Specifically include: Obtaining a second sample multi-feature data stream; Extracting a second feature vector of the second sample multi-feature data stream, and constructing a second cache miss rate curve data set of the second sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a second expected cache miss rate, a second feature vector, and a second cache miss rate curve data set preset by a user into the cache policy decision model to be trained, and the cache policy decision model outputs an optimal cache eviction policy predicted under current conditions; Inputting the predicted optimal cache eviction policy into a cache capacity prediction model, the cache capacity prediction model outputting a predicted second cache capacity allocation result; A reward function is constructed based on the predicted second cache capacity allocation result and the optimal cache capacity allocation result output by the cache capacity prediction model under the same input, and the cache policy decision model is optimized by the reward function to obtain a trained cache policy decision model.
[0037] In an embodiment of the present invention, optionally, constructing a second cache miss rate curve dataset of the second sample multi-feature data stream based on a cache miss rate curve algorithm includes: Step a: obtaining a second eviction policy and a second data flow according to a cache size range to be evaluated set by a user and a cache eviction policy pool given based on the cache size range, wherein the second eviction policy belongs to the cache eviction policy pool, the cache eviction policy pool includes at least one eviction policy, and the second data flow belongs to a first data flow group, and the second data flow group includes at least one data flow; Step b: using the second data stream to simulate the cache operation of each access request under caches of different sizes, and calculating the miss rate of each access request under the size of each cache to obtain the cache miss rate; Step c: generating a cache miss rate curve according to the cache miss rate; Step d: determining whether the cache miss rate curve has been fitted for each eviction policy in the cache policy pool for the data flows in the second data flow group; if not all eviction policies have been traversed, repeating steps b and c until all eviction policies have been traversed; Step e: Determine whether the cache miss rate curve has been fitted for all collected data streams. If not all data streams have been traversed, repeat steps b to d until all data streams have been traversed to obtain the target cache miss rate curve dataset.
[0038] In the embodiment of the present invention, the method for constructing the MRC dataset is as described above; the cache eviction strategy selection and cache expansion and contraction decision jointly determine the system service capability and benefits. Obtaining the optimal cache eviction strategy is a necessary prerequisite for the cache capacity prediction model to output the global optimal solution. Accurate cache capacity prediction also provides a solid foundation for improving the performance of the cache strategy decision model. Figure 6 As shown in Figure 2, the MRC trend chart of the data flow for a certain data access request under the two strategies is shown. When the expected miss rate is 65%, strategy A is significantly better than strategy B, which can save 20GiB of cache cost. When the miss rate is 50%, strategy B has a more economic advantage than strategy A. Therefore, Figure 6 It explains that cache eviction policy selection and cache capacity allocation are indispensable in cache management. As the real-time data stream characteristics change and the user's expected cache miss rate varies, the cache policy decision model needs to adaptively and intelligently output the most appropriate eviction policy to the cache capacity prediction model, thereby jointly forming the optimal solution.
[0039] In the embodiment of the present invention, a deep reinforcement learning algorithm is used to model the cache policy decision model in the cache eviction policy intelligent allocation device, wherein the five basic elements of reinforcement learning include state ,action , state transfer matrix ,award and discounts ,Right now ,in is the model input, is the model output, Determines the main goal of model parameter optimization, such as Figure 7 As shown, the state vector The expected cache miss rate given by the user and collected data streams The eigenvector of As mentioned above, the input layer size of the reinforcement learning model is set to , the model is able to be given a cache eviction policy pool Select the optimal cache eviction strategy , motion vector for dimensional vector, whose The first element is 1, indicating that the current model is selected strategies, and the rest of the elements are 0, so the output layer size is . Note that the output of the reinforcement learning model is The subsequent and are concatenated and input into the cache capacity prediction model, so The pros and cons of an action can be determined by comparing the current capacity forecast result with the predicted optimal capacity. Not affected by current status and current actions Therefore, the state transfer can be regarded as deterministic, that is, is a matrix of all 1s.
[0040] In the reward function and discount factor In terms of settings, in the embodiment of the present invention, according to The result obtained by inputting into the cache capacity intelligent allocation model, i.e., the predicted second cache capacity allocation result, is compared and cost-analyzed with the global optimal result output by the cache capacity prediction model under the same input, thereby constructing a reward function and determining the discount factor.
[0041] Specifically, let the strategy given by the cache strategy decision model Cache capacity prediction model output results , and let the minimum cache that the cache capacity prediction model can give under the same conditions be , assuming that it is in the cache eviction policy When it reaches the minimum value, Generally speaking, if , indicating that the reinforcement learning model has the optimal decision-making ability, otherwise there is still room for parameter optimization. However, in the cache management process, it is one-sided to only compare the required cache size under the same conditions when evaluating the cache expansion and contraction mechanism, because it is not ruled out that the cost overhead of using two caches of different sizes within a certain capacity range under certain pricing rules may be consistent, and the decision to require a larger cache should not be punished at this time. Therefore, evaluating decisions from the perspective of economic cost can better reflect the actual needs of cache management. Therefore, in the embodiment of the present invention, the reinforcement learning reward function construction method based on the cost function, where the cost function is set , which should vary with the cache capacity The increase of shows a monotonically non-decreasing trend. Without loss of generality, as long as it conforms to this trend, it is allowed To express it in arbitrary function form, please refer to Figure 8-13 As shown, including but not limited to linear type (such as Figure 8 ), exponential (such as Figure 9 ), parabolic (such as Figure 10 ), ladder type (such as Figure 11 ), segmented (mixed) (e.g. Figure 12 and Figure 13 ) etc., due to Monotonically non-decreasing reward function Can be set to: ; The higher the value, the stronger the performance of the cache strategy decision model. In the technical context of this proposal, the overall decision benefit (i.e., the cache cost reduction amount) can be regarded as the direct accumulation of each period's decision benefits, without considering the historical discount effect. Therefore, the discount factor can be set to .
[0042] In the construction of the network structure of the deep reinforcement learning model, the hidden layer network connecting the input layer and the output layer can introduce various forms of neural network models, optimization mechanisms or multiple combinations as needed. The layer before the output layer will be activated by the softmax function, and the neurons at each position represent the probability of selecting the corresponding eviction strategy. Then, the one-hot function is used to activate the output layer, which maps the neuron with the highest probability to 1 and the rest to 0. In the selection of reinforcement learning algorithms, since the action space is discrete, various value-based, policy-based or actor-critic algorithms can be used to implement the design of the cache eviction strategy intelligent allocation device of this proposal. The present invention uses the most convenient policy gradient algorithm (PG) as a specific embodiment for explanation. According to The construction method of the PG algorithm aims to obtain the expected return maximization of for:
[0043] in, The trajectory of action formed for all decisions, is the trajectory length (or the total number of decisions), is the neural network parameter. The bigger the better, so the PG algorithm uses the gradient boosting method to calculate the deterministic policy gradient , and update the network parameters: is the update step size.
[0044] In an embodiment of the present invention, by setting an expected cache miss rate threshold, extracting data stream features, and constructing a policy selection model within a policy pool, a reinforcement learning algorithm is used to dynamically select the optimal cache eviction policy, thereby optimizing cache usage efficiency. Reinforcement learning is used to achieve intelligent and dynamic optimization of the cache eviction policy, significantly improving the system's adaptability and service efficiency under different data streams, and laying a high-quality decision-making foundation for cache capacity allocation. Therefore, when evaluating cache eviction policy decisions, the global optimal result output by the cache capacity prediction model is used as the evaluation criterion, rather than directly finding the actual optimal result based on the MRC dataset. This can effectively reduce sampling variance and overfitting risks, and help improve model robustness and flexibility. Based on the construction and optimization of the cache policy decision model, in subsequent actual use, for real-time data streams, after specifying the expected cache miss rate, the optimal policy can be quickly selected from the pool of alternative eviction policies based on the data stream feature vector processed by the feature engineering module, providing users with a reliable policy decision basis and providing necessary input information for the cache capacity intelligent allocation device.
[0045] Please refer to Figure 14 In an embodiment of the present invention, a cache eviction policy decision model in a cache eviction policy function allocation device and a cache capacity prediction model in a cache capacity intelligent allocation device are simultaneously constructed. The optimal cache eviction policy selection of the cache eviction policy pool and the optimal cache capacity allocation result of the cache capacity are respectively realized according to the real-time data stream input, and an MRC data set is generated according to the data stream based on the MRC generation algorithm for model training optimization. The optimal cache eviction policy and the optimal cache capacity allocation results output by the cache eviction policy decision model and the cache capacity prediction model promote each other, further optimize the cache eviction policy decision model and the cache capacity prediction model, and efficiently synchronize and parallelize the two cache management methods, greatly reducing management costs and improving resource efficiency, solving the problem that the existing one-sided consideration of cache size setting or data elimination rules when given an expected cache miss rate is difficult to achieve global optimization.
[0046] Please refer to Figure 15, an embodiment of the present invention provides a cache allocation device, comprising: A first processing module 151 is configured to obtain a multi-feature data stream and extract a target feature vector from the multi-feature data stream; A second processing module 152 is configured to input the user's preset expected cache miss rate and the target feature vector into a cache policy decision model, wherein the cache policy decision model outputs an optimal cache eviction policy based on the user's preset expected cache miss rate and the target feature vector, and then input the optimal cache eviction policy, the user's preset expected cache miss rate, and the target feature vector into a cache capacity prediction model, wherein the cache capacity prediction model outputs a target cache capacity allocation result based on the optimal cache eviction policy, the user's preset expected cache miss rate, and the target feature vector; The cache capacity prediction model and the cache strategy decision model are trained in the following manner: The cache policy decision model inputs the predicted optimal cache eviction policy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache policy decision model according to the predicted capacity allocation result.
[0047] In an embodiment of the present invention, optionally, the feature indicators used to extract the target feature vector in the multi-feature data stream include at least one of the following: data repetition frequency distribution, repeated data ratio, cumulative distribution of the number of data between repeated data, data stream information entropy, distribution of the shortest time interval between repeated data, distribution of time interval between adjacent data, data stream statistical period and data stream calendar effect.
[0048] In an embodiment of the present invention, optionally, the first processing module includes: The first processing submodule is used to input the multi-feature data stream into a feature engineering module, perform data preprocessing on the multi-feature data stream to obtain a preprocessed multi-feature data stream, and perform feature extraction on the preprocessed multi-feature data stream according to a preset time window size of data stream statistics to obtain a target feature vector.
[0049] In the embodiment of the present invention, optionally, the method further includes: A first model training module, configured to train the cache capacity prediction model; Specifically include: Obtaining a first sample multi-feature data stream; Extracting a first feature vector of the first sample multi-feature data stream, and constructing a first cache miss rate curve data set of the first sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a first expected cache miss rate preset by a user, a cache eviction policy read from the first cache miss rate curve dataset, a first feature vector, and the first cache miss rate curve dataset into the cache capacity prediction model to be trained, training the cache capacity prediction model, and the cache capacity prediction model outputting a first cache capacity allocation result predicted under current conditions; A first loss is calculated based on the predicted first cache capacity allocation result and the optimal cache capacity allocation result corresponding to the cache eviction strategy read from the first cache miss rate curve data set, and the cache capacity prediction model is optimized by the first loss to obtain a trained cache capacity prediction model.
[0050] In the embodiment of the present invention, optionally, the method further includes: A second model training module is used to train the cache strategy decision model; Specifically include: Obtaining a second sample multi-feature data stream; Extracting a second feature vector of the second sample multi-feature data stream, and constructing a second cache miss rate curve data set of the second sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a second expected cache miss rate, a second feature vector, and a second cache miss rate curve data set preset by a user into the cache policy decision model to be trained, and the cache policy decision model outputs an optimal cache eviction policy predicted under current conditions; Inputting the predicted optimal cache eviction policy into a cache capacity prediction model, the cache capacity prediction model outputting a predicted second cache capacity allocation result; A reward function is constructed based on the predicted second cache capacity allocation result and the optimal cache capacity allocation result output by the cache capacity prediction model under the same input, and the cache policy decision model is optimized by the reward function to obtain a trained cache policy decision model.
[0051] In an embodiment of the present invention, optionally, constructing a first cache miss rate curve dataset of the first sample multi-feature data stream based on a cache miss rate curve algorithm includes: Step a: obtaining a first eviction policy and a first data flow according to a cache size range to be evaluated set by a user and a cache eviction policy pool given based on the cache size range, wherein the first eviction policy belongs to a cache eviction policy pool, the cache eviction policy pool includes at least one eviction policy, and the first data flow belongs to a first data flow group, the first data flow group includes at least one data flow; Step b: using the first data stream to simulate the cache operation of each access request under caches of different sizes, and calculating the miss rate of each access request under the size of each cache to obtain the cache miss rate; Step c: generating a cache miss rate curve according to the cache miss rate; Step d: determining whether the cache miss rate curve has been fitted for each eviction policy in the cache policy pool for the data flows in the first data flow group; if not all eviction policies have been traversed, repeating steps b and c until all eviction policies have been traversed; Step e: Determine whether the cache miss rate curve has been fitted for all collected data streams. If not all data streams have been traversed, repeat steps b to d until all data streams have been traversed to obtain the target cache miss rate curve dataset.
[0052] The cache allocation device provided by the embodiment of the present invention can achieve Figure 1 The various processes implemented by the method embodiment achieve the same technical effect and are not described here again to avoid repetition.
[0053] The embodiment of the present invention provides an electronic device 160, see Figure 16 As shown, Figure 16 This is a principle block diagram of an electronic device 160 according to an embodiment of the present invention, including a processor 161, a memory 162, and a program or instruction stored in the memory 162 and executable on the processor 161. When the program or instruction is executed by the processor, the steps in any one of the cache allocation methods of the present invention are implemented.
[0054] An embodiment of the present invention provides a readable storage medium, which stores a program or instruction. When the program or instruction is executed by a processor, the various processes of the embodiment of the cache allocation method such as any of the above-mentioned items are implemented, and the same technical effect can be achieved. To avoid repetition, they will not be described here.
[0055] The present application also provides a computer program product including computer instructions, which, when executed by a processor, implement the above Figure 1 The various processes of the method embodiment shown can achieve the same technical effect, and to avoid repetition, they will not be described here.
[0056] Computer-readable media includes both permanent and non-permanent, removable and non-removable media, and can be implemented using any method or technology for information storage. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change RAM (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0057] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, and storage of user personal information involved in the technical solutions disclosed herein comply with relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken with respect to user personal information to prevent unauthorized access to user personal information data and maintain the security of user personal information and network security.
[0058] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0059] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0060] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, or the part that contributes to the existing technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a service classification device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of this application.
[0061] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A cache allocation method, characterized in that: include: Acquire a multi-feature data stream, and extract a target feature vector of the multi-feature data stream; Inputting the expected cache miss rate preset by the user and the target feature vector into a cache policy decision model, the cache policy decision model outputting an optimal cache eviction policy based on the expected cache miss rate preset by the user and the target feature vector, then inputting the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector into a cache capacity prediction model, the cache capacity prediction model outputting a target cache capacity allocation result based on the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector; The cache capacity prediction model and the cache strategy decision model are trained in the following manner: The cache policy decision model inputs the predicted optimal cache eviction policy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache policy decision model according to the predicted capacity allocation result.
2. The cache allocation method according to claim 1, wherein: The characteristic indicators used to extract the target feature vector in the multi-feature data stream include at least one of the following: data repetition frequency distribution, repeated data ratio, cumulative distribution of the number of data intervals between repeated data, data stream information entropy, distribution of the shortest time interval between repeated data, distribution of time intervals between adjacent data, data stream statistical period and data stream calendar effect.
3. The cache allocation method according to claim 1, wherein: The extracting the target feature vector of the multi-feature data stream includes: The multi-feature data stream is input into the feature engineering module, data preprocessing is performed on the multi-feature data stream to obtain a preprocessed multi-feature data stream, and feature extraction is performed on the preprocessed multi-feature data stream according to a preset data stream statistical time window size to obtain a target feature vector.
4. The cache allocation method according to claim 1, wherein: Also includes: Training the cache capacity prediction model; Specifically include: Obtaining a first sample multi-feature data stream; Extracting a first feature vector of the first sample multi-feature data stream, and constructing a first cache miss rate curve data set of the first sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a first expected cache miss rate preset by a user, a cache eviction policy read from the first cache miss rate curve dataset, a first feature vector, and the first cache miss rate curve dataset into the cache capacity prediction model to be trained, training the cache capacity prediction model, and the cache capacity prediction model outputting a first cache capacity allocation result predicted under current conditions; A first loss is calculated based on the predicted first cache capacity allocation result and the optimal cache capacity allocation result corresponding to the cache eviction strategy read from the first cache miss rate curve data set, and the cache capacity prediction model is optimized by the first loss to obtain a trained cache capacity prediction model.
5. The cache allocation method according to claim 4, characterized in that: Also includes: Training the cache strategy decision model; Specifically include: Obtaining a second sample multi-feature data stream; Extracting a second feature vector of the second sample multi-feature data stream, and constructing a second cache miss rate curve data set of the second sample multi-feature data stream based on a cache miss rate curve algorithm; Inputting a second expected cache miss rate, a second feature vector, and a second cache miss rate curve data set preset by a user into the cache policy decision model to be trained, and the cache policy decision model outputs an optimal cache eviction policy predicted under current conditions; Inputting the predicted optimal cache eviction policy into a cache capacity prediction model, the cache capacity prediction model outputting a predicted second cache capacity allocation result; A reward function is constructed based on the predicted second cache capacity allocation result and the optimal cache capacity allocation result output by the cache capacity prediction model under the same input, and the cache policy decision model is optimized by the reward function to obtain a trained cache policy decision model.
6. The cache allocation method according to claim 5, characterized in that: The constructing of a first cache miss rate curve data set of the first sample multi-feature data stream based on a cache miss rate curve algorithm includes: Step a: obtaining a first eviction policy and a first data flow according to a cache size range to be evaluated set by a user and a cache eviction policy pool given based on the cache size range, wherein the first eviction policy belongs to a cache eviction policy pool, the cache eviction policy pool includes at least one eviction policy, and the first data flow belongs to a first data flow group, the first data flow group includes at least one data flow; Step b: using the first data stream to simulate the cache operation of each access request under caches of different sizes, and calculating the miss rate of each access request under the size of each cache to obtain the cache miss rate; Step c: generating a cache miss rate curve according to the cache miss rate; Step d: determining whether the cache miss rate curve has been fitted for each eviction policy in the cache policy pool for the data flows in the first data flow group; if not all eviction policies have been traversed, repeating steps b and c until all eviction policies have been traversed; Step e: Determine whether the cache miss rate curve has been fitted for all collected data streams. If not all data streams have been traversed, repeat steps b to d until all data streams have been traversed to obtain the target cache miss rate curve dataset.
7. A cache allocation device, characterized in that: include: A first processing module is used to obtain a multi-feature data stream and extract a target feature vector of the multi-feature data stream; a second processing module, configured to input an expected cache miss rate preset by a user and the target feature vector into a cache policy decision model, wherein the cache policy decision model outputs an optimal cache eviction policy based on the expected cache miss rate preset by the user and the target feature vector, and further input the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector into a cache capacity prediction model, wherein the cache capacity prediction model outputs a target cache capacity allocation result based on the optimal cache eviction policy, the expected cache miss rate preset by the user, and the target feature vector; The cache capacity prediction model and the cache strategy decision model are trained in the following manner: The cache policy decision model inputs the predicted optimal cache eviction policy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache policy decision model according to the predicted capacity allocation result.
8. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps in the cache allocation method according to any one of claims 1 to 6.
9. A readable storage medium, characterized in that The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps in the cache allocation method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps in the cache allocation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Cache replacement system and method based on imitation learning
CN114780889A
CPU (Central Processing Unit) shared cache division method for real-time tasks of embedded system
CN115658344A
Database caching strategy adjusting method, device and equipment
CN118796896A
High-performance-oriented intelligent cache replacement policy adaptive to prefetching
WO2022247070A1