Cache data processing method, device, equipment, storage medium and program product
Through representation learning and correlation analysis of cache area data access sequences, cache prefetching and replacement are optimized, which solves the problem of low cache hit rate in the existing technology and improves the performance of the cache system.
Patent Information
- Application Number
- CN202411040486.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-07-31
AI Technical Summary
In existing cache technology, frequency and probability-based, non-heuristic algorithms or random algorithms lead to low data cache hit rates, which cannot effectively mine request correlation and access patterns, affecting the performance of cache replacement and prefetching.
By obtaining the data access sequence of the cache area for representation learning, the feature vector sequence is obtained, and data access correlation learning is performed, the prefetch probability of each accessed data in the file system is calculated, and the prefetching and replacement processing of the cache area are optimized.
The data cache hit rate is improved. By understanding data access behaviors and patterns, future access data can be more accurately predicted, thereby improving the efficiency of the cache system.
Smart Images

Figure CN118568010B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network cache technology, and in particular to a cache data processing method, device, equipment, storage medium and program product. Background Art
[0002] At present, in order to improve the system reading performance and reduce the response time of the application, a subset of data is mainly temporarily stored in the high-speed data storage layer. When the cached data is requested, the requested data can be provided quickly, that is, the data access speed and system performance are improved through caching technology.
[0003] Cache replacement and prefetching are important factors affecting cache efficiency. Currently, cache replacement and prefetching use frequency and probability-based, non-heuristic algorithms or random algorithms, resulting in a low cache hit rate for data. Summary of the invention
[0004] The main purpose of the present invention is to provide a cache data processing method, device, equipment, storage medium and program product, aiming to solve the technical problem of low cache hit rate of data in the prior art.
[0005] To achieve the above object, the present invention provides a cache data processing method, the method comprising the following steps:
[0006] Get the data access sequence of cached data in the cache area;
[0007] Performing characterization learning on the data access sequence to obtain a first feature vector sequence;
[0008] Performing data access relevance learning on the first feature vector sequence to obtain pre-fetch probability of each access data in the file system;
[0009] Based on the pre-fetch probability, the access data is pre-fetched to be stored in the cache area.
[0010] Optionally, the data access sequence for obtaining cached data in the cache area includes:
[0011] Obtaining an access log set of cached data in the cache area;
[0012] Performing log sequence extraction on the access log set to obtain an access log sequence set; wherein the access log sequence set includes at least two access log sequences;
[0013] Extracting log attributes of each access log in each access log sequence in the access log sequence set to obtain a session element sequence corresponding to each access log sequence;
[0014] Each of the session element sequences is reorganized to obtain the data access sequence corresponding to each of the access log sequences.
[0015] Optionally, the learning of data access relevance of the first feature vector sequence to obtain a pre-fetch probability of each access data in the file system includes:
[0016] Adding a special embedding vector to the first feature vector sequence to obtain a new first feature vector sequence;
[0017] Taking the sum of the position embedding vector, the segment embedding vector and the new first feature vector sequence as the first vector to be encoded;
[0018] Performing data access relevance learning on the first vector to be encoded to obtain a first encoding output vector;
[0019] Inputting the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder;
[0020] The first decoding output vector is converted to obtain a pre-fetch probability of each access data in the file system.
[0021] Optionally, before prefetching the access data based on the prefetch probability, the method further includes:
[0022] Generate a cache content list based on the cache data;
[0023] Performing characterization learning on the cache content list to obtain a second feature vector sequence;
[0024] Adding a special embedding vector to the second feature vector sequence to obtain a new second feature vector sequence;
[0025] Taking the sum of the new second feature vector, the position embedding vector and the segment embedding vector as the second vector to be encoded;
[0026] Performing data access relevance learning on the second vector to be encoded to obtain a second encoded output vector;
[0027] Inputting the second encoded output vector into a decoder to obtain a second decoded output vector output by the decoder;
[0028] Performing conversion processing on the second decoded output vector to obtain a replacement probability of each cached data in the cache area;
[0029] Based on the replacement probability, replacement processing is performed on the cache data to remove the cache data from the cache area.
[0030] Optionally, the decoder includes a replacement decoder and a pre-fetch decoder, the first decoding output vector is a pre-fetch decoding output vector, and the second decoding output vector is a replacement decoding output vector;
[0031] The step of inputting the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder includes:
[0032] Inputting the first encoding output vector into the pre-fetch decoder to obtain a pre-fetch decoding output vector output by the pre-fetch decoder;
[0033] The step of inputting the second encoded output vector into a decoder to obtain a second decoded output vector output by the decoder comprises:
[0034] The second encoded output vector is input into the replacement decoder to obtain a replacement decoded output vector output by the replacement decoder.
[0035] Optionally, before inputting the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder, the method further includes:
[0036] Acquire a training sample set; wherein the training sample set includes a cache list, a positive replacement sample, a negative replacement sample, a positive pre-fetch sample, a pre-fetch task input, and a negative pre-fetch sample;
[0037] The initial pre-fetch decoder and the initial replacement decoder are trained respectively by using the training sample set to obtain the replacement decoder and the pre-fetch decoder.
[0038] Optionally, obtaining a training sample set includes:
[0039] Get the historical data access sequence of the cache area in different time periods;
[0040] Determining a plurality of target historical data access sequences from all the historical data access sequences;
[0041] Based on the first proportion, the latter part of all the target historical data access sequences is intercepted to obtain a first subsequence corresponding to each of the target historical data access sequences;
[0042] Based on all the first subsequences, construct the positive pre-fetch samples, and use the remaining sequences of each target historical data access sequence except the first subsequence as the pre-fetch task input;
[0043] Determining negative pre-fetch samples from the historical data access sequences except the target historical data access sequence; wherein the number of the negative pre-fetch samples is greater than the number of the positive pre-fetch samples;
[0044] Based on the second proportion, the front part of all the target historical data access sequences is intercepted to obtain a second subsequence corresponding to each of the target historical data access sequences;
[0045] Based on all the second subsequences, construct the cache list, and use the remaining sequences of each target historical data access sequence except the second subsequence as the positive replacement samples;
[0046] Negative replacement samples are determined from the historical data access sequences except the target historical data access sequence; wherein the number of the negative replacement samples is greater than the number of the positive replacement samples.
[0047] Optionally, the using the training sample set to respectively train an initial pre-fetch decoder and an initial replacement decoder to obtain the replacement decoder and the pre-fetch decoder comprises:
[0048] Performing characterization learning on the pre-fetch task input to obtain a third feature vector sequence;
[0049] Adding a special embedding vector to the third feature vector sequence to obtain a new third feature vector sequence;
[0050] Performing correlation learning on the new third feature vector sequence to obtain a pre-fetched embedding vector to be decoded;
[0051] Inputting the to-be-decoded prefetch embedding vector into the initial prefetch decoder to obtain a target prefetch decoding output vector output by the initial prefetch decoder;
[0052] Calculating a first output loss of the positive pre-fetch sample and the negative pre-fetch sample with respect to the target pre-fetch decoded output vector;
[0053] If the first output loss is greater than a preset threshold, the parameters of the initial pre-fetch decoder are updated to obtain a new initial pre-fetch decoder, and the new initial pre-fetch decoder is used as the initial pre-fetch decoder, and the pre-fetch embedding vector to be decoded is input into the initial pre-fetch decoder to obtain a target pre-fetch decoding output vector output by the initial pre-fetch decoder, until the first output loss is less than the preset threshold;
[0054] If the first output loss is less than the preset threshold, the initial pre-fetch decoder is used as the replacement decoder.
[0055] Optionally, the using the training sample set to respectively train an initial pre-fetch decoder and an initial replacement decoder to obtain the replacement decoder and the pre-fetch decoder comprises:
[0056] Performing characterization learning on the cache list to obtain a fourth feature vector sequence;
[0057] Adding a special embedding vector to the fourth feature vector sequence to obtain a new fourth feature vector sequence;
[0058] Performing data access association learning on the new fourth feature vector sequence to obtain a replacement embedding vector to be decoded;
[0059] Inputting the replacement embedding vector to be decoded into the initial replacement decoder to obtain a target replacement decoding output vector output by the initial replacement decoder;
[0060] Calculate a second output loss of the positive replacement sample and the negative replacement sample with the target replacement decoding output vector;
[0061] If the second output loss is greater than a preset threshold, the parameters of the initial replacement decoder are updated to obtain a new initial replacement decoder, and the new initial replacement decoder is used as the initial replacement decoder, and the replacement embedding vector to be decoded is input into the initial replacement decoder to obtain a target replacement decoding output vector output by the initial replacement decoder, until the second output loss is less than the preset threshold;
[0062] If the second output loss is less than the preset threshold, the initial replacement decoder is used as the replacement decoder.
[0063] In addition, to achieve the above-mentioned purpose, the present invention further proposes a cache data processing device, the cache data processing device comprising:
[0064] An acquisition module, used for acquiring a data access sequence of cached data in a cache area;
[0065] A representation learning module, used for performing representation learning on the data access sequence to obtain a first feature vector sequence;
[0066] A learning module, used for learning the data access relevance of the first feature vector sequence to obtain the pre-fetch probability of each access data in the file system;
[0067] A processing module is used to perform pre-fetch processing on the access data based on the pre-fetch probability so as to store the pre-fetched data into the cache area.
[0068] In addition, to achieve the above-mentioned purpose, the present invention also proposes a cache data processing device, which includes: a memory, a processor, and a cache data processing program stored in the memory and executable on the processor, and the cache data processing program is configured to implement the steps of the cache data processing method described above.
[0069] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a cache data processing program is stored, and when the cache data processing program is executed by a processor, the steps of the cache data processing method described above are implemented.
[0070] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer program product, which includes a cache data processing program, and when the cache data processing program is executed by a processor, the steps of the cache data processing method described above are implemented.
[0071] The present invention provides a cache data processing method. Compared with the related art, which uses a frequency and probability-based, non-heuristic algorithm or a random algorithm to calculate the pre-fetch probability of data, this embodiment obtains the data access sequence of the cache area, characterizes and learns the data access sequence, obtains a first feature vector sequence, and learns the data access correlation of the first feature vector sequence to obtain the pre-fetch probability of each access data in the file system. Since the data access sequence of the cache area can reflect the access situation of the cached data in the cache area in different time periods, when characterizing and learning the data access sequence, the correlation and pattern between different data accesses can be found, such as the relationship between adjacent accesses and the pattern of the time series, which helps to better understand the data access behavior, and obtain the pre-fetch probability of the access data based on the first feature vector sequence used to represent the data access behavior, thereby improving the cache hit rate of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 It is a structural diagram of a cache data processing device in a hardware operating environment involved in an embodiment of the present invention;
[0073] Figure 2 It is a flow chart of a first embodiment of a cache data processing method of the present invention;
[0074] Figure 3 A schematic diagram of an access log set and an access log sequence of the present invention;
[0075] Figure 4 A schematic diagram of extracting log attributes of each access log in each access log sequence according to the present invention;
[0076] Figure 5 A schematic diagram showing the reorganization of the conversation elements of the present invention;
[0077] Figure 6 It is a structural block diagram of the first embodiment of the cache data processing device of the present invention.
[0078] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0079] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0080] Cache technology plays an important role in computer systems. By temporarily storing a subset of data in a high-speed data storage layer, the requested data can be quickly provided when the cached data is requested, improving the system's read performance and reducing the application's response time. As an important part of the cache system, cache replacement and prefetching methods significantly affect the cache hit rate, thereby affecting the cache's working efficiency.
[0081] Existing cache replacement and prefetching methods can be divided into rule-based cache replacement and prefetching and machine learning-based cache replacement and prefetching. The former mainly manually sets some rules and performs cache replacement and prefetching when the cache operation meets the rule requirements, such as least recently used (LRU), first in first out (FIFO), random replacement, etc.; the latter uses machine learning or deep learning to mine the laws and patterns of data access, such as using decision trees and support vector machines to learn the data access patterns of applications, predict which data will be frequently accessed, and adjust the weights of replacement algorithms such as LRU or LFU accordingly, using RNN and LSTM to learn the data access patterns of applications, predict the data that may be needed in the future, and prefetch these data into the cache in advance.
[0082] However, using existing prefetching methods to predict the next step of data access mainly has the following problems:
[0083] 1. Most existing cache replacement and cache prefetching methods use frequency and probability-based, non-heuristic algorithms, or even random algorithms. Although such algorithms are simple to implement and fast to run, they do not fully explore the request correlation in the cached data, resulting in a low cache hit rate, making it difficult to effectively mine the patterns contained in the request sequence, and unable to fully utilize the access logs of cache data to improve the performance of cache replacement and cache prefetching.
[0084] 2. Existing cache replacement and cache prefetching based on deep neural networks and logs often process each log in isolation, which cannot effectively learn data representation information, nor can it effectively focus on the access patterns implied in the access log context, resulting in a low cache hit rate.
[0085] 3. When using the results of deep recurrent neural networks for cache replacement and cache prefetching, due to shortcomings such as slow inference speed, it is difficult to meet the cache system's requirements for cache replacement and cache prefetching, and lacks practicality.
[0086] 4. Most of the existing representation learning frameworks based on access logs and deep bidirectional encoders process each access log in sequence without paying attention to the request pattern information within a complete request process, resulting in the output representation being unable to effectively mine the pattern in a single request, thus causing a low cache hit rate.
[0087] Therefore, when the probability of cache replacement and cache prefetching is calculated using the existing method, the request correlation in the cache data cannot be mined, resulting in a low cache hit rate of the data.
[0088] The present invention provides a cache data processing method. Compared with the related art, which uses a frequency and probability-based, non-heuristic algorithm or a random algorithm to calculate the pre-fetch probability of data, this embodiment obtains the data access sequence of the cache area, characterizes and learns the data access sequence, obtains a first feature vector sequence, and learns the data access correlation of the first feature vector sequence to obtain the pre-fetch probability of each access data in the file system. Since the data access sequence of the cache area can reflect the access situation of the cached data in the cache area in different time periods, when characterizing and learning the data access sequence, the correlation and pattern between different data accesses can be found, such as the relationship between adjacent accesses and the pattern of the time series, which helps to better understand the data access behavior, and obtain the pre-fetch probability of the access data based on the first feature vector sequence used to represent the data access behavior, thereby improving the cache hit rate of the data.
[0089] Reference Figure 1 , Figure 1 The present invention is a schematic diagram of the structure of a cache data processing device in a hardware operating environment according to an embodiment of the present invention.
[0090] like Figure 1As shown, the cache data processing device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0091] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the cache data processing device, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0092] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a cache data processing program.
[0093] exist Figure 1 In the cache data processing device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the cache data processing device of the present invention can be set in the cache data processing device, and the cache data processing device calls the cache data processing program stored in the memory 1005 through the processor 1001, and executes the cache data processing method provided by the embodiment of the present invention.
[0094] The embodiment of the present invention provides a cache data processing method, referring to Figure 2 , Figure 2 It is a flowchart of the first embodiment of the cache data processing method of the present invention.
[0095] In this embodiment, the cache data processing method includes the following steps:
[0096] Step S10: Obtain a data access sequence of cached data in the cache area.
[0097] It should be noted that the execution subject of the cache data processing method is a cache data processing device, and a cache data processing program is stored on the cache data processing device. When the cache data processing device executes the cache data processing program, the cache data processing method of this embodiment is implemented.
[0098] In this embodiment, the cache area may be a memory area in a cache data processing device for temporarily storing data, and preloaded data or temporarily stored data may be stored in the cache area, so that when the preloaded data or temporarily stored data is subsequently accessed, the corresponding data may be directly called from the cache area, thereby improving the speed of data access and device performance. The cache data may be preloaded data or temporarily stored data stored in the cache area.
[0099] It should be noted that an access log reflecting information such as the time when the cached data is accessed and the access frequency may be stored in the cache area. In order to understand the access mode and frequency of the data, when obtaining the data access sequence of the cached data in the cache area, further, as an optional implementation, step S10 specifically includes:
[0100] Step S101: Obtain an access log set of cached data in the cache area.
[0101] Step S102: extract log sequences from the access log set to obtain an access log sequence set; wherein the access log sequence set includes at least two access log sequences.
[0102] Step S103: extracting log attributes of each access log in each access log sequence in the access log sequence set, and obtaining a session element sequence corresponding to each access log sequence.
[0103] Step S104: reorganize the session element sequences to obtain the data access sequences corresponding to the access log sequences.
[0104] In this embodiment, the access log may be an access log of cached data, or an access log of cached data that has been removed from the cache area, or an access log of cached data and an access log of cached data that has been removed from the cache area. A log sequence may be an ordered set representing a group of requests in a service for a user.
[0105] Specifically, refer to Figure 3 As shown, the cache data processing device can directly read the access log set of the cache data in the cache area, and record the access log set as , ,in, represents the i-th access log in the access log set. represents the i-th attribute of the log, such as timestamp, event type, thread information, message content, etc., and k represents the total number of attributes. After obtaining the access log set, the log sequence can be extracted from the access log set based on the session to obtain the access log sequence set. For example, the session can be the user terminal IP address that sends the access request and the interval time between the access request does not exceed ten seconds. That is, the log sequence is extracted from the access log set according to different users, and the log sequence is sorted in order to obtain the access log sequence set. The log sequence can be recorded as , the access log sequence set is recorded as , m represents the total number of log sequences, Represents the i-th log sequence.
[0106] After obtaining the access log sequence set, refer to Figure 4 As shown, the same t attributes of each access log can be extracted from each access log sequence in the access log sequence set, that is, ,in, represents the t attributes extracted from the cth access log, and the attributes of the log extracted from the access log are used as the session element sequence of each log sequence, that is, , The sequence of session elements representing the i-th access log sequence, represents the xth attribute of the yth access log, x∈k.
[0107] Further, see Figure 5 As shown in FIG. 1 , after obtaining the session element sequence of each access log sequence, the session element sequence can be reorganized, that is, the same type of log attributes in the session element sequence are used as session element groups, and all session element groups are used as data access sequences. For example, extracting log attributes of each access log in the i-th access log sequence, the obtained session element sequence corresponding to the i-th access log sequence is According to the type of log attribute, all log attributes in the session element sequence are reorganized to obtain the session element group corresponding to each type of log attribute. Attributes as an example, the resulting session element group is , all session element groups are regarded as data access sequences corresponding to each access log sequence, that is, the data access sequence is recorded as
[0108] In this embodiment, since the access log can reflect the access time, access frequency and other information of the cached data in the cache area, after log sequence extraction is performed to obtain the access log sequence set, the log attributes of each access log in each access log sequence in the access log sequence set are extracted to obtain a session element sequence. Since the session element can reflect the user's data access behavior pattern from the side, such as the user's access habits, preferences, frequency, etc., the reorganized session elements are used as the data access sequence, which can more finely describe the user's demand for data, so that when predicting the next access data based on the data access sequence, the future data access pattern can be predicted more accurately, thereby improving the cache hit rate.
[0109] Step S20: Perform characterization learning on the data access sequence to obtain a first feature vector sequence.
[0110] Specifically, after obtaining the data access sequence, the Tokenizer obtained through representation learning can be used , that is, by fine-tuning the text into words or word modules, the data access sequence is represented and learned, so that different types of session elements in the data access sequence can be converted into embedding vectors using different representation learning methods. For example, when the session element is of time type, the time can be converted into a timestamp first, and then the timestamp can be converted into a binary time, and the high bit of the binary sequence is padded with 0 to a length of 64 to obtain a 1×64 embedding vector. Alternatively, when the type of the session element is a cache data access request type, it can be converted into an embedding vector using the Word2Vec method.
[0111] After the session elements are converted into corresponding embedding vectors, the corresponding embedding vectors may be sorted according to the arrangement order of each session element group in the data access sequence, and the sorted embedding vectors are used as the first feature vector sequence.
[0112] Step S30: learning the data access association of the first feature vector sequence to obtain the pre-fetch probability of each access data in the file system.
[0113] In this embodiment, a deep bidirectional encoder, an autoencoder, a variational autoencoder, a sparse autoencoder, a denoising autoencoder, a convolutional autoencoder or a recursive autoencoder can be used to learn the data access association of the first feature vector sequence, wherein this embodiment is illustrated by taking a deep bidirectional encoder as an example.
[0114] When the first feature vector sequence is input into the deep bidirectional encoder for learning data access association, in order to provide the deep bidirectional encoder with richer input information so that the deep bidirectional encoder can better capture the complex relationship between elements in the input first feature vector sequence, so as to obtain a pre-fetch probability with higher accuracy, further, as an optional implementation, step S30 specifically includes:
[0115] Step S301: Add a special embedding vector to the first feature vector sequence to obtain a new first feature vector sequence.
[0116] Step S302: taking the sum of the position embedding vector, the segment embedding vector and the new first feature vector sequence as the first vector to be encoded.
[0117] Step S303: learning data access association of the first vector to be encoded to obtain a first encoded output vector.
[0118] Step S304: input the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder.
[0119] Step S305: convert the first decoded output vector to obtain a pre-fetch probability of each access data in the file system.
[0120] In this embodiment, the special embedding vector may be at least one of a special embedding vector MSAK, a special embedding vector SEP, a special embedding vector CLS, and a special embedding vector PAD.
[0121] Adding the special embedding vector CLS to the first feature vector sequence can help the deep bidirectional encoder capture the semantic information of the entire first feature vector sequence. The special embedding vector MASK can help the deep bidirectional encoder shield the influence of the padding part. The special embedding vector PAD can pad the length of the first feature vector sequence after adding the special embedding vector MASK and the special embedding vector CLS when the length of the first feature vector sequence after adding the special embedding vector MASK and the special embedding vector CLS does not meet the maximum length of the deep bidirectional encoder.
[0122] After adding a special embedding vector to the first feature vector sequence to obtain a new first feature vector sequence, when the new first feature vector sequence is input into the deep bidirectional encoder for learning data access relevance, in order to enable the deep encoder to better understand the position of the words and paragraph information in the input new first feature vector sequence, so as to better capture the structural characteristics of the sequence, the sum of the position embedding vector, the paragraph embedding vector and the new first feature vector sequence can be used as the first vector to be encoded. After obtaining the first vector to be encoded, the first vector to be encoded can be input into the deep bidirectional encoder for learning data access relevance to obtain the first encoded output vector output by the deep bidirectional encoder, that is, ,in, represents a deep bidirectional encoder, represents the first vector to be encoded, Represents the first encoded output vector.
[0123] After obtaining the first encoding output vector, the first encoding output vector can be input into a decoder for decoding to obtain a first decoding output vector output by the decoder. The first decoding output vector can be converted into a pre-fetch probability using methods such as a Softmax function, a probability model, and a regression model density estimation.
[0124] In this embodiment, when the first feature vector sequence is input into the deep bidirectional encoder for learning data access relevance, the first vector to be encoded with a special embedding vector, a position embedding vector and a segment embedding vector is input into the deep bidirectional encoder for learning data access relevance. By adding the special embedding vector, the deep bidirectional encoder can be helped to capture the semantic information of the entire first feature vector sequence. By adding the position embedding vector and the segment embedding vector, the deep encoder can be helped to better understand the position of words and paragraph information in the input new first feature vector sequence, so as to better capture the structural features of the sequence. That is, by providing the deep bidirectional encoder with richer input information, the deep bidirectional encoder can better capture the complex relationship between elements in the input first feature vector sequence.
[0125] In this embodiment, the encoder may be pre-trained through a masked sequence model (MSM) task and a next data prediction (NDP) task to obtain a deep bidirectional encoder.
[0126] Specifically, in order to enable the encoder to learn the association in the data access sequence, the encoder can be trained on the mask sequence task, that is, by predicting the original vector of the input encoder replaced by the special embedding vector MASK, and calculating the loss between the original vector and the replacement vector after being replaced by the special embedding vector MASK, and the loss is recorded as ,Right now ,in, represents the replacement vector where the original vector is replaced with the MASK special embedding vector. is the number of original vectors replaced by the MASK special embedding vector, i represents the index of the i-th original vector replaced by the special embedding vector, The encoder is in the subscript The output vector of positions, is the one-hot vector representing the original vector, is the SoftMax layer, is a feed-forward neural network layer.
[0127] After the encoder is trained on the mask sequence task, in order to enable the encoder to learn the correlation in the data access sequence, the encoder can be trained on the near-future data prediction task, that is, by judging whether the first and second halves of the data access sequence input to the encoder match, the second half of the data access sequence is replaced with the second half of another data access sequence, and the loss between the data access sequence without replacement operation and the data access sequence after replacement operation is calculated, and the loss is recorded as ,Right now
[0128]
[0129] in, is the length of the data access sequence corresponding to the current input. When the first and second halves of the access sequence match ,otherwise , is the output vector of the special embedding vector CLS, is the SoftMax layer, is a feed-forward neural network layer.
[0130] In getting and After that, you can use and The network parameters of the encoder are optimized by summing them up to obtain a deep bidirectional encoder that can learn the correlation in the data access sequence.
[0131] For better understanding, a specific example is provided below.
[0132] Specifically, after the cache data processing device reads 1,000 access logs from the cache area, it can use "the request time interval of the same user is no more than 10 seconds" as the basis to convert the access logs into A total of 1000 access logs are extracted into 15 groups of logs to obtain access log sequence sets, which are recorded as , and the format of each access log is '$remote_addr-$remote_user [$time_local], "$request" $status $bytes_sent, "$http_referer", "$http_user_agent" "$gzip_ratio"'.
[0133] After obtaining the access log set, $time_local, $request, and $http_referer can be used as log attributes to be extracted. For each access log sequence in the access log sequence set, the log attributes of each access log in each access log sequence are extracted to obtain the session element sequence corresponding to each access log sequence. The log attributes in the session element sequence are reorganized to obtain multiple session element groups and the data access sequence. For example, with the access log sequence Take this as an example to illustrate: It consists of thirty logs. Extract the log attributes of each log in the log, and after reorganizing them, sort them according to the order of initiation of the session elements to obtain Data access sequence , and access log sequence The data access sequence is abbreviated as The above processing is performed on all access log sequences to obtain the data access sequence corresponding to each access log sequence, and all data access sequences are combined into a data access sequence group, recorded as .
[0134] After obtaining the data access sequence, we can perform characterization learning on the data access sequence, that is, according to the type of log attribute, use the corresponding conversion method to convert all log attributes in the data access sequence into embedded vectors, and combine all embedded vectors to obtain the first feature vector sequence. The data access sequence is As an example, after converting it into time attributes, request attributes, and link attributes into embedding vectors respectively, the embedding vector of the time attribute is expressed as , the embedding vector of the request attribute is represented as , the embedding vector of the link attribute is represented as , where the above embedding vectors are all 1×64 embedding vectors.
[0135] After obtaining the first feature vector sequence, the special embedding vector, the position vector and the segment embedding vector are added to the first feature vector sequence to obtain the first vector to be encoded. Convert to the first vector to be encoded Take this as an example to illustrate. Concatenate T, Req, and Ref to get the intermediate vector ,Right now },in For a 1 192 vector. In getting the intermediate vector sequence After that, 20% of the vectors in are replaced with MASK special embedding vectors, and The second half of the vector is replaced with the second half of another intermediate vector with a probability of 50%, and the SEP embedding vector is added at the connection between the two segments for connection. The CLS embedding vector is added to the starting position of the The length of is less than the maximum length of the deep bidirectional encoder, and further after adding the CLS embedding vector Add the PAD embedding vector to the end of to complete the length and obtain a new first feature vector sequence. Perform the above operation on each item in the data access sequence to obtain an intermediate vector sequence, and record the intermediate vector sequence as .
[0136] After obtaining the new first eigenvector sequence, the position embedding vector is generated using the sine function and the cosine function respectively. That is, when the subscript i of the new first eigenvector sequence to which the position embedding vector needs to be added is an even number, the sine function is used. Generate position embedding vector, otherwise use cosine function Generate a position embedding vector where , POS represents the position of the new first feature vector sequence in the intermediate vector sequence, and the position embedding vector is a 512×192 matrix. After obtaining the position embedding vector, determine whether the position of the segment embedding vector is between the CLS embedding vector and the SEP embedding vector. When the segment embedding vector is between the CLS embedding vector and the SEP embedding vector, the segment embedding vector is a 1×192 unit vector, otherwise it is a 1×192 zero vector. The segment embedding vector finally generated is a 512×192 matrix.
[0137] After obtaining the segment embedding vector and the position embedding vector, the sum of the segment embedding vector and the position embedding vector and the new first feature vector sequence is used as the first vector to be encoded ,Will Input the deep bidirectional encoder for encoding, and obtain the first encoded output vector output by the deep bidirectional encoder, that is, ,in , The dimension of each vector in is 1×192.
[0138] Assume that the vector replaced by the MASK embedding vector in the first encoding output vector is and , calculate the loss between the original vector and the replacement vector replaced by the special embedding vector MASK, that is, and Input the MSM task decoder respectively, and get the output of the MSM task decoder =[0.001,0.002,…,0.009] and =[0.002,0.007,…,0.001], whose dimensions are all 1*900. , With one-hot vector , Calculate the loss and use the cross entropy loss to get the loss value . Using the NDP task decoder The vector is decoded to get ENDP=[0.92,0.08], whose values represent "probability of not being replaced" and "probability of being replaced" respectively. The loss value is obtained by using cross entropy loss with the one-hot vector ONDP=[1,0]. .
[0139] Final calculation and of and, using and The sum of the encoder network parameters is optimized until and The sum of is less than 0.85.
[0140] Step S40: Based on the pre-fetch probability, pre-fetch the access data to store it in the cache area.
[0141] In this embodiment, the file system may be a data storage management system for managing files and data resources, and the cache area may be a subset of the file system for storing the most recent or frequently accessed access data in the file system.
[0142] Specifically, after obtaining the first decoded output vector, the first decoded output vector can be converted into a pre-fetch probability by using methods such as a Softmax function, a probability model, and a regression model density estimation. After obtaining the pre-fetch probability of each access data, the access data can be pre-fetched according to the pre-fetch probability of each access data, so that the access data with a high pre-fetch probability is stored in the cache area.
[0143] It should be noted that, when the access data is pre-fetched according to the pre-fetch probability to be stored in the cache area, the cache space of the cache area may be full. When the cache space of the cache area is full, the access data cannot be stored in the cache area. Therefore, to avoid this situation, further as an optional implementation, before step S40, it also includes:
[0144] Step S32: Generate a cache content list based on the cache data.
[0145] Step S33: Perform characterization learning on the cache content list to obtain a second feature vector sequence.
[0146] Step S34: Add a special embedding vector to the second feature vector sequence to obtain a new second feature vector sequence.
[0147] Step S35: taking the sum of the new second feature vector, the position embedding vector and the segment embedding vector as the second vector to be encoded.
[0148] Step S36: learning the data access association of the second vector to be encoded to obtain a second encoded output vector.
[0149] Step S37: input the second encoded output vector into a decoder to obtain a second decoded output vector output by the decoder.
[0150] Step S38: convert the second decoded output vector to obtain a replacement probability of each cached data in the cache area.
[0151] Step S39: Based on the replacement probability, replace the cache data to remove the cache data from the cache area.
[0152] Specifically, the cache data processing device can directly read the cached data from the cache area and generate a cache content list of the cache area, that is, ,in represents the cache content list, and n represents the cache capacity. After obtaining the cache content list, the cache content list can be characterized and learned to convert each data item in the cache content list into an embedding vector, and the corresponding embedding vectors are sorted according to the arrangement order of the cache data in the cache content list to obtain a second feature vector sequence.
[0153] After obtaining the second feature vector sequence, a special embedding vector can be added to the second feature vector sequence to obtain a new second feature vector sequence, and the new second feature vector, the position embedding vector and the segment embedding vector are used as the second vector to be encoded. After obtaining the second vector to be encoded, the second vector to be encoded can be input into the deep bidirectional encoder to learn the data access association, and the second encoded output vector output by the deep bidirectional encoder is obtained.
[0154] After obtaining the second encoding output vector, the second encoding output vector can be input into the decoder to obtain the second decoding output vector output by the decoder, and the second decoding output vector can be converted, such as using a softmax function to convert the second decoding output vector to obtain the replacement probability of each cached data in the cache area. According to the replacement probability, the cached data whose replacement probability is greater than the preset replacement probability is replaced to remove the corresponding cached data from the cache area. After the cached data is removed from the cache area, the pre-fetched access data can be determined from the access data according to the pre-fetch probability of the access data, and the access data can be stored in the cache area.
[0155] It can be understood that in order to better handle the two different tasks of data replacement and data prefetching in the cache, when obtaining the prefetching probability of accessing data and the replacement probability of cached data, the replacement decoder and the prefetching decoder can be used to respectively perform decoding operations on the corresponding decoding output vectors, that is, the first encoding output vector is decoded by the prefetching decoder to obtain the prefetching decoding output vector output by the prefetching decoder. The second encoding output vector is decoded by the replacement decoder to obtain the replacement decoding output vector, that is, step S304 is adaptively changed to: the first encoding output vector is input into the prefetching decoder to obtain the prefetching decoding output vector output by the prefetching decoder, and step S37 is adaptively changed to: the second encoding output vector is input into the replacement decoder to obtain the replacement decoding output vector output by the replacement decoder.
[0156] It can be understood that when the replacement decoder and the prefetch decoder are used to process two different tasks of data replacement and data prefetching in the cache respectively, in order to improve the accuracy of prediction, further, as an optional implementation, before step S40, it also includes:
[0157] Step S28: Obtain a training sample set.
[0158] The training sample set includes a cache list, positive replacement samples, negative replacement samples, positive pre-fetch samples, pre-fetch task inputs and negative pre-fetch samples.
[0159] It can be understood that in order to enable the positive pre-fetch samples, pre-fetch task inputs and negative pre-fetch samples in the training sample set to capture the user's access trends and possible future access patterns, the pre-fetch algorithm is optimized, and the cache list, positive replacement samples and negative replacement samples can capture the most frequently accessed data vectors, thereby better reflecting the actual hot data set, so as to better simulate the access pattern of cached data in the actual cache area. Further, as an optional implementation, step S28 specifically includes:
[0160] Step S281, obtaining the historical data access sequence of the cache area in different time periods.
[0161] Step S282: Determine a plurality of target historical data access sequences from all the historical data access sequences.
[0162] Step S283: based on the first proportion, intercept the latter part of all the target historical data access sequences to obtain a first subsequence corresponding to each of the target historical data access sequences.
[0163] Step S284: construct the positive pre-fetch samples based on all the first sub-sequences, and use the remaining sequences of each target historical data access sequence except the first sub-sequence as the pre-fetch task input.
[0164] Step S285 : Determine negative pre-fetch samples from the historical data access sequences except the target historical data access sequence; wherein the number of the negative pre-fetch samples is greater than the number of the positive pre-fetch samples.
[0165] Step S286: based on the second proportion, intercept the front part of all the target historical data access sequences to obtain a second subsequence corresponding to each of the target historical data access sequences.
[0166] Step S287: construct the cache list based on all the second subsequences, and use the remaining sequences of each target historical data access sequence except the second subsequence as the positive replacement samples.
[0167] Step S288: Determine negative replacement samples from the historical data access sequences except the target historical data access sequence; wherein the number of the negative replacement samples is greater than the number of the positive replacement samples.
[0168] Specifically, after obtaining the access log set of cached data in the cache area, the access log set can be divided into multiple access log subsets according to the generation time of the access log to obtain multiple access log subsets in different time periods, and then based on the above operations, the multiple access log subsets are extracted and processed to obtain historical data access sequences corresponding to each access log subset.
[0169] After obtaining multiple historical data access sequences, multiple historical data access sequences are randomly selected from the multiple historical data access sequences, and the selected multiple historical data access sequences are used as target historical data access sequences. For example, if there are 1000 historical data access sequences, 15 historical data access sequences are randomly selected from them as target historical data access sequences.
[0170] Alternatively, all historical data access sequences may be sorted in descending order according to the time of the access log subset corresponding to each historical data access sequence, and the top 15 historical data access sequences are used as target historical data access sequences.
[0171] Alternatively, all historical data access sequences may be sorted in descending order according to the access frequencies of the access log subsets corresponding to the historical data access sequences, and the top 15 historical data access sequences may be used as target historical data access sequences.
[0172] After obtaining multiple target historical data access sequences, in order to capture the user's access trends and possible future access patterns and optimize the prefetch algorithm, the latter q% of each target historical data access sequence can be used to construct positive prefetch samples, that is, access data samples that need to be prefetched, denoted as , that is, based on the first proportion, the latter part of all target historical data access sequences is intercepted to obtain the first subsequences corresponding to each target historical data access sequence, and all the first subsequences are used as positive pre-fetch samples. Correspondingly, after all the first subsequences are used as positive pre-fetch samples, the remaining sequences of each target historical data access sequence except the first subsequence can be used as pre-fetch task input, that is, used to represent the data access request input by the subsequent user, which is recorded as Finally, multiple historical data access sequences are randomly selected from the historical data access sequences except the target historical data access sequence, and used as negative prefetch samples, that is, access data samples that do not require prefetch operations, denoted as .
[0173] For example, based on the aforementioned 1000 historical data access sequences, 15 historical data access sequences are extracted as target historical data access sequences. When the first proportion is 20%, the last 20% of each target historical data access sequence is used as positive pre-fetch samples, and the first 80% of each target historical data access sequence is used as pre-fetch task input. Finally, negative pre-fetch samples are randomly selected from the historical data access sequences excluding the target historical data access sequence, that is, negative pre-fetch samples are randomly selected from the remaining 985 historical data access sequences, such as selecting 150 historical data access sequences as negative pre-fetch samples. The first proportion can be 20% or 30%, and this embodiment does not limit this.
[0174] Accordingly, in order to capture the most frequently accessed data vectors, thereby better reflecting the actual hot data set and simulating the access pattern of cached data in the actual cache area, the cache list can be constructed using the first p% of each target historical data access sequence. , which is used to represent the cache data cached in the cache area, that is, according to the second proportion, the front part of all target historical data access sequences is intercepted to obtain the second subsequence corresponding to each target historical data access sequence, and the cache list is constructed using all the second subsequences. Among them, the second proportion can be 80%, that is, the cache list is constructed using the first 80% of each historical data access sequence, and the last 20% of each historical data access sequence is used as a positive replacement sample.
[0175] After constructing the cache list using the first p% of each target historical data access sequence, the remaining part of each target historical data access sequence can be marked as positive replacement samples, that is, cache data samples that should be removed from the cache area, and the positive replacement samples are recorded as , that is, the remaining sequences of each historical access sequence except the second subsequence are used as positive replacement samples. After obtaining the positive replacement samples, when constructing negative replacement samples, multiple historical data access sequences can be randomly selected from the historical data access sequences except the target historical data access sequence, and used as negative replacement samples, that is, cache data samples in the cache area that do not need to be removed, and the negative replacement samples are recorded as , to increase sample diversity and the generalization ability of model training, thereby helping the model to learn and generalize more comprehensively.
[0176] Step S29: using the training sample set to train the initial pre-fetch decoder and the initial replacement decoder respectively, to obtain the replacement decoder and the pre-fetch decoder.
[0177] It can be understood that the positive prefetch samples, prefetch task inputs and prefetch samples in the training sample set can reflect the user's access trends and possible future access patterns, and the cache list, positive replacement samples and negative replacement samples can reflect the access patterns of cached data in the actual cache area. Therefore, when the initial prefetch decoder and the initial replacement decoder are trained using the training sample set, the initial prefetch decoder should be trained using the prefetch task input, and the initial replacement decoder should be trained using the cache list. Further, as an optional implementation, step S39 specifically includes:
[0178] Step A1: perform representation learning on the pre-fetch task input to obtain a third feature vector sequence.
[0179] Step A2: adding a special embedding vector to the third feature vector sequence to obtain a new third feature vector sequence.
[0180] Step A3: learning the association of the new third feature vector sequence to obtain a pre-fetched embedding vector to be decoded.
[0181] Step A4: input the pre-fetch embedding vector to be decoded into the initial pre-fetch decoder to obtain a target pre-fetch decoding output vector output by the initial pre-fetch decoder.
[0182] Step A5: Calculate a first output loss between the positive pre-fetched sample and the negative pre-fetched sample and the target pre-fetched decoding output vector.
[0183] Step A6: If the first output loss is greater than a preset threshold, update the parameters of the initial pre-fetch decoder to obtain a new initial pre-fetch decoder, and use the new initial pre-fetch decoder as the initial pre-fetch decoder, and return to execute step A4 until the first output loss is less than the preset threshold.
[0184] Step A7: If the first output loss is less than the preset threshold, use the initial pre-fetch decoder as the pre-fetch decoder.
[0185] It should be noted that the above operation steps do not constitute a limitation on the training of the initial pre-fetch decoder, and may include more or fewer operation steps than the above operation steps. For example, after obtaining the fourth feature vector sequence, the fourth feature vector sequence can be directly used to learn the data access association without executing step A2.
[0186] After obtaining the positive pre-fetch samples, the negative pre-fetch samples and the pre-fetch task input, in order to reduce the interference of irrelevant features when learning the association of data access later, the pre-fetch task input can be characterized and learned, so as to learn effective feature representations from the pre-fetch task input, that is, the pre-fetch task input is characterized and learned to obtain a third feature vector sequence. After obtaining the third feature vector sequence, a special embedding vector sequence can be added to the third feature vector sequence to obtain a new third feature vector sequence.
[0187] After obtaining the new third feature vector sequence, the data access association can be learned for the new third feature vector sequence to obtain the pre-fetch embedding vector to be decoded, such as inputting the new third feature vector sequence into the deep bidirectional encoder for encoding to obtain the pre-fetch embedding vector to be decoded. After obtaining the pre-fetch embedding vector to be decoded, the pre-fetch embedding vector to be decoded can be used to train the initial pre-fetch decoder, that is, the pre-fetch embedding vector to be decoded is input into the initial pre-fetch decoder to obtain the target pre-fetch decoding output vector output by the initial pre-fetch decoder.
[0188] It is understandable that when the initial pre-fetch decoder is trained, the initial pre-fetch decoder may not fit the data well due to improper parameter settings, and there is an under-fitting phenomenon, resulting in poor performance of the initial pre-fetch decoder. In order to make the pre-fetch decoder reach the best state, after obtaining the target pre-fetch decoding output vector output by the initial pre-fetch decoder, the cross-entropy loss function can be used to calculate the vector output loss of the positive pre-fetch samples and the negative pre-fetch samples and the target pre-fetch decoding output vector, that is, the first output loss. When the first output loss is greater than the preset threshold, it means that the initial pre-fetch decoder has a poor prediction effect on the pre-fetch task, and it is necessary to adjust the initial pre-fetch decoder by updating the parameters to improve the accuracy. After adjusting the parameters of the initial pre-fetch decoder to obtain a new initial pre-fetch decoder, the new initial pre-fetch decoder can be used as the initial pre-fetch decoder, and return to execute step A4 until the first output loss is less than the preset threshold.
[0189] Alternatively, as another optional implementation, when the number of repeated executions of step A4 reaches a preset number of times, the initial pre-fetch decoder may be used as the pre-fetch decoder. For example, when the number of repeated executions of step A4 reaches 20 times, the initial pre-fetch decoder may be used as the pre-fetch decoder.
[0190] In this embodiment, before using the pre-fetch decoder to perform a decoding operation on the first encoded output vector, the historical data access sequence is used to construct positive pre-fetch samples, pre-fetch task inputs, and negative pre-fetch samples, and the initial pre-fetch decoder is trained to obtain a pre-fetch decoder. When the first encoded output vector is subsequently decoded, the pre-fetch decoder can be directly called, thereby shortening the decoding time. At the same time, the positive pre-fetch samples are constructed using the last q% of each historical data access sequence, which can better capture the user's access trend and possible future access mode, optimize the pre-fetch algorithm, and thus make the pre-fetch decoder have better performance.
[0191] After obtaining the pre-fetch decoder, the same method can be used to train the initial replacement decoder to obtain the replacement decoder. Therefore, accordingly, as an optional implementation, in step S39, it also includes:
[0192] Step B1: Perform characterization learning on the cache list to obtain a fourth feature vector sequence.
[0193] Step B2: adding a special embedding vector to the fourth feature vector sequence to obtain a new fourth feature vector sequence.
[0194] Step B3: learning data access association of the new fourth feature vector sequence to obtain a replacement embedding vector to be decoded.
[0195] Step B4: input the replacement embedding vector to be decoded into the initial replacement decoder to obtain a target replacement decoding output vector output by the initial replacement decoder.
[0196] Step B5: Calculate the second output loss of the positive replacement sample, the negative replacement sample and the target replacement decoding output vector.
[0197] Step B6: If the second output loss is greater than a preset threshold, update the parameters of the initial replacement decoder to obtain a new initial replacement decoder, and use the new initial replacement decoder as the initial replacement decoder, and return to execute B4 until the second output loss is less than the preset threshold.
[0198] Step B7: If the second output loss is less than the preset threshold, use the initial replacement decoder as the replacement decoder.
[0199] It should be noted that the above operation steps do not constitute a limitation on the training of the initial replacement decoder, and may include more or fewer operation steps than the above operation steps. For example, after obtaining the fourth feature vector sequence, the fourth feature vector sequence can be directly input into the deep bidirectional encoder to learn the data access association without executing step B2.
[0200] Specifically, in order to reduce the interference of irrelevant features in the subsequent learning of data access relevance, the cache list can be characterized and learned so as to learn effective feature representations from the cache list, that is, the cache list is characterized and learned to obtain a fourth feature vector sequence. After obtaining the fourth feature vector sequence, a special embedding vector sequence can be added to the fourth feature vector sequence to obtain a new fourth feature vector sequence.
[0201] After obtaining the new fourth feature vector sequence, the data access association can be learned for the new fourth feature vector sequence to obtain a pre-fetched embedding vector to be decoded, such as inputting the new fourth feature vector sequence into a deep bidirectional encoder for encoding to obtain a replacement embedding vector to be decoded. After obtaining the replacement embedding vector to be decoded, the replacement embedding vector to be decoded can be used to train the initial replacement decoder, that is, the replacement embedding vector to be decoded is input into the initial replacement decoder to obtain a target replacement decoding output vector output by the initial replacement decoder.
[0202] It is understandable that when the initial replacement decoder is trained, the initial replacement decoder may not fit the data well due to improper parameter settings, and there is an underfitting phenomenon, resulting in poor performance of the initial replacement decoder. In order to make the replacement decoder reach the best state, after obtaining the target replacement decoding output vector output by the initial replacement decoder, the cross entropy loss function can be used to calculate the vector output loss of the positive replacement sample and the negative replacement sample and the target replacement decoding output vector, that is, the second output loss. When the second output loss is greater than the preset threshold, it means that the initial replacement decoder has a poor prediction effect on the replacement task, and it is necessary to adjust the initial replacement decoder by updating the parameters to improve the accuracy. After adjusting the parameters of the initial replacement decoder to obtain a new initial replacement decoder, the new initial replacement decoder can be used as the initial replacement decoder, and return to execute step B4 until the first output loss is less than the preset threshold. Among them, the preset threshold can be 0.5, or it can also be set according to actual needs.
[0203] Alternatively, as another optional implementation, when the number of repeated executions of step B4 reaches a preset number of times, the initial replacement decoder may be used as the replacement decoder. For example, when the number of repeated executions of step B4 reaches 20 times, the initial replacement decoder may be used as the replacement decoder.
[0204] In this embodiment, before using the replacement decoder to decode the second encoded output vector, the cache list, positive replacement samples and negative replacement samples are constructed in advance using the historical data access sequence, and the initial replacement decoder is trained to obtain a replacement decoder. When the second encoded output vector is subsequently decoded, the replacement decoder can be directly called, thereby shortening the decoding time. At the same time, using the first p% of each historical data access sequence to construct a cache list can better capture the most frequently accessed data vectors, thereby better reflecting the actual hot data set, so as to better simulate the access mode of the cached data in the actual cache area.
[0205] In this embodiment, compared with the related art, which uses a frequency and probability-based, non-heuristic algorithm or a random algorithm to calculate the pre-fetch probability of data, this embodiment obtains the data access sequence of the cache area, characterizes and learns the data access sequence, obtains a first feature vector sequence, and learns the data access correlation of the first feature vector sequence to obtain the pre-fetch probability of each access data in the file system. Since the data access sequence of the cache area can reflect the access situation of the cached data in the cache area in different time periods, when characterizing and learning the data access sequence, the correlation and pattern between different data accesses can be found, such as the relationship between adjacent accesses and the pattern of the time series, which helps to better understand the data access behavior, and obtain the pre-fetch probability of the access data based on the first feature vector sequence used to represent the data access behavior, thereby improving the cache hit rate of the data.
[0206] To facilitate a better understanding of the present application, a specific example is provided below.
[0207] Specifically, the cache data processing device can directly read the access log set of the cache data from the cache area. After reading the access log set, the real-time requests of the same user can be arranged in order based on "the time interval between requests of the same user does not exceed 10 seconds", and the log attributes of the access logs in each log sequence can be extracted by using the $time_local, $request, and $http_referer attributes of the log to obtain the data access sequence, and the data access sequence can be recorded as , where the length of the data access sequence is 86. After obtaining the data access sequence, a cache content list can be generated based on the cache data in the cache area. , where 256 represents the capacity of the cache area, so the length of the cache content list is 256.
[0208] After obtaining the data access sequence and the cache content list, the data access sequence can be represented and learned by converting each session element in the data access sequence into an embedding vector to obtain the first feature vector sequence, that is, the first feature vector sequence is represented as It should be noted that when learning the representation of the session elements in the data access sequence, different representation learning methods need to be used according to the attributes of the session elements, such as choosing to convert $time_local into a timestamp and then into a binary time representation learning method; choosing the Word2Vec method for $request and $http_referer to convert them into embedded vectors. Correspondingly, the same operation method is used when learning the representation of the cache content list and obtaining the second feature vector sequence. Among them, the second feature vector sequence is recorded as .
[0209] After obtaining the first feature vector sequence and the second feature vector sequence, for each embedded vector in the first feature vector sequence, the embedded vectors corresponding to its $time_local, $request, and $http_referer attributes are concatenated, that is, the embedded vector pair , the embedding vector , the embedding vector Concatenate, where the embedding vector pair , the embedding vector , the embedding vector Both After performing the above operation on each access data, we get an access data embedding vector sequence consisting of 86 1×192 access data embedding vectors. , and in accessing the data embedding vector sequence Add a special embedding vector CLS at the beginning of the access data embedding vector sequence Add a special embedding vector PAD at the end of to fill the length to 512, and get a new first feature vector sequence. Then take the sum of the new first feature vector sequence, the segment embedding vector and the position vector as the first vector to be encoded, denoted as Correspondingly, the second feature vector sequence also uses the same operation method to obtain the second vector to be encoded, and the second vector to be encoded is recorded as .
[0210] After obtaining the first vector to be encoded and the second vector to be encoded After that, the first vector to be encoded can be and the second vector to be encoded The input deep bidirectional encoder is used to learn the data access association to obtain the first vector to be encoded The corresponding first decoding output vector is recorded as , and the second vector to be encoded The corresponding second output vector to be decoded Finally, the first decoded output vector Input the replacement decoder to obtain the replacement decoding output vector of each cached data in the cache area being replaced, and the second to-be-decoded output vector The pre-fetch decoder is input to obtain the pre-fetch decoding output vector of each access data in the file system, and the replacement decoding output vector and the pre-fetch decoding output vector are converted respectively to obtain the replacement probability of each cache data and the pre-fetch probability of each access data. According to the replacement probability of each cache data, the cache data is sorted in descending order to remove the first 32 cache data from the cache area. Correspondingly, according to the pre-fetch probability of each access data, the access data is sorted in descending order to store the first 32 access data in the access cache area.
[0211] In addition, an embodiment of the present invention further provides a computer program product, including a cache data processing program, and when the cache data processing program is executed by a processor, the steps of the cache data processing method described above are implemented.
[0212] The specific implementation of the computer program product of the present invention is basically the same as the embodiments of the cache data processing method described above, and will not be described in detail here.
[0213] In addition, an embodiment of the present invention further provides a storage medium, on which a cache data processing program is stored. When the cache data processing program is executed by a processor, the steps of the cache data processing method described above are implemented.
[0214] Reference Figure 6 , Figure 6 It is a structural block diagram of the first embodiment of the cache data processing device of the present invention.
[0215] like Figure 6 As shown, the cache data processing device proposed in the embodiment of the present invention includes:
[0216] An acquisition module, used for acquiring a data access sequence of cached data in a cache area;
[0217] A representation learning module, used for performing representation learning on the data access sequence to obtain a first feature vector sequence;
[0218] A learning module, used for learning the data access relevance of the first feature vector sequence to obtain the pre-fetch probability of each access data in the file system;
[0219] A processing module is used to perform pre-fetch processing on the access data based on the pre-fetch probability so as to store the pre-fetched data into the cache area.
[0220] Other embodiments or specific implementations of the cache data processing device of the present invention can refer to the above-mentioned method embodiments, which will not be described in detail here.
[0221] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0222] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0223] 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 a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0224] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A cache data processing method, characterized in that: The method comprises: Get the data access sequence of cached data in the cache area; Performing characterization learning on the data access sequence to obtain a first feature vector sequence; Performing data access relevance learning on the first feature vector sequence to obtain pre-fetch probability of each access data in the file system; Based on the pre-fetch probability, pre-fetch the access data to store it in the cache area; The data access sequence for obtaining cached data in the cache area includes: Obtaining an access log set of cached data in the cache area; Performing log sequence extraction on the access log set to obtain an access log sequence set; wherein the access log sequence set includes at least two access log sequences; Extracting log attributes of each access log in each access log sequence in the access log sequence set to obtain a session element sequence corresponding to each access log sequence; Reorganizing each of the session element sequences to obtain the data access sequence corresponding to each of the access log sequences; The learning of data access relevance of the first feature vector sequence to obtain pre-fetch probability of each access data in the file system includes: Adding a special embedding vector to the first feature vector sequence to obtain a new first feature vector sequence; wherein the special embedding vector includes at least one of a special embedding vector MSAK, a special embedding vector SEP, a special embedding vector CLS, and a special embedding vector PAD; Taking the sum of the position embedding vector, the segment embedding vector and the new first feature vector sequence as the first vector to be encoded; Performing data access relevance learning on the first vector to be encoded to obtain a first encoding output vector; Inputting the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder; The first decoding output vector is converted to obtain a pre-fetch probability of each access data in the file system.
2. The cache data processing method according to claim 1, characterized in that: Before prefetching the access data based on the prefetch probability, the method further includes: Generate a cache content list based on the cache data; Performing characterization learning on the cache content list to obtain a second feature vector sequence; Adding a special embedding vector to the second feature vector sequence to obtain a new second feature vector sequence; Taking the sum of the new second feature vector, the position embedding vector and the segment embedding vector as the second vector to be encoded; Performing data access relevance learning on the second vector to be encoded to obtain a second encoded output vector; Inputting the second encoded output vector into a decoder to obtain a second decoded output vector output by the decoder; Performing conversion processing on the second decoded output vector to obtain a replacement probability of each cached data in the cache area; Based on the replacement probability, replacement processing is performed on the cache data to remove the cache data from the cache area.
3. The cache data processing method according to claim 2, characterized in that: The decoder comprises a replacement decoder and a pre-fetch decoder, the first decoding output vector is a pre-fetch decoding output vector, and the second decoding output vector is a replacement decoding output vector; The step of inputting the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder includes: Inputting the first encoding output vector into the pre-fetch decoder to obtain a pre-fetch decoding output vector output by the pre-fetch decoder; The step of inputting the second encoded output vector into a decoder to obtain a second decoded output vector output by the decoder comprises: The second encoded output vector is input into the replacement decoder to obtain a replacement decoded output vector output by the replacement decoder.
4. The cache data processing method according to claim 3, characterized in that: Before inputting the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder, the method further includes: Acquire a training sample set; wherein the training sample set includes a cache list, a positive replacement sample, a negative replacement sample, a positive pre-fetch sample, a pre-fetch task input, and a negative pre-fetch sample; The initial pre-fetch decoder and the initial replacement decoder are trained respectively by using the training sample set to obtain the replacement decoder and the pre-fetch decoder.
5. The cache data processing method according to claim 4, characterized in that: The step of obtaining a training sample set includes: Get the historical data access sequence of the cache area in different time periods; Determining a plurality of target historical data access sequences from all the historical data access sequences; Based on the first proportion, the latter part of all the target historical data access sequences is intercepted to obtain a first subsequence corresponding to each of the target historical data access sequences; Based on all the first subsequences, construct the positive pre-fetch samples, and use the remaining sequences of each target historical data access sequence except the first subsequence as the pre-fetch task input; Determining negative pre-fetch samples from the historical data access sequences except the target historical data access sequence; wherein the number of the negative pre-fetch samples is greater than the number of the positive pre-fetch samples; Based on the second proportion, the front part of all the target historical data access sequences is intercepted to obtain a second subsequence corresponding to each of the target historical data access sequences; Based on all the second subsequences, construct the cache list, and use the remaining sequences of each target historical data access sequence except the second subsequence as the positive replacement samples; Negative replacement samples are determined from the historical data access sequences except the target historical data access sequence; wherein the number of the negative replacement samples is greater than the number of the positive replacement samples.
6. The cache data processing method according to claim 5, characterized in that: The method of using the training sample set to respectively train the initial pre-fetch decoder and the initial replacement decoder to obtain the replacement decoder and the pre-fetch decoder comprises: Performing characterization learning on the pre-fetch task input to obtain a third feature vector sequence; Adding a special embedding vector to the third feature vector sequence to obtain a new third feature vector sequence; Performing correlation learning on the new third feature vector sequence to obtain a pre-fetched embedding vector to be decoded; Inputting the to-be-decoded prefetch embedding vector into the initial prefetch decoder to obtain a target prefetch decoding output vector output by the initial prefetch decoder; Calculating a first output loss of the positive pre-fetch sample and the negative pre-fetch sample with respect to the target pre-fetch decoded output vector; If the first output loss is greater than a preset threshold, the parameters of the initial pre-fetch decoder are updated to obtain a new initial pre-fetch decoder, and the new initial pre-fetch decoder is used as the initial pre-fetch decoder, and the pre-fetch embedding vector to be decoded is input into the initial pre-fetch decoder to obtain a target pre-fetch decoding output vector output by the initial pre-fetch decoder, until the first output loss is less than the preset threshold; If the first output loss is less than the preset threshold, the initial pre-fetch decoder is used as the pre-fetch decoder.
7. The cache data processing method according to claim 5, characterized in that: The method of using the training sample set to respectively train the initial pre-fetch decoder and the initial replacement decoder to obtain the replacement decoder and the pre-fetch decoder comprises: Performing characterization learning on the cache list to obtain a fourth feature vector sequence; Adding a special embedding vector to the fourth feature vector sequence to obtain a new fourth feature vector sequence; Performing data access association learning on the new fourth feature vector sequence to obtain a replacement embedding vector to be decoded; Inputting the to-be-decoded replacement embedding vector into the initial replacement decoder to obtain a target replacement decoding output vector output by the initial replacement decoder; Calculate a second output loss of the positive replacement sample and the negative replacement sample with the target replacement decoding output vector; If the second output loss is greater than a preset threshold, the parameters of the initial replacement decoder are updated to obtain a new initial replacement decoder, and the new initial replacement decoder is used as the initial replacement decoder, and the replacement embedding vector to be decoded is input into the initial replacement decoder to obtain a target replacement decoding output vector output by the initial replacement decoder, until the second output loss is less than the preset threshold; If the second output loss is less than the preset threshold, the initial replacement decoder is used as the replacement decoder.
8. A cache data processing device, characterized in that: The cache data processing device comprises: An acquisition module, used for acquiring a data access sequence of cached data in a cache area; A representation learning module, used for performing representation learning on the data access sequence to obtain a first feature vector sequence; A learning module, used for learning the data access relevance of the first feature vector sequence to obtain the pre-fetch probability of each access data in the file system; A processing module, configured to perform pre-fetch processing on the access data based on the pre-fetch probability, so as to store the access data in the cache area; The acquisition module is further used to acquire an access log set of cached data in the cache area; extract log sequences from the access log set to obtain an access log sequence set; extract log attributes of each access log in each access log sequence in the access log sequence set to obtain a session element sequence corresponding to each access log sequence; reorganize each session element sequence to obtain the data access sequence corresponding to each access log sequence; wherein the access log sequence set includes at least two access log sequences; The learning module is also used to add a special embedding vector to the first feature vector sequence to obtain a new first feature vector sequence; use the sum of the position embedding vector, the segment embedding vector and the new first feature vector sequence as the first vector to be encoded; learn the data access association of the first vector to be encoded to obtain a first encoding output vector; input the first encoding output vector into a decoder to obtain a first decoding output vector output by the decoder; convert the first decoding output vector to obtain a pre-fetch probability of each access data in the file system; wherein the special embedding vector includes at least one of a special embedding vector MSAK, a special embedding vector SEP, a special embedding vector CLS and a special embedding vector PAD.
9. A cache data processing device, characterized in that: The device comprises: a memory, a processor, and a cache data processing program stored in the memory and executable on the processor, wherein the cache data processing program is configured to implement the steps of the cache data processing method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a cache data processing program, and when the cache data processing program is executed by the processor, the steps of the cache data processing method according to any one of claims 1 to 7 are implemented.
11. A computer program product, characterized in that The computer program product comprises a cache data processing program, and when the cache data processing program is executed by a processor, the steps of the cache data processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Cache prefetching method and device, equipment and computer readable storage medium
CN110018970A
Solid state disk data prefetching method based on attention mechanism
CN114706798A
