A method, apparatus, device, medium, and program product for cache allocation

By acquiring multi-feature data streams and utilizing cache policy decision models and cache capacity prediction models, the optimal policy selection for the cache eviction policy pool and the optimal resource allocation for cache capacity are achieved. This solves the problem of global optimality in cache management in existing technologies, improves resource utilization efficiency, and reduces management costs.

CN120653451BActive Publication Date: 2025-11-04CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511134810.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-14
Publication Date
2025-11-04
Estimated Expiration
2045-08-14

AI Technical Summary

Technical Problem

Existing cache management technologies, given a target cache miss rate, only consider cache size settings or data eviction rules, making it difficult to achieve globally optimal cache capacity and resource allocation.

Method used

By acquiring multi-feature data streams, extracting target feature vectors, and utilizing cache strategy decision models and cache capacity prediction models, based on the user-preset expected cache miss rate and target feature vectors, the optimal cache eviction policy and target cache capacity allocation results are output, thereby achieving optimal policy selection for the cache eviction policy pool and optimal resource allocation for cache capacity.

Benefits of technology

It improves the utilization efficiency of cache resources, reduces management costs, enhances resource efficiency, and solves the problem of achieving global optimization that is difficult in existing technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653451B_ABST
    Figure CN120653451B_ABST
Patent Text Reader

Abstract

The application provides a cache allocation method, device, equipment, medium and program product, and relates to the technical field of artificial intelligence. The method comprises the following steps: acquiring a multi-feature data stream, and extracting a target feature vector of the multi-feature data stream; inputting an expected cache miss rate set by a user in advance and the target feature vector into a cache strategy decision model, outputting an optimal cache eviction strategy, and inputting the optimal cache eviction strategy, the expected cache miss rate set by the user in advance and the target feature vector into a cache capacity prediction model, and outputting a target cache capacity allocation result. In the application, real-time data streams are taken as inputs to realize optimal strategy selection of a cache eviction strategy pool and optimal resource allocation of cache capacity respectively. Through mutual promotion of working capabilities of the cache strategy decision model and the cache capacity prediction model, the two cache management modes are efficiently realized, the management cost is greatly reduced, and the resource efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of artificial intelligence, and in particular to a cache allocation method, device, equipment, medium and program product. BACKGROUND

[0002] At present, the technical route of cache management mainly researches and applies the construction of cache expansion and contraction mechanism or the formulation of cache eviction strategy respectively. However, for different characteristic data stream inputs, the cache miss rate and cache capacity correlation relationship presented by different eviction strategies are different. When a given expected cache miss rate (or hit rate) is given, the cache size setting or data elimination rule is considered one-sidedly, the optimal strategy selection and the optimal resource allocation of cache capacity cannot be considered at the same time, and it is difficult to achieve global optimization. SUMMARY

[0003] Embodiments of the present application provide a cache allocation method, device, equipment, medium and program product to solve the problem that the existing given expected cache miss rate is considered one-sidedly and it is difficult to achieve global optimization.

[0004] In order to solve the above technical problems, the present application is implemented as follows:

[0005] In a first aspect, the embodiments of the present application provide a cache allocation method, comprising:

[0006] Obtaining a multi-feature data stream and extracting a target feature vector of the multi-feature data stream;

[0007] Inputting an expected cache miss rate set by a user in advance and the target feature vector into a cache strategy decision model, the cache strategy decision model outputs an optimal cache eviction strategy based on the expected cache miss rate set by the user in advance and the target feature vector, and then inputting the optimal cache eviction strategy, the expected cache miss rate set by the user in advance and the target feature vector into a cache capacity prediction model, the cache capacity prediction model outputs a target cache capacity allocation result based on the optimal cache eviction strategy, the expected cache miss rate set by the user in advance and the target feature vector;

[0008] The cache capacity prediction model and the cache strategy decision model are trained by the following method:

[0009] The cache strategy decision model inputs the predicted optimal cache eviction strategy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache strategy decision model according to the predicted capacity allocation result.

[0010] Optionally, the feature indicators used for extracting the target feature vector in the multi-feature data stream include at least one of the following: data repetition frequency distribution, repetition data ratio, cumulative distribution of data number between repeated data, data stream information entropy, shortest time interval distribution between repeated data, time interval distribution between adjacent data, data stream statistical period, and data stream calendar effect.

[0011] Optionally, the extracting the target feature vector of the multi-feature data stream includes:

[0012] inputting the multi-feature data stream into a feature engineering module, performing data preprocessing on the multi-feature data stream to obtain a preprocessed multi-feature data stream, and performing feature extraction on the preprocessed multi-feature data stream according to a preset data stream statistical time window size to obtain a target feature vector.

[0013] Optionally, the method further includes:

[0014] training the cache capacity prediction model;

[0015] Specifically, the method includes:

[0016] obtaining a first sample multi-feature data stream;

[0017] 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;

[0018] inputting a first expected cache miss rate set by a user in advance, a cache eviction strategy read from the first cache miss rate curve data set, the first feature vector, and the first cache miss rate curve data set into the cache capacity prediction model to be trained, training the cache capacity prediction model, and outputting a first cache capacity allocation result predicted under a current condition by the cache capacity prediction model;

[0019] calculating a first loss according to the predicted first cache capacity allocation result and an optimal cache capacity allocation result corresponding to the cache eviction strategy read from the first cache miss rate curve data set, and optimizing the cache capacity prediction model through the first loss to obtain a trained cache capacity prediction model.

[0020] Optionally, the method further includes:

[0021] training the cache strategy decision model;

[0022] Specifically, the method includes:

[0023] obtaining a second sample multi-feature data stream;

[0024] 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;

[0025] inputting the second expected cache miss rate, the second feature vector and the second cache miss rate curve data set set by the user in advance into the cache strategy decision model to be trained, and outputting a predicted optimal cache eviction strategy under a current condition by the cache strategy decision model;

[0026] inputting the predicted optimal cache eviction strategy into a cache capacity prediction model, and outputting a predicted second cache capacity allocation result by the cache capacity prediction model;

[0027] constructing a reward function according to the predicted second cache capacity allocation result and an optimal cache capacity allocation result output by the cache capacity prediction model under the same input, and optimizing the cache strategy decision model by the reward function to obtain a trained cache strategy decision model.

[0028] Optionally, the cache miss rate curve algorithm based on the first sample multi-feature data stream includes:

[0029] Step a: obtaining a first eviction strategy and a first data stream according to a cache size range to be evaluated set by a user and a cache eviction strategy pool given based on the cache size range, the first eviction strategy belonging to the cache eviction strategy pool, the cache eviction strategy pool including at least one eviction strategy, and the first data stream belonging to a first data stream group, the first data stream group including at least one data stream;

[0030] Step b: simulating cache operations of each access request under different sizes of caches by using the first data stream, and calculating a miss rate of each access request under each size of cache according to the size to obtain a cache miss rate;

[0031] Step c: generating a cache miss rate curve according to the cache miss rate;

[0032] Step d: judging whether the data stream in the first data stream group has performed cache miss rate curve fitting on each eviction strategy in the cache strategy pool, if not all the eviction strategies have been traversed, repeating steps b and c until all the eviction strategies are traversed;

[0033] Step e: judging whether cache miss rate curve fitting has been performed on each group of data streams collected, if not all the data streams have been traversed, repeating steps b to d until all the data streams are traversed to obtain a target cache miss rate curve data set.

[0034] In a second aspect, an embodiment of the present application provides a cache allocation device, comprising:

[0035] A first processing module is configured to acquire a multi-feature data stream and extract a target feature vector of the multi-feature data stream.

[0036] A second processing module is configured to input a user-pre-set expected cache miss rate and the target feature vector into a cache strategy decision model, and output an optimal cache eviction strategy based on the user-pre-set expected cache miss rate and the target feature vector.

[0037] The cache strategy decision model is trained by the following method:

[0038] The cache strategy decision model is trained by the following method:

[0039] In a third aspect, an embodiment of the present application 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 is executed by the processor to implement the steps in the cache allocation method according to any one of the first aspect.

[0040] In a fourth aspect, an embodiment of the present application provides a readable storage medium, wherein the readable storage medium stores a program or instruction, and the program or instruction is executed by a processor to implement the steps in the cache allocation method according to any one of the first aspect.

[0041] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising computer instructions, and the computer instructions are executed by a processor to implement the steps in the cache allocation method according to any one of the first aspect.

[0042] In the present application, a multi-feature data stream is acquired, and a target feature vector of the multi-feature data stream is extracted; an expected cache miss rate set by a user in advance and the target feature vector are input into a cache strategy decision model, an optimal cache eviction strategy is output, and the optimal cache eviction strategy, the expected cache miss rate set by the user in advance and the target feature vector are input into a cache capacity prediction model, and a target cache capacity allocation result is output. In the present application, the data stream is taken as an input to realize optimal strategy selection of a cache eviction strategy pool and optimal resource allocation of a cache capacity respectively, and through mutual promotion of working capabilities of the cache strategy decision model and the cache capacity prediction model, two cache management modes are efficiently realized, management cost is greatly reduced and resource efficiency is improved, and the problem that given an expected cache miss rate, it is difficult to realize global optimization by one-sidedly considering cache size setting or data elimination rules is solved. BRIEF DESCRIPTION OF DRAWINGS

[0043] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The detailed description is made with reference to the accompanying drawings.

[0044] Figure 1 is a flowchart of a cache allocation method provided by an embodiment of the present application;

[0045] Figure 2 is an MRC trend diagram under various cache eviction strategies of a cache allocation method provided by an embodiment of the present application;

[0046] Figure 3 is a flowchart of MRC data set construction of a cache allocation method provided by an embodiment of the present application;

[0047] Figure 4 is a schematic diagram of a cache capacity intelligent allocation device of a cache allocation method provided by an embodiment of the present application;

[0048] Figure 5 is a training schematic diagram of a cache capacity prediction model of a cache allocation method provided by an embodiment of the present application;

[0049] Figure 6 is a schematic diagram of influence of cache eviction strategy selection on optimal cache capacity allocation of a cache allocation method provided by an embodiment of the present application;

[0050] Figure 7 is a schematic diagram of a cache eviction strategy intelligent allocation device of a cache allocation method provided by an embodiment of the present application;

[0051] Figure 8is a linear cost function diagram of a cache allocation method provided by an embodiment of the present application;

[0052] Figure 9 is an exponential cost function diagram of a cache allocation method provided by an embodiment of the present application;

[0053] Figure 10 is a parabolic cost function diagram of a cache allocation method provided by an embodiment of the present application;

[0054] Figure 11 is a step cost function diagram of a cache allocation method provided by an embodiment of the present application;

[0055] Figure 12 is a segmented cost function diagram of a cache allocation method provided by an embodiment of the present application;

[0056] Figure 13 is a segmented cost function diagram of another cache allocation method provided by an embodiment of the present application;

[0057] Figure 14 is a general flowchart of a cache allocation method provided by an embodiment of the present application;

[0058] Figure 15 is a structural diagram of a cache allocation device provided by an embodiment of the present application;

[0059] Figure 16 is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0060] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0061] Please refer to Figure 1 The embodiment of the present application provides a cache allocation method, which comprises the following steps:

[0062] Step 11: acquiring a multi-feature data stream and extracting a target feature vector of the multi-feature data stream;

[0063] In the embodiment of the present application, the multi-feature data stream comes from different data sources, and a collection window length is set The collection window length can be consistent with the window size selected in the training stage of the cache strategy decision model and the cache capacity prediction model, and the collection window length can be adjusted according to the actual situation. collecting the multi-feature data stream of the time period ; and inputting the data stream of the time period to a feature extraction module to obtain a corresponding target feature vector ; collecting the multi-feature data stream of the time period and inputting the data stream of the time period to a feature extraction module to obtain a corresponding target feature vector ; by extracting the target feature vector of the multi-feature data stream, the cache resources can be more reasonably allocated, redundant storage is avoided, and the utilization efficiency of storage and computing resources is improved; and every time, the multi-feature data stream is automatically repeatedly acquired and subsequent operations are performed, which is easy to operate and saves a large amount of human management cost.

[0064] Step 12: inputting the target feature vector and the expected cache miss rate set by the user in advance into a cache strategy decision model, wherein the cache strategy decision model outputs an optimal cache eviction strategy based on the target feature vector and the expected cache miss rate set by the user in advance, and then inputting the optimal cache eviction strategy, the target feature vector and the expected cache miss rate set by the user in advance 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 strategy, the target feature vector and the expected cache miss rate set by the user in advance;

[0065] The cache capacity prediction model and the cache strategy decision model are obtained by the following method:

[0066] The cache strategy decision model inputs the predicted optimal cache eviction strategy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache strategy decision model according to the predicted capacity allocation result.

[0067] In the embodiment of the application, the cache management party or the user sets an expected cache miss rate in accordance with the system running state and access demand of the method for realizing cache allocation , determines a candidate strategy pool , wherein the candidate strategy pool is consistent with the strategy pool used in the training stage of the cache strategy decision model and the cache capacity prediction model, and a state vector is constructed from the target feature vector and input into the cache strategy decision model , and the cache strategy decision model selects an optimal cache eviction strategy from as the optimal cache eviction strategy used by the cache system in the time period; then the target feature vector , the expected cache miss rate The joint input is input to the cache capacity prediction model, and the cache capacity prediction model outputs a target cache capacity allocation result As a cache system The cache size used in the time period is decided by the cache strategy decision model and input to the cache capacity prediction model at a high speed, so that the cache strategy decision model and the cache capacity prediction model can be efficiently and almost synchronously parallel, the method of simultaneously implementing intelligent allocation of the eviction strategy and intelligent allocation of the cache capacity breaks the dilemma of the current two cache management paths, forms a reliable and credible decision scheme from the perspective of global optimization, takes into account the service quality and system expenditure of the cache system, and makes up for the shortcomings of the timeliness of the real-time demand feedback of the traditional cache management.

[0068] In the embodiment of the application, the cache eviction strategy selection and the cache capacity allocation jointly determine the system service capability and benefit, and obtaining the optimal cache eviction strategy is a necessary prerequisite for the cache capacity prediction model to output a globally optimal solution, and accurate cache capacity prediction also provides a solid foundation for the performance improvement of the cache strategy decision model, so the cache eviction strategy selection and the cache capacity allocation are indispensable in cache management, and as the characteristics of real-time data streams change and the expected cache miss rate of users is different, the cache strategy decision model needs to adaptively and intelligently output the most suitable eviction strategy to the cache capacity prediction model, so as to jointly form an optimal solution.

[0069] In the embodiment of the application, the multi-feature data stream is obtained, and a target feature vector of the multi-feature data stream is extracted; an expected cache miss rate set by a user in advance and the target feature vector are input to a cache strategy decision model, the cache strategy decision model outputs an optimal cache eviction strategy, and the optimal cache eviction strategy, the expected cache miss rate set by the user in advance and the target feature vector are input to a cache capacity prediction model, and the cache capacity prediction model outputs a target cache capacity allocation result. In the application, the real-time data stream is taken as an input to realize optimal strategy selection of a cache eviction strategy pool and optimal resource allocation of a cache capacity, respectively, through mutual promotion of the working capacity of the cache strategy decision model and the cache capacity prediction model, the two cache management modes are efficiently and synchronously parallel, the management cost is greatly reduced and the resource efficiency is improved, and the problem that given an expected cache miss rate, it is difficult to achieve global optimization by only considering cache size setting or data elimination rules is solved.

[0070] In the embodiment of the application, 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, repetition data ratio, cumulative distribution of the number of data between repeated data, data stream information entropy, shortest time interval distribution between repeated data, time interval distribution between adjacent data, data stream statistical period and data stream calendar effect.

[0071] In the embodiment of the present application, in order to ensure the comprehensiveness and representativeness of the data feature collection of the multi-feature data stream, the feature pre-selection range needs to be expanded as much as possible under the premise of meeting the data availability and reliable quality, and new features are also constructed 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 application mainly include distribution feature class, time period class, and other class, wherein the distribution feature class includes data repetition frequency distribution, repetition data ratio, data number cumulative distribution of interval between repetition data, and data stream information entropy; the time period class includes shortest time interval distribution between repetition data and time interval distribution between adjacent data; and the other class includes data stream statistical period and data stream calendar effect.

[0072] When performing data stream feature extraction, the size of the time window for data stream statistics needs to be specified artificially in advance, such as 60 seconds, 1 hour, 1 day, etc. The window size is closely related to the adjustment frequency of the cache strategy and cache capacity, such as collecting information once every 1 hour and extracting the data stream features within 1 hour, which means that the cache eviction strategy and capacity size can be adjusted once every hour according to the latest features.

[0073] Specifically, in a certain time window, the data repetition frequency distribution in the distribution feature class mainly statistics the frequency distribution of repeated data access requests, and the mean, standard deviation, kurtosis and skewness of the distribution are taken as the feature values of the indicator; the repetition data ratio is the proportion of repeated access data in the total data; the data number cumulative distribution of interval between repetition data mainly statistics the distribution of the sum of other access times between all adjacent repetition data accesses, and the mean, standard deviation, kurtosis and skewness of the distribution are taken as the feature values of the indicator; the data stream information entropy first determines the probability of each data value or access request in the data stream, and then calculates the information entropy of the data stream according to the probability distribution. The shortest time interval distribution between repetition data in the time period class mainly statistics the distribution of the shortest time interval between all adjacent repetition data accesses, and the mean, standard deviation, kurtosis and skewness of the distribution are taken as the feature values of the indicator; the time interval distribution between adjacent data mainly statistics the distribution of the time interval between all adjacent data accesses, and the mean, standard deviation, kurtosis and skewness of the distribution are taken as the feature values of the indicator. The data stream statistical period in the other class takes seconds as the unit to statistics the size of the time window, for example, the feature value is 60 when the window period is 1 minute; the data stream calendar effect mainly investigates whether the window period is in the weekend and statutory holidays, and takes 0 or 1 to represent weekdays or holidays respectively, which takes into account the possible periodic characteristics of data access.

[0074] Optionally, in the embodiment of the application, the target feature vector of the multi-feature data stream is extracted, including:

[0075] 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.

[0076] In the embodiment of the application, in order to reduce the model calculation complexity and feature redundancy, the feature engineering module performs secondary processing on the initially selected features, including but not limited to various feature selection and feature compression dimension reduction methods. For example, commonly used feature selection methods can be selected from maximum information number (MIC), correlation feature selection (CFS), recursive feature elimination (RFE), stability selection (RL), lasso algorithm (LASSO), ridge regression algorithm (RR) and random forest algorithm (RF), etc. Feature selection can directly select several important features from a group of features through information coefficients, correlation coefficients, regression coefficients and other discriminant indicators. The number and types of features selected by different methods are different. The feature compression method includes principal component analysis (PCA), factor analysis (FA) and singular value decomposition (SVD), etc. Feature compression linearly combines original features under certain rules to form new features with lower dimensions and less information loss. The feature engineering module can enable users to arbitrarily select or switch the required feature dimension reduction method through relevant code design, or support not using any dimension reduction strategy when the total number of features is small.

[0077] The feature engineering module selects feature types to obtain a feature vector matrix, which is used for subsequent model training and actual system. Considering the modeling calculation overhead, the most representative data stream feature types are extracted and the final feature vector is determined according to all available historical data stream information. After the required feature types are specified, the directly carried information of the real-time collected data stream, system running state information, etc. are statistically processed, missing values are filled, abnormal values are detected and replaced, and normalization or standardization processing is performed, to finally form a real-time feature vector or feature matrix of the data stream, thereby providing high-quality information input for model pre-training and cache system real-time management. The feature engineering module undertakes the feature extraction and feature compression of the data stream, effectively extracts representative features of multi-source and multi-type data streams, constructs a feature vector, and is used for subsequent model training, so that the cache strategy decision model and the cache capacity prediction model which have learned a large amount of prior feature knowledge can output results in real time using real-time data stream feature data in actual system operation, ensuring the timeliness of the cache management process.

[0078] Optionally, the embodiment of the application further comprises:

[0079] training the cache capacity prediction model;

[0080] Specifically comprising:

[0081] obtaining a first sample multi-feature data stream;

[0082] 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;

[0083] inputting a first expected cache miss rate set by a user, a cache eviction strategy read from the first cache miss rate curve data set, the first feature vector and the first cache miss rate curve data set into the cache capacity prediction model to be trained, training the cache capacity prediction model, and outputting a first cache capacity allocation result predicted under a current condition by the cache capacity prediction model;

[0084] calculating a first loss according to the predicted first cache capacity allocation result and an optimal cache capacity allocation result corresponding to the cache eviction strategy read from the first cache miss rate curve data set, optimizing the cache capacity prediction model through the first loss, and obtaining a trained cache capacity prediction model.

[0085] In the embodiment of the application, the cache miss rate curve algorithm based on the first sample multi-feature data stream to construct the first cache miss rate curve data set comprises:

[0086] Step a: obtaining a first eviction strategy and a first data stream according to a cache size range to be evaluated set by a user and a cache eviction strategy pool given based on the cache size range, the first eviction strategy belonging to the cache eviction strategy pool, the cache eviction strategy pool including at least one eviction strategy, and the first data stream belonging to a first data stream group, the first data stream group including at least one data stream;

[0087] Step b: simulating cache operations of each access request under different sizes of caches using the first data stream, and calculating a miss rate of each access request under the size of each cache according to the size of each cache to obtain a cache miss rate;

[0088] Step c: generating a cache miss rate curve according to the cache miss rate;

[0089] Step d: judging whether the data stream in the first data stream group has performed cache miss rate curve fitting on each eviction strategy in the cache strategy pool, if not all the eviction strategies have been traversed, repeating steps b and c until all the eviction strategies are traversed;

[0090] Step e: judging whether the cache miss ratio curve fitting is performed on all collected data streams, if not all data streams are traversed, repeating steps b to d until all data streams are traversed, and obtaining the target cache miss ratio curve data set.

[0091] In the embodiment of the present application, 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, which can provide a scientific and reasonable basis for cache expansion and contraction strategy. The present application constructs a training data set by MRC algorithm and uses it for cache capacity prediction model, so that the cache capacity prediction model can obtain the decision ability of cache expansion and contraction according to the real-time characteristics of data stream and the prior knowledge from MRC, greatly reducing the time consumption and significantly improving the decision efficiency of capacity allocation. In addition, for a group of the same data stream, the MRC curve usually presents different trends under different cache eviction strategies, as shown in Figure 2 , by comprehensively investigating the MRC curves of all strategies, the optimal cache eviction strategy and cache capacity under the data stream can be effectively determined. For example, Figure 2 , in the case of given expected cache miss ratio 50%, the optimal cache eviction strategy and cache capacity corresponding to the data stream are FIFO and 50GiB respectively. Therefore, when constructing the MRC data set, the curve trend of each type of method in the cache eviction strategy pool under various characteristic data streams needs to be considered.

[0092] Specifically, please refer to Figure 3, first perform step a, determine the cache size range to be evaluated, the upper limit of the range can be determined based on the self cache capacity requirements or economic budget, then the range is divided into certain interval size, the smaller the division granularity, the more accurate the cache miss rate curve fitting, the richer the data information, but the larger the workload, for example, when the evaluation range is 0~100GiB, if the cache slice size is increased by 10GiB, a total of 10 different size caches need to be simulated, and if the cache slice size is increased by 5GiB, a total of 20 simulations are needed. The division granularity can be determined comprehensively with the MRC generation algorithm efficiency, the required data set size, etc. Based on the given cache eviction policy pool, a selected eviction policy is determined, and a set of data streams is determined, wherein the data stream contains data access patterns; perform step b, simulate cache operation, by using the collected access patterns, simulate whether each access request is cached hit under different size of cache, for each cache size, calculate the miss rate of all requests under that size, that is, the cache miss rate; perform step c, generate MRC, take different cache capacity as the abscissa, and the miss rate as the ordinate, draw the corresponding MRC by linear interpolation or cubic spline interpolation of the discrete points in the data set; perform step d, examine whether the cache miss rate curve fitting is performed for various eviction strategies in the cache strategy pool under the same set of data streams, if all strategies have not been traversed, repeat steps b and c until all strategies are completed; perform step e, examine whether the cache miss rate curve fitting is performed for all collected data streams, if all data streams (or data access patterns) have not been traversed, repeat steps b to d until all data streams are completed, and the target cache miss rate curve data set is obtained.

[0093] In the embodiments of the present application, the following algorithms can be used, but are not limited to: Mattson algorithm, SHARDS algorithm, MiniSim algorithm and Kosmo algorithm, etc. The Mattson algorithm is the earliest algorithm that can be used to construct MRC and can be used for data simulation of LRU cache strategy. It records all accessed objects by maintaining an LRU stack, 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 efficiency of MRC generation by processing only a sampling subset of access requests, and generally has a lower fitting error. The MiniSim algorithm can model any cache eviction strategy and generate MRC by independently simulating caches of different sizes, while using the SHARDS sampling method to improve the generation efficiency. The Kosmo algorithm allows MRC to be generated for multiple cache eviction strategies at the same time. It calculates the reuse distance by using the eviction map and reconstructs the cache stack of different sizes using a single data copy, which has lower memory overhead and higher throughput. In the above algorithms, although the Mattson method has high fitting accuracy, its application scenario is limited and is only suitable for MRC generation of LRU strategy. The MiniSim method has strong universality, but it needs to maintain a complete cache structure for each cache size, which has high memory overhead. The Kosmo method optimizes memory usage and calculation efficiency based on MiniSim, providing a more efficient and economical solution. Since the step of generating related data set based on MRC algorithm mainly serves the model pre-training, the quality of data set mainly affects the model performance and decision effect, and the time cost of constructing data set will not affect the real-time performance of subsequent cache intelligent allocation operation. Therefore, the MRC generation algorithm with high fitting accuracy (the accuracy refers to whether the cache miss rate value obtained in the data access experiment can accurately reflect the actual situation) is preferred, and the time cost of obtaining data set can be appropriately reduced in priority according to the actual situation. In the embodiments of the present application, the accuracy, robustness and efficiency of the algorithm are considered comprehensively, and the Kosmo algorithm is taken as a specific embodiment to realize the creation of MRC data set. The MRC data set construction method based on multiple characteristics constructs data set for training and optimizing cache allocation model according to different data flow characteristics, generates high-precision MRC data set for different data flow scenarios, which helps to significantly improve the model training effect and the accuracy of cache allocation decision, and opens up a new prediction scenario and technical demand by constructing and applying multiple characteristic MRC data set, providing a solid data foundation for cache capacity prediction and miss rate prediction, so as to realize the precise optimization and adaptability enhancement of cache capacity management.

[0094] Please refer to Figure 4In this embodiment of the invention, the cache capacity prediction model in the intelligent cache capacity allocation device is trained to improve the accuracy and robustness of cache capacity prediction, providing scientific support for cache elastic 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 MRC generation algorithm to output training data.

[0095] For details, please refer to Figure 4 When a user pre-sets a desired cache miss rate and a set of data streams And its feature vector is obtained based on the feature engineering module. ( , (Total number of data stream sample groups), with cache eviction policy as follows: hour( , (Cache eviction policy pool size), cache capacity prediction model It should be able to provide the optimal cache capacity allocation under the current conditions. ,Right now Cache capacity prediction model Its predictive ability is mainly achieved by learning the corresponding data stream. MRC training set ;like Figure 5 As shown, the input to the cache capacity prediction model mainly includes three aspects: data flow feature vector. Expected cache miss rate and cache eviction policy ,in This is a vector formed by concatenating all the feature index values ​​after standardization or normalization. and You can directly based on Table retrieval For numerical values, for A dimensional vector, whose dimensional vector is the first dimensional vector. The input label is obtained by setting one element to 1 and the rest to 0. Similarly, the optimal cache size under this condition is... You can also directly in In this embodiment of the invention, "optimal" refers to the fact that under the same eviction policy, different cache sizes may correspond to the same or very close cache miss rates. In this case, the cache size with the smallest miss rate should be selected, thereby obtaining the final output label. This refers to the predicted first cache capacity allocation result. For example: in Figure 5 The first inspection Group data stream and using an eviction policy , corresponding , using an eviction policy , corresponding . As the cache partitioning step size decreases, the richer the information, the stronger the feature capturing ability of the cache capacity prediction model, and in addition, since interpolation methods can be used to continuously fill in the discrete points of , in theory, for any given cache miss rate , the corresponding optimal cache capacity can be found.

[0096] After determining the input and output forms of the cache capacity prediction model, the cache capacity prediction model itself needs to be constructed. Since the model input dimension is high, the structure is complex, and the MRC usually presents nonlinear, multi-volatility and other characteristics, therefore, in the embodiment of the present application, a deep learning algorithm is selected to model the cache capacity prediction model. Specifically, in the deep neural network, the input layer size is , wherein is the number of selected feature indicators, is the total number of alternative eviction policies, 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 various combinations according to needs, including but not limited to full connection network (Full-connected Networks), convolutional neural network (CNN), recurrent neural network (RNN), long short-term memory network (LSTM), attention mechanism (Attention), etc., and the activation function connecting the output layer is selected as ReLu activation. When optimizing the neural network parameters, the first loss function is set as the model predicted value and the true value an error form including but not limited to root mean square error (RMSE), mean absolute error (MAE), mean absolute percentage error (MAPE), etc., and then updating network parameters based on model loss and back propagation algorithm (BP). Through pre-training of the cache capacity prediction model on a large number of data stream samples and different eviction strategies, and in the subsequent actual use process, facing real-time data streams, after a specified expected cache miss rate, the cache allocation amount can be quickly, conveniently and accurately output according to 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, while ensuring the timeliness and reliability of the quality of service, the economic cost is minimized, the optimal cache allocation amount is output through intelligent prediction, the best utilization of cache resources under different loads and data characteristics is ensured, the intelligent allocation of cache capacity is realized by combining deep learning technology and training the prediction model through historical data, the resource management efficiency of the system is greatly improved, and the resource use cost is effectively reduced.

[0097] Optionally, in the embodiment of the application, the method further comprises:

[0098] training the cache strategy decision model;

[0099] Specifically, the method comprises:

[0100] obtaining a second sample multi-feature data stream;

[0101] 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;

[0102] inputting a second expected cache miss rate, the second feature vector and the second cache miss rate curve data set set by a user in advance into the cache strategy decision model to be trained, and the cache strategy decision model outputs a predicted optimal cache eviction strategy under current conditions;

[0103] inputting the predicted optimal cache eviction strategy into a cache capacity prediction model, and the cache capacity prediction model outputs a predicted second cache capacity allocation result;

[0104] constructing a reward function according to the predicted second cache capacity allocation result and an optimal cache capacity allocation result output by the cache capacity prediction model under the same input, and optimizing the cache strategy decision model through the reward function to obtain a trained cache strategy decision model.

[0105] Optionally, in the embodiment of the application, the cache capacity prediction model comprises:

[0106] Step a: obtaining a second eviction policy and a second data stream according to a user-set cache size range to be evaluated and a cache eviction policy pool given based on the cache size range, the second eviction policy belonging to the cache eviction policy pool, the cache eviction policy pool including at least one eviction policy, and the second data stream belonging to a first data stream group, the second data stream group including at least one data stream;

[0107] Step b: simulating cache operations of each access request under different sizes of caches by using the second data stream, and calculating a cache miss rate of each access request under each size of cache according to the size of the cache, to obtain a cache miss rate;

[0108] Step c: generating a cache miss rate curve according to the cache miss rate;

[0109] Step d: judging whether the data stream in the second data stream group has performed cache miss rate curve fitting on each eviction policy in the cache policy pool, if not all the eviction policies have been traversed, repeating steps b and c until all the eviction policies are traversed;

[0110] Step e: judging whether cache miss rate curve fitting has been performed on each group of data streams collected, if not all the data streams have been traversed, repeating steps b to d until all the data streams are traversed, to obtain a target cache miss rate curve data set.

[0111] In the embodiment of the application, the method for constructing the MRC data set is as described above; the cache eviction policy selection and the cache expansion and contraction decision jointly determine the system service capability and benefit, and obtaining the optimal cache eviction policy is a necessary prerequisite for the cache capacity prediction model to output the globally optimal solution, and the accurate cache capacity prediction also provides a solid foundation for the performance improvement of the cache strategy decision model, as shown in the following table: Figure 6 As shown in the MRC trend chart of the data stream of a certain data access request under two strategies, when the expected miss rate is 65%, strategy A is significantly better than strategy B, and 20 GiB of cache cost can be saved at this time; when the miss rate is 50%, strategy B has more economic advantages than strategy A, therefore, Figure 6 It is illustrated that the cache eviction policy selection and the cache capacity allocation are indispensable in cache management, and with the change of real-time data stream characteristics and the difference of user's expected cache miss rate, the cache strategy decision model needs to adaptively and intelligently output the most suitable eviction policy to the cache capacity prediction model, so as to form the optimal solution.

[0112] In the embodiment of the application, a deep reinforcement learning algorithm is used to model the cache strategy decision model in the cache eviction policy intelligent allocation device, wherein the five basic elements of reinforcement learning include state , action State transition matrix ,award and discounts ,Right now ,in Input to the model, For model output, The main objective of model parameter optimization is determined, such as Figure 7 As shown, the state vector User-defined expected cache miss rate and the collected data stream eigenvectors It is formed by concatenation, as mentioned above, with the input layer size of the reinforcement learning model set to... This model can be used in a given cache eviction policy pool. Select the optimal cache eviction strategy Action vector for A dimensional vector, whose dimensional vector is the first dimensional vector. An element being 1 indicates that the current model has selected the [number]th [element]. There are 1 strategy, and all other elements are 0, so the output layer size is 1. Note the output of the reinforcement learning model. The follow-up will be with and The data is concatenated and input into the cache capacity prediction model, therefore... The merits of the action can be determined by comparing the current capacity prediction results with the predicted optimal capacity size. Within the technical context of this proposal, the next phase state... Unaffected by the current state and current actions The influence of this can be considered that the state transition is deterministic, i.e. It is a matrix of all 1s.

[0113] In the reward function and discount factor In terms of configuration, in this embodiment of the invention, according to... The results obtained from the input to the intelligent cache capacity allocation model, namely the predicted second cache capacity allocation result, are compared and cost-analyzed with the globally optimal result output by the cache capacity prediction model under the same input, thereby constructing a reward function and determining a discount factor.

[0114] Specifically, let the strategy given by the caching strategy decision model... Output of cache capacity prediction model And let the minimum cache size that the cache capacity prediction model can provide under the same conditions be... Assuming it follows a cache eviction policy The time reaches the minimum value, that is Generally speaking, if , it indicates that the reinforcement learning model has optimal decision-making ability, otherwise there is still a parameter optimization space. However, in the process of cache management, it is one-sided to compare only the required cache size under the same conditions when evaluating the cache expansion and contraction mechanism, because it does not rule out that under certain pricing rules, the cost overhead of using two different sizes of caches within a certain capacity interval can be consistent, and at this time the decision that requires a larger cache should not be punished. Therefore, from the perspective of economic cost, the evaluation of the decision can better reflect the actual needs of cache management. Therefore, in the embodiment of the present application, the reinforcement learning reward function construction method based on the cost function is constructed, wherein the cost function is set as , which should present a monotonic non-decreasing trend with the increase of the cache capacity . Without loss of generality, as long as the trend is met, the can be expressed by any function form, please refer to Figures 8-13 , including but not limited to linear type (such as Figure 8 ), exponential type (such as Figure 9 ), parabolic type (such as Figure 10 ), step type (such as Figure 11 ), segmented type (hybrid type) (such as Figure 12 and Figure 13 ) and the like, since is monotonic and non-decreasing, the reward function can be set as: ; The higher the performance of the cache strategy decision model, the stronger the performance of the cache strategy decision model. In the technical background of the present application, the overall decision benefit (i.e. the amount of cache cost reduction) can be considered as the direct accumulation of the decision benefit of each period, without considering the historical discount effect, so the discount factor can be set as .

[0115] 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 various combinations as needed, the previous layer of the output layer will be activated by the softmax function, and each position of the neuron represents the probability size of selecting the corresponding eviction strategy. Then the one-hot function is activated in the output layer, which maps the neuron with the largest probability to 1 and the rest to 0. In the selection of reinforcement learning algorithm, since the action space is discrete, various algorithms based on value class (Value-based), policy class (Policy-based) or Actor-Critic class can achieve the design of the cache eviction strategy intelligent allocation device of the present application. The present application takes the most convenient policy gradient algorithm (Policy Gradients, PG) as a specific embodiment for illustration. According to the construction method of , the PG algorithm aims to obtain the expected return maximize J (a1, a2,..., an) = E [R (a1, a2,..., an) ], where

[0116]

[0117] where, is the action trajectory formed by all decisions, is the trajectory length (or the total number of decisions), is the neural network parameter. Since the larger the better, the PG algorithm uses the gradient boosting method to calculate the deterministic policy gradient and update the network parameters: is the update step size.

[0118] In the embodiment of the present application, by setting the expected cache miss rate threshold, the characteristics of the data stream are extracted and a policy selection model is constructed in the policy pool, and the optimal cache eviction policy is dynamically selected by using the reinforcement learning algorithm, thereby optimizing the use efficiency of the cache. The intelligentization and dynamic optimization of the cache eviction policy are realized through reinforcement learning, which greatly improves the adaptability and service efficiency of the system under different data streams, and lays a high-quality decision basis for cache capacity allocation. Therefore, when evaluating the cache eviction policy decision, the global optimal result output by the cache capacity prediction model is used as the evaluation standard, rather than directly finding the actual optimal result according to the MRC data set, which can effectively reduce the sampling variance and overfitting risk, and help to improve the model robustness and flexibility. Based on the construction and optimization of the cache policy decision model, in the subsequent actual use process, facing real-time data streams, after specifying the expected cache miss rate, the optimal policy can be quickly selected from the candidate eviction policy pool according to the data stream feature vector processed by the feature engineering module, which not only provides reliable policy decision basis for users, but also provides necessary input information for the cache capacity intelligent allocation device.

[0119] Please refer to Figure 14 In the embodiment of the present application, the cache eviction policy decision model in the cache eviction policy allocation device and the cache capacity prediction model in the cache capacity intelligent allocation device are constructed at the same time, the optimal cache eviction policy selection of the cache eviction policy pool and the optimal cache capacity allocation result of the cache capacity are realized according to the real-time data stream input, and the MRC data set is generated according to the data stream based on the MRC generation algorithm for model training and optimization. The optimal cache eviction policy and the optimal cache capacity allocation result 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, efficiently synchronize and parallelize the two cache management modes, greatly reduce the management cost and improve the resource efficiency, and solve the problem that the existing cache size setting or data elimination rule is difficult to achieve global optimization when a given expected cache miss rate is considered one-sidedly.

[0120] Reference is made to Figure 15 The embodiment of the present application provides a cache allocation device, comprising:

[0121] The first processing module 151 is configured to acquire a multi-feature data stream and extract a target feature vector of the multi-feature data stream.

[0122] The second processing module 152 is configured to input a user-pre-set expected cache miss rate and the target feature vector into a cache strategy decision model, and output an optimal cache eviction strategy based on the user-pre-set expected cache miss rate and the target feature vector.

[0123] The cache capacity prediction model and the cache strategy decision model are trained by the following method:

[0124] The cache strategy decision model inputs the predicted optimal cache eviction strategy into the cache capacity prediction model to obtain a predicted capacity allocation result, and optimizes the cache strategy decision model according to the predicted capacity allocation result.

[0125] In the embodiment of the present application, optionally, the feature indicators used for extracting 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 data number between repeated data, data stream information entropy, shortest time interval distribution between repeated data, time interval distribution between adjacent data, data stream statistical period and data stream calendar effect.

[0126] In the embodiment of the present application, optionally, the first processing module comprises:

[0127] The first processing sub-module is configured to input the multi-feature data stream into a feature engineering module, perform data preprocessing on the multi-feature data stream to obtain preprocessed multi-feature data stream, and perform feature extraction on the preprocessed multi-feature data stream according to a pre-set data stream statistical time window size to obtain a target feature vector.

[0128] In the embodiment of the present application, optionally, the device further comprises:

[0129] The first model training module is configured to train the cache capacity prediction model.

[0130] Specifically, the device comprises:

[0131] obtain a first sample multi-feature data stream;

[0132] extract a first feature vector of the first sample multi-feature data stream, and construct a first cache miss rate curve data set of the first sample multi-feature data stream based on a cache miss rate curve algorithm;

[0133] input a first expected cache miss rate set by a user in advance, a cache eviction strategy read from the first cache miss rate curve data set, the first feature vector and the first cache miss rate curve data set into the cache capacity prediction model to be trained, train the cache capacity prediction model, and output a first predicted cache capacity allocation result under a current condition by the cache capacity prediction model;

[0134] calculate a first loss according to the predicted first cache capacity allocation result and an optimal cache capacity allocation result corresponding to the cache eviction strategy read from the first cache miss rate curve data set, optimize the cache capacity prediction model through the first loss, and obtain a trained cache capacity prediction model.

[0135] In the embodiment of the application, the method further comprises:

[0136] a second model training module configured to train the cache strategy decision model;

[0137] Specifically, the method comprises:

[0138] obtain a second sample multi-feature data stream;

[0139] extract a second feature vector of the second sample multi-feature data stream, and construct a second cache miss rate curve data set of the second sample multi-feature data stream based on a cache miss rate curve algorithm;

[0140] input a second expected cache miss rate set by a user in advance, the second feature vector and the second cache miss rate curve data set into the cache strategy decision model to be trained, and output a predicted optimal cache eviction strategy under a current condition by the cache strategy decision model;

[0141] input the predicted optimal cache eviction strategy into a cache capacity prediction model, and output a predicted second cache capacity allocation result by the cache capacity prediction model;

[0142] construct a reward function according to the predicted second cache capacity allocation result and an optimal cache capacity allocation result output by the cache capacity prediction model under the same input, optimize the cache strategy decision model through the reward function, and obtain a trained cache strategy decision model.

[0143] Optionally, the first cache miss rate curve data set of the first sample multi-feature data stream is constructed based on the cache miss rate curve algorithm, and the first cache miss rate curve data set comprises:

[0144] Step a: obtaining a first eviction policy and a first data stream according to a cache size range to be evaluated and a cache eviction policy pool given based on the cache size range, the first eviction policy belonging to the cache eviction policy pool, the cache eviction policy pool comprising at least one eviction policy, and the first data stream belonging to a first data stream group, the first data stream group comprising at least one data stream;

[0145] Step b: simulating cache operations of each access request under different cache sizes using the first data stream, and calculating a cache miss rate of each access request under the size according to the size of each cache to obtain the cache miss rate;

[0146] Step c: generating a cache miss rate curve according to the cache miss rate;

[0147] Step d: determining whether the cache miss rate curve fitting is performed on each eviction policy in the cache policy pool for the data stream in the first data stream group, if all the eviction policies have not been traversed, repeating steps b and c until all the eviction policies are traversed;

[0148] Step e: determining whether the cache miss rate curve fitting is performed on each group of data streams collected, if all the data streams have not been traversed, repeating steps b to d until all the data streams are traversed to obtain a target cache miss rate curve data set.

[0149] The cache allocation device provided in the embodiment of the application can implement the processes of the method embodiment and achieve the same technical effects. Figure 1 The processes of the method embodiment and achieve the same technical effects.

[0150] The embodiment of the application provides an electronic device 160, referring to Figure 16 as shown, Figure 16 is a principle block diagram of the electronic device 160, comprising a processor 161, a memory 162, and a program or instruction stored in the memory 162 and executable on the processor 161, the program or instruction being executed by the processor to implement the steps in any cache allocation method of the application.

[0151] The embodiment of the application provides a readable storage medium, the readable storage medium storing a program or instruction, the program or instruction being executed by the processor to implement the processes of the embodiment of any cache allocation method as described above, and achieve the same technical effects, and details are not repeated here to avoid repetition.

[0152] The embodiment of the application further provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the above-mentioned Figure 1 The various processes of the method embodiment are implemented by the processor, and the same technical effects can be achieved. To avoid repetition, details are not described herein.

[0153] Computer readable media includes permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. The 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 memory (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 cassette, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device. According to the definition herein, computer readable media does not include transitory media such as modulated data signals and carriers.

[0154] It should be noted that in the technical solutions of the present disclosure, the collection, collection, update, analysis, processing, use, transmission, storage and other aspects of user personal information are in line with relevant laws and regulations, are used for legal purposes, and do not violate public order and good customs. Necessary measures are taken to prevent illegal access to user personal information data, and user personal information security and network security are maintained.

[0155] It should be noted that in this paper, the term "includes", "contains" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such process, method, article or device. Without more limitations, the element defined by the statement "includes a" does not exclude the presence of another identical element in the process, method, article or device including the element.

[0156] The above-mentioned serial numbers of the embodiments of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0157] Those skilled in the art can clearly understand the above-mentioned embodiment method can be realized by means of software and necessary general hardware platform, of course, also can be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application essentially or say the part of the prior art contribution can be embodied in the form of software products, the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc), including a number of instructions to make a service classification device (may be a mobile phone, computer, server, air conditioner, or network equipment, etc.) executes the method described in various embodiments of the present application.

[0158] The above only is the preferred embodiment of the present application, it should be pointed out that, for those skilled in the art, without departing from the principle of the present application, can make a number of improvements and refinements, these improvements and refinements should also be considered as the protection scope of the present application.

Claims

1. A method of cache allocation, characterized by, include: Acquire a multi-feature data stream and extract the target feature vector from the multi-feature data stream; The user-preset expected cache miss rate and the target feature vector are input into the cache strategy decision model. The cache strategy decision model outputs the optimal cache eviction policy based on the user-preset expected cache miss rate and the target feature vector. Then, the optimal cache eviction policy, the user-preset expected cache miss rate and the target feature vector are input into the cache capacity prediction model. The cache capacity prediction model outputs the target cache capacity allocation result based on the optimal cache eviction policy, the user-preset expected cache miss rate and the target feature vector. The cache capacity prediction model and the cache policy decision model are trained in the following way: The cache strategy decision model obtains the predicted capacity allocation result by inputting the predicted optimal cache eviction policy into the cache capacity prediction model, and optimizes the cache strategy decision model based on the predicted capacity allocation result.

2. The cache allocation method according to claim 1, characterized in that, 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, repetition data ratio, cumulative distribution of the number of data intervals between repetition data, data stream information entropy, distribution of the shortest time interval between repetition data, distribution of the time interval between adjacent data, data stream statistical period, and data stream calendar effect.

3. The method of cache allocation according to claim 1, wherein, The extraction of the target feature vector from the multi-feature data stream includes: The multi-feature data stream is input into the feature engineering module, which performs data preprocessing on the multi-feature data stream to obtain a preprocessed multi-feature data stream. Based on the preset data stream statistical time window size, features are extracted from the preprocessed multi-feature data stream to obtain the target feature vector.

4. The method of cache allocation of claim 1, wherein, Also includes: The cache capacity prediction model is trained. Specifically, it includes: Obtain the multi-feature data stream of the first sample; Extract the first feature vector from the first sample multi-feature data stream, and construct the first cached missing rate curve dataset of the first sample multi-feature data stream based on the cached missing rate curve algorithm; The cache capacity prediction model is trained by inputting the user-preset first expected cache miss rate, the cache eviction policy read from the first cache miss rate curve dataset, the first feature vector, and the first cache miss rate curve dataset into the cache capacity prediction model to be trained. The cache capacity prediction model outputs the first cache capacity allocation result predicted under the current conditions. The 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 policy read from the first cache miss rate curve dataset. The cache capacity prediction model is then optimized using the first loss to obtain the trained cache capacity prediction model.

5. The method of cache allocation according to claim 4, wherein, Also includes: The caching strategy decision model is trained; Specifically, it includes: Obtain the multi-feature data stream of the second sample; Extract the second feature vector from the second sample multi-feature data stream, and construct the second cached missing rate curve dataset of the second sample multi-feature data stream based on the cached missing rate curve algorithm; The user-preset second expected cache miss rate, second feature vector, and second cache miss rate curve dataset are input into the cache policy decision model to be trained, and the cache policy decision model outputs the optimal cache eviction policy predicted under the current conditions. The predicted optimal cache eviction policy is input into the cache capacity prediction model, and the cache capacity prediction model outputs the 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. The cache policy decision model is then optimized through the reward function to obtain the trained cache policy decision model.

6. The method of cache allocation according to claim 5, wherein, The first cached missing rate curve dataset for constructing the first sample multi-feature data stream based on the cached missing rate curve algorithm includes: Step a: Based on the cache size range to be evaluated set by the user and the cache eviction policy pool given based on the cache size range, a first eviction policy and a first data stream are obtained. The first eviction policy belongs to the cache eviction policy pool, which includes at least one eviction policy. The first data stream belongs to a first data stream group, which includes at least one data stream. Step b: Use the first data stream to simulate the caching operation of each access request under different cache sizes, and calculate the miss rate of each access request under each cache size to obtain the cache miss rate; Step c: Generate a cache miss rate curve based on the cache miss rate; Step d: Determine whether the data stream in the first data stream group has performed cache miss rate curve fitting for each eviction policy in the cache policy pool. If all eviction policies have not been traversed, repeat steps b and c until all eviction policies have been traversed. Step e: Determine whether cache missing rate curve fitting has been performed on each of the collected data streams. If not all data streams have been traversed, repeat steps b to d until all data streams have been traversed and the target cache missing rate curve dataset is obtained.

7. A cache allocation apparatus, characterized in that, include: The first processing module is used to acquire a multi-feature data stream and extract the target feature vector of the multi-feature data stream; The second processing module is used to input the user-preset expected cache miss rate and the target feature vector into the cache strategy decision model. The cache strategy decision model outputs the optimal cache eviction policy based on the user-preset expected cache miss rate and the target feature vector. Then, the optimal cache eviction policy, the user-preset expected cache miss rate and the target feature vector are input into the cache capacity prediction model. The cache capacity prediction model outputs the target cache capacity allocation result based on the optimal cache eviction policy, the user-preset expected cache miss rate and the target feature vector. The cache capacity prediction model and the cache policy decision model are trained in the following way: The cache strategy decision model obtains the predicted capacity allocation result by inputting the predicted optimal cache eviction policy into the cache capacity prediction model, and optimizes the cache strategy decision model based on the predicted capacity allocation result.

8. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps in the cache allocation method as described in any one of claims 1 to 6.

9. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the cache allocation method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, Includes computer instructions that, when executed by a processor, implement the steps in the cache allocation method as described in 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