WO2022213871A1 - 缓存装置、方法及系统 - Google Patents

缓存装置、方法及系统 Download PDF

Info

Publication number
WO2022213871A1
WO2022213871A1 PCT/CN2022/084333 CN2022084333W WO2022213871A1 WO 2022213871 A1 WO2022213871 A1 WO 2022213871A1 CN 2022084333 W CN2022084333 W CN 2022084333W WO 2022213871 A1 WO2022213871 A1 WO 2022213871A1
Authority
WO
WIPO (PCT)
Prior art keywords
cache
target object
probability
candidate
prediction model
Prior art date
Application number
PCT/CN2022/084333
Other languages
English (en)
French (fr)
Inventor
胥皇
单卫华
Original Assignee
华为云计算技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2022213871A1 publication Critical patent/WO2022213871A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a cache device, method, and system.
  • caches are usually set up in business systems such as databases, content distribution networks, and data storage, for example, cache components, cache subsystems, etc., are used to temporarily save data in business systems that may be repeatedly accessed in the near future. .
  • the cache is usually a heuristic cache using preset admission and elimination rules, or a cache based on offline machine learning.
  • heuristic caches and offline machine learning-based caches have problems of poor business adaptability and high maintenance costs.
  • an embodiment of the present application provides a cache device, the cache device includes a control module and a storage module, and the control module is configured to: mark the candidate object according to historical access information of the candidate object; The candidate object is all or part of the target object, the target object is the object indicated in the read request received by the cache device, or the target object is the object indicated in the write request received by the cache device , or the target object is the object to be eliminated in the storage module; add the marked candidate object to the current training set; use the current training set to train the probability prediction model of the current cycle to obtain the next The probability prediction model of the cycle, or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the current training set is used to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle .
  • the embodiment of the present application can automatically mark candidate objects during the operation of the cache device, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the following
  • the probability prediction model of one cycle or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the probability prediction model of the current cycle is trained using the current training set to obtain the probability prediction model of the next cycle, so that the probability prediction model can be realized.
  • Online self-supervised learning of the prediction model that is, automatic sample labeling and training during online operation), thereby realizing online self-supervised learning of the cache device.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • control module is configured to: determine a reference position in the historical access information of the candidate object; The information before the reference position is marked as the reference access information of the candidate object; the information after the reference position in the historical access information is marked as the reference access probability of the candidate object.
  • the reference position is determined in the historical access information of the candidate object, and the information in the historical access information of the candidate object before the reference position is marked as the reference access information of the candidate object, and the historical access information of the candidate object is marked as the reference access information of the candidate object.
  • the information after the reference position in the access information is marked as the reference access probability of the candidate object, so that the candidate object can be automatically marked according to the historical access information during the operation of the cache device, thereby improving the marking efficiency.
  • the control module is configured to: if the target object is the cache device The object indicated in the received write request uses the historical access information of the target object as the input of the probability prediction model of the current cycle, and predicts the probability that the target object is accessed through the probability prediction model of the current cycle; When the predicted probability is greater than or equal to the first probability threshold, the target object is stored in the storage module.
  • the control module when the target object is the object indicated in the write request received by the cache device, the control module can predict the probability that the target object is accessed by using the probability prediction model of the current cycle, and perform the caching calibration according to the predicted probability. access, thereby improving the accuracy of cache access.
  • all The control module is used for: if the target object is an object to be eliminated in the storage module, the historical access information of the target object is used as the input of the probability prediction model of the current cycle, and the The probability prediction model predicts the probability that the target object is accessed; when the predicted probability is less than or equal to a second probability threshold, the target object is eliminated from the storage module.
  • the control module can predict the probability of the target object being accessed through the probability prediction model of the current cycle, and perform cache elimination according to the predicted probability, thereby improving the Accuracy of cache elimination.
  • all The control module is configured to: if the target object is the object indicated in the write request received by the cache device and there is no historical access information of the target object, store the target object in the storage module.
  • the target object when the target object is the object indicated in the write request received by the cache device and there is no historical access information of the target object, the target object is stored in the storage module, which can avoid the failure of the target object without historical access information.
  • Write to the cache device thereby improving the adaptability of the cache device to changes in business scenarios or changes in data access patterns.
  • all The control module is configured to: sample one or more candidate objects from a plurality of the target objects.
  • the number of candidate objects can be reduced, thereby improving processing efficiency.
  • all The control module is configured to: store the candidate object in the storage module.
  • the candidate object is stored in the storage module, so that the historical access information of the candidate object can be continuously updated.
  • the time corresponding to the historical access information of the target object includes a plurality of sub-periods, and the historical access information of the target object includes the access frequency level of the target object in each sub-period.
  • the historical access information of the target object is recorded through the access frequency level of the target object in each sub-period, which can not only save storage space and computing resources, but also record the access behavior of the target object according to the time series, thereby realizing the cache device. Online perception of access behavior of a large number of objects.
  • an embodiment of the present application provides a caching method, the method includes: marking the candidate object according to historical access information of the candidate object; wherein the candidate object is all or part of the target object , the target object is the object indicated in the read request received by the cache device, or the target object is the object indicated in the write request received by the cache device, or the target object is the object to be eliminated in the storage module of the cache device Add the marked candidate object into the current training set; Use the current training set to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle, or the candidate object in the current training set When the number is greater than or equal to the number threshold, the current training set is used to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle; wherein the method is applied to the control module of the cache device.
  • the embodiment of the present application can automatically mark candidate objects during the operation of the cache device, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the following
  • the probability prediction model of one cycle or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the probability prediction model of the current cycle is trained using the current training set to obtain the probability prediction model of the next cycle, so that the probability prediction model can be realized.
  • Online self-supervised learning of the prediction model that is, automatic sample labeling and training during online operation), thereby realizing online self-supervised learning of the cache device.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • the marking the candidate object according to the historical access information of the candidate object includes: in the historical access information of the candidate object Determine the reference position; mark the information in the historical access information before the reference position as the reference access information of the candidate object; mark the information in the historical access information after the reference position as the reference access information The reference access probability of the candidate object.
  • the reference position is determined in the historical access information of the candidate object, and the information in the historical access information of the candidate object before the reference position is marked as the reference access information of the candidate object, and the historical access information of the candidate object is marked as the reference access information of the candidate object.
  • the information after the reference position in the access information is marked as the reference access probability of the candidate object, so that the candidate object can be automatically marked according to the historical access information during the operation of the cache device, thereby improving the marking efficiency.
  • the method further includes: if the target object is received by the caching apparatus Write the object indicated in the request, use the historical access information of the target object as the input of the probability prediction model of the current cycle, and predict the probability that the target object is accessed through the probability prediction model of the current cycle; When the probability is greater than or equal to the first probability threshold, the target object is stored in the storage module.
  • the control module when the target object is the object indicated in the write request received by the cache device, the control module can predict the probability that the target object is accessed by using the probability prediction model of the current cycle, and perform the caching calibration according to the predicted probability. access, thereby improving the accuracy of cache access.
  • all The method further includes: if the target object is an object to be eliminated in the storage module, using the historical access information of the target object as the input of the probability prediction model of the current cycle, and using the probability prediction model of the current cycle The model predicts the probability that the target object is accessed; when the predicted probability is less than or equal to a second probability threshold, the target object is eliminated from the storage module.
  • the control module can predict the probability of the target object being accessed through the probability prediction model of the current cycle, and perform cache elimination according to the predicted probability, thereby improving the Accuracy of cache elimination.
  • all The method further includes: if the target object is the object indicated in the write request received by the cache device and there is no historical access information of the target object, storing the target object in the storage module.
  • the target object when the target object is the object indicated in the write request received by the cache device and there is no historical access information of the target object, the target object is stored in the storage module, which can avoid the failure of the target object without historical access information.
  • Write to the cache device thereby improving the adaptability of the cache device to changes in business scenarios or changes in data access patterns.
  • all The method further includes: sampling one or more candidate objects from a plurality of the target objects.
  • the number of candidate objects can be reduced, thereby improving processing efficiency.
  • all The method further includes: storing the candidate object in the storage module.
  • the candidate object is stored in the storage module, so that the historical access information of the candidate object can be continuously updated.
  • the time corresponding to the historical access information of the target object includes a plurality of sub-periods, and the historical access information of the target object includes the access frequency level of the target object in each sub-period.
  • the historical access information of the target object is recorded through the access frequency level of the target object in each sub-period, which can not only save storage space and computing resources, but also record the access behavior of the target object according to the time series, thereby realizing the cache device. Online perception of access behavior of a large number of objects.
  • an embodiment of the present application provides a chip, where the chip is used to deploy the first aspect or one or more of the possible implementations of the first aspect.
  • the embodiment of the present application can automatically mark candidate objects during the operation of the cache device, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the following
  • the probability prediction model of one cycle or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the probability prediction model of the current cycle is trained using the current training set to obtain the probability prediction model of the next cycle, so that the probability prediction model can be realized.
  • the online self-supervised learning of the prediction model that is, the candidate object annotation and training are automatically performed during the online operation), and then the online self-supervised learning of the cache device is realized.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • embodiments of the present application provide a caching system, including: a caching device for caching objects, where the caching device is one of the first aspect or multiple possible implementations of the first aspect or several kinds of cache devices; a data processing device, used to send a read request or a write request of the object to the cache device; and a data storage device, used to store the object.
  • the cache system includes a cache device, a data processing device, and a data storage device.
  • the data processing device can send a read request or a write request of an object to the cache device.
  • the cache device receives a read request or a write request of an object, Perform corresponding processing, such as object read operation, cache admission processing, etc.
  • the caching device can automatically mark the candidate objects during operation, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the probability prediction of the next cycle model, or use the current training set to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle when the number of candidate objects in the current training set is greater than or equal to the number threshold, so as to realize the online self-service of the probability prediction model.
  • Supervised learning and then realize the online self-supervised learning of the cache device.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • embodiments of the present application provide a cache system, including: a data processing device, where the data processing device includes a processor and a cache device for caching objects, wherein the processor is configured to send the cache to the cache The device sends a read request or a write request of the object, and the cache device is the cache device of the first aspect or one or more of the multiple possible implementations of the first aspect; a data storage device, used for Store the object.
  • the cache system includes a data processing device and a data storage device
  • the data processing device includes a processor and a cache device
  • the processor can send a read request or a write request of an object to the cache device
  • the cache device receives the read request of the object.
  • perform corresponding processing such as object read operation, cache admission processing, etc.
  • the cache device can automatically mark the candidate objects, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the probability of the next cycle.
  • Prediction model or use the current training set to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle when the number of candidate objects in the current training set is greater than or equal to the number threshold, so that the online probability prediction model can be realized.
  • Self-supervised learning and then realize the online self-supervised learning of the cache device.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • embodiments of the present application provide an electronic device, including: a processor; and a memory for storing instructions executable by the processor, wherein the processor is configured to implement the above-mentioned second when executing the instructions One or more caching methods of the aspect or the multiple possible implementation manners of the second aspect.
  • the embodiment of the present application can automatically mark candidate objects during the operation of the cache device, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the following The probability prediction model of one cycle, or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the probability prediction model of the current cycle is trained using the current training set to obtain the probability prediction model of the next cycle, so that the probability prediction model can be realized.
  • the online self-supervised learning of the prediction model, and then the online self-supervised learning of the cache device is realized.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • embodiments of the present application provide a non-volatile computer-readable storage medium on which computer program instructions are stored, wherein the computer program instructions implement the second aspect when executed by a processor Or one or more caching methods in multiple possible implementation manners of the second aspect.
  • the embodiment of the present application can automatically mark candidate objects during the operation of the cache device, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the following The probability prediction model of one cycle, or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the probability prediction model of the current cycle is trained using the current training set to obtain the probability prediction model of the next cycle, so that the probability prediction model can be realized.
  • the online self-supervised learning of the prediction model, and then the online self-supervised learning of the cache device is realized.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • embodiments of the present application provide a computer program product, comprising computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are stored in an electronic
  • the processor in the electronic device executes the second aspect or one or more of the caching methods in the multiple possible implementation manners of the second aspect.
  • the embodiment of the present application can automatically mark candidate objects during the operation of the cache device, add the marked candidate objects to the current training set, and then use the current training set to train the probability prediction model of the current cycle to obtain the following The probability prediction model of one cycle, or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the probability prediction model of the current cycle is trained using the current training set to obtain the probability prediction model of the next cycle, so that the probability prediction model can be realized.
  • the online self-supervised learning of the prediction model, and then the online self-supervised learning of the cache device is realized.
  • the cache device can automatically perceive and adapt to various business scenarios and changes in business scenarios or data access patterns, and improve the cache performance. While improving the service adaptability of the device, the maintenance cost of the cache device can also be reduced.
  • FIG. 1a shows a schematic diagram of an application scenario of a cache device according to an embodiment of the present application.
  • FIG. 1b shows a schematic diagram of an application scenario of a cache device according to an embodiment of the present application.
  • FIG. 2 shows a block diagram of a cache device according to an embodiment of the present application.
  • FIG. 3 shows a schematic diagram of a simplified knowledge storage structure according to an embodiment of the present application.
  • FIG. 4 shows a schematic diagram of a processing procedure of a control module of a cache device according to an embodiment of the present application.
  • FIG. 5a shows a schematic diagram of annotation of a candidate object according to an embodiment of the present application.
  • FIG. 5b shows a schematic diagram of annotation of a candidate object according to an embodiment of the present application.
  • FIG. 6a shows a schematic diagram of a processing procedure of cache admission of a cache device according to an embodiment of the present application.
  • FIG. 6b shows a schematic diagram of a processing procedure of cache admission of a cache device according to an embodiment of the present application.
  • FIG. 7 is a schematic diagram illustrating a process of cache elimination of a cache device according to an embodiment of the present application.
  • FIG. 8 shows a flowchart of a caching method according to an embodiment of the present application.
  • the cache In a business system (which can also be considered an application system), the cache is usually used to temporarily store data that may be accessed repeatedly in the near future to reduce disk read and write overhead and network request overhead caused by repeated access to the same data, thereby reducing Data access latency.
  • Caches usually manage data in objects as the smallest unit. An object may include a piece of data in the cache and its corresponding description information (also called meta information).
  • the cache medium is the physical medium used to store data in the cache, such as memory, disk, etc. Cache media are generally fast to access but have small storage capacity.
  • the business system obtains data by requesting the cache. If the data is in the cache, the cache hits; if the data is not in the cache, the cache misses.
  • the ratio of cache hit data to all requested data is called the cache hit rate. The higher the cache hit rate, the faster the data access speed of the business system, and the better its performance.
  • Cache admission refers to the process in which the cache determines whether to write the object indicated by the write request into the cache medium when it receives the write request. For example, before the object enters the cache medium, it is judged whether the object has cache value. If the object has cache value, the object is written to the cache medium; if the object has no cache value, the object is not written to the cache medium.
  • Cache elimination refers to the process of cache deletion or overwriting of objects in the cache medium.
  • Cache elimination algorithms usually tend to retain new objects and eliminate old objects, such as eliminating least recently used (LRU) objects, object first in first out (FIFO), etc.
  • the cache adopts a rule-based admission and elimination method, and this type of cache may be called heuristic cache.
  • heuristic cache Most of the current mainstream application-level cache systems (or cache subsystems) are heuristic caches.
  • Apache traffic server apache traffic server, ATS
  • distributed memory object cache system memcached
  • squid cache proxy server squid cache
  • the admission method of heuristic cache usually includes second hit, admission based on statistical information, etc.
  • the second admission means that the object that is accessed for the first time recently is not written to the cache, and the object that has been accessed for the second or more times recently is written to the cache.
  • Statistical-based admission means to count the recent access times of each object separately, and write the objects whose access times exceed the threshold of access times to the cache, otherwise they will not be written to the cache.
  • Heuristic cache elimination methods usually include LRU, FIFO, least frequency used (LFU), and methods similar to LRU, FIFO, and LFU.
  • a statistical module can also be introduced on the basis of rule-based cache admission and elimination to count the frequency of objects being accessed in a short period of time, and perform cache admission based on the statistical results of the statistical module. and elimination decisions.
  • the cache admission and elimination rules need to be formulated in advance before the business system runs.
  • the pre-established cache admission and elimination rules are usually difficult to adapt to the actual data access mode (such as data access distribution) of the business system, and also difficult to adapt to various business scenarios of the business system. For example, suppose that the cache access rule specifies that data less than 1MB does not meet the access conditions, that is, it is not allowed to enter the cache.
  • the cache access rule specifies that data less than 1MB does not meet the access conditions, that is, it is not allowed to enter the cache.
  • the business system is running, due to mechanisms such as data fragmentation, the data may be less than 1MB or greater than 1MB.
  • the fixed cache admission rules cannot achieve the expected effect. Therefore, the business adaptability of heuristic caching is poor.
  • offline machine learning-based caching is used.
  • a machine learning model for predicting the probability of an object being accessed is introduced into the cache, and based on the prediction result of the machine learning model, the decision of cache admission and elimination is made.
  • the application method of the machine learning model is offline training-online deployment. That is to say, after introducing the machine learning model into the cache, it is usually necessary to collect the data accessed by the business system, label the collected data offline, and then use the labelled data to train the machine learning model offline.
  • the machine learning model is deployed online.
  • the present application provides a cache device.
  • the cache device of the embodiment of the present application includes a control module and a storage module, and the control module is configured to: mark the candidate object according to the historical access information of the candidate object, wherein the candidate object is all or part of the target object, and the target object is the cache device The object indicated in the received read request, or the target object is the object indicated in the write request received by the cache device, or the target object is the object to be eliminated in the storage module; add the marked candidate object to the current training set; use the current The training set trains the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle, or uses the current training set to train the probability prediction model of the current cycle when the number of candidate objects in the current training set is greater than or equal to the number threshold to get the probability prediction model for the next cycle.
  • the candidate objects can be automatically marked, the marked candidate objects can be added to the current training set, and then the current training set is used to train the probability prediction model of the current cycle to obtain the next The probability prediction model of the cycle, or when the number of candidate objects in the current training set is greater than or equal to the number threshold, the probability prediction model of the current cycle is trained using the current training set to obtain the probability prediction model of the next cycle, so as to realize the probability prediction Online self-supervised learning of the model (that is, automatic sample labeling and training during online operation), thereby realizing online self-supervised learning of the cache device.
  • the cache device of the embodiment of the present application realizes the online self-supervised learning of the cache device by introducing a probability prediction model driven by object behavior and can be automatically supervised and learned online.
  • the cache hit rate is improved, and the cache device can automatically perceive and adapt to a variety of business scenarios and changes in business scenarios or data access modes, thereby improving the business adaptability of the cache device and reducing the maintenance cost of the cache device.
  • FIG. 1a shows a schematic diagram of an application scenario of a cache device according to an embodiment of the present application.
  • a cache system including a data processing device 100, a cache device 200 for caching objects, and a data storage device 300 for storing objects.
  • the cache device 200 is located outside the data processing apparatus 100 .
  • the data processing device 100 may send a read request or a write request of an object to the cache device 200, and the cache device 200 performs corresponding processing when receiving the read request or write request of the object, for example, an object read operation, cache admission processing, etc.
  • the data processing device 100 when the data processing device 100 reads an object, it first sends a read request to the cache device 200 . If the object requested by the data processing device 100 exists in the cache device 200 , the cache is hit, and the data processing device 100 directly retrieves the data from the cache device 200 . Read the object; if the object requested by the data processing device 100 does not exist in the cache device 200 , the cache misses, and the data processing device 100 reads the object from the data storage device 300 .
  • the data processing device 100 is used for processing the objects stored in the data storage device 300 .
  • the data processing device 100 may be a server, a terminal device, or the like in a business system such as a content distribution network and data storage. It should be noted that the data processing device 100 may also be other data processing devices, which are not limited in this application.
  • the cache device 200 is used to temporarily store objects that may be repeatedly accessed by the data processing device 100 in the near future, so as to reduce the data access delay of the data processing device 100 and improve the data access efficiency.
  • the data processing device 100 may also send a write request of the object to the cache device 200.
  • the cache device 200 receives the write request of the object, it starts the process of cache admission to determine whether to allow the object indicated by the write request to be written to the cache device.
  • FIG. 1b shows a schematic diagram of an application scenario of a cache device according to an embodiment of the present application.
  • a cache system including a data processing device 100 and a data storage device 300 for storing objects.
  • the data processing device 100 includes a processor 110 and a cache device 200 , that is, the cache device 200 is located inside the data processing device 100 .
  • the processor 110 may send a read request or a write request of the object to the cache device 200 .
  • the cache apparatus 200 receives a read request or a write request of an object, it performs corresponding processing, for example, an object read operation, a cache admission processing, and the like.
  • the cache device 200 when the cache device 200 is applied in a business system, the cache device may be implemented as an independent cache subsystem in the business system (as shown in the application scenario shown in FIG. 1a ), or as a business system The cache component of the server and other devices in the system (the application scenario shown in Figure 1b). It should be noted that a person skilled in the art can set a specific implementation manner of the cache device according to the actual situation, which is not limited in this application.
  • FIG. 2 shows a block diagram of a cache device according to an embodiment of the present application.
  • the cache device 200 includes a control module 210 and a storage module 220 .
  • the control module 210 is used to implement functions such as cache admission, cache elimination, automatic annotation of candidate objects, and online training of probability prediction models;
  • the storage module 220 is the cache medium (such as memory, disk, network medium, etc.) data.
  • the control module 210 may be implemented by a processor.
  • the processor may include one or more processing units.
  • the processor may include a central process unit (CPU), an application processor (application processor, AP), a modem processor, and a graphics processor (graphics processing unit). unit, GPU), image signal processor (ISP), controller, video codec, digital signal processor (DSP), baseband processor, and/or neural network processor (neural) -network processing unit, NPU), etc.
  • CPU central process unit
  • application processor application processor
  • AP application processor
  • modem processor a graphics processor
  • graphics processor graphics processor
  • graphics processor graphics processor
  • unit GPU
  • ISP image signal processor
  • DSP digital signal processor
  • NPU neural network processor
  • different processing units may be independent devices, or may be integrated in one or more processors. This application does not limit the specific type of the processor.
  • the cache apparatus 200 manages the cached data in units of objects.
  • the control module 210 may record historical access information of each object.
  • the historical access information of the object may include the time when the object was accessed, the number of times the object was accessed, the time when the object was written to the cache device 200, and the like.
  • the control module 210 can directly record the original access information such as the time when the object is accessed, the number of times the object is accessed, and the time when the object is written into the cache device 200; it can also process the original access information of the object. It will be recorded later, which is not limited in this application.
  • the historical access information of objects can be recorded by means of hash tables, ordered arrays, etc.
  • the historical access information of the object can be attached to the data structure of the object, stored together with the object, or stored independently.
  • the present application does not limit the recording method and storage method of the historical access information of the object in the cache device.
  • the control module 210 After the object is written into the storage module 220 (ie, the cache medium), the control module 210 starts to record its historical access information. When the object is read, the object is eliminated from the storage module 220, or the object is written to the storage module 220 again, the control module 210 will update the historical access information of the object in real time.
  • the time length of the historical access information of the object may be preset. For example, assuming that the historical access information of the object in the last 15 days needs to be recorded, the time length of the historical access information of the object can be set to 15 days.
  • the time length of the historical access information may be determined according to the cache period of each object in the cache device.
  • the cache period of an object refers to the time period from when the object is written into the storage module of the cache device to when the object is eliminated from the storage module of the cache device.
  • the time length of the historical access information can be set to be greater than the average value of the cache period of each object in the cache device.
  • the business scenario of the business system, data access mode, etc. can also be considered. This application does not limit the setting basis and specific value of the time length of the historical access information.
  • the historical access information of the object is also continuously updated as the current time goes forward.
  • the time length of historical access information can be regarded as a time window that can slide forward. As the current moment moves forward, the time window also slides forward.
  • the control module will continue to The historical access information of the object is updated, so that the historical access information of the object can be continuously updated as the current time moves forward.
  • the historical access information that slips out of the time window can be overwritten or deleted, or can be stored in a preset area for subsequent continued use, or other processing such as statistical analysis.
  • the time period corresponding to the historical access information of the object may be divided into multiple sub-periods, and the historical access information of the object may include The level of access frequency within each sub-period.
  • the historical access information of objects can be recorded through a reduced knowledge storage structure.
  • the reduced knowledge storage structure can record the access frequency level of the object in each sub-period by using a storage space with a preset length (for example, 4 bytes).
  • the control module can establish a corresponding simplified knowledge storage structure for the object to record its historical access information.
  • the time period corresponding to the historical access information of the object can be divided into multiple sub-periods, and the storage space of the simplified knowledge storage structure can be divided into multiple sub-spaces.
  • the number of spaces can be the same as the number of sub-periods, that is, sub-spaces correspond to sub-periods one-to-one, each sub-space stores the historical access information of objects in the corresponding sub-period, or the number of sub-spaces can also be greater than the number of sub-periods, each Each sub-period corresponds to a sub-space, and the remaining sub-space can be used to store other state information of the object, such as whether the object is an important object, and whether the object is an object reserved in the last cache cycle (that is, the objects that need to be eliminated but not eliminated in the last cache cycle).
  • the reduced knowledge storage structure of the object may include multiple subspaces, and correspondingly, the time period corresponding to the historical access information of the object may also include multiple subperiods, and each subperiod corresponds to a subspace in the reduced knowledge storage structure.
  • the historical access information of the object may include the access frequency level of the object in each sub-period, and the access frequency level of the object in each sub-period may be stored in the corresponding subspace of the reduced knowledge storage structure.
  • FIG. 3 shows a schematic diagram of a simplified knowledge storage structure according to an embodiment of the present application.
  • the storage space of the reduced knowledge storage structure of the object is 32 bits, and the reduced knowledge storage structure can be divided into 16 subspaces, and the size of each subspace is 2 bits.
  • the 16 subspaces are numbered in sequence: the first subspace is the 0-1st position, the second subspace is the 2nd-3rd position, ..., the 16th subspace is the 30th-31st position,
  • the time period corresponding to the historical access information of the object is divided into 15 sub-periods, and the 15 sub-periods are numbered according to the distance from the current moment to the farthest: the first sub-period is before the current moment and is the same as the current moment.
  • the second sub-period is the sub-period before the 1st sub-period and adjacent to the 1st sub-period
  • the 15th sub-period is before the 14th sub-period and is adjacent to the 14th sub-period adjacent sub-periods.
  • the sub-periods and sub-spaces correspond according to the numbers: the first sub-period corresponds to the first sub-space, the second sub-period corresponds to the second sub-space, ..., the 15th sub-period corresponds to the 15th sub-space .
  • the access frequency level of the object in each sub-period is determined according to the preset access frequency level division rule and the number of visits of the object in each sub-period. Since the size of each subspace is 2 bits, 00, 01, 10, and 11 can be used to represent 4 states or levels.
  • the preset access frequency level division rule is: if the number of visits of the object in the sub-period is less than the first threshold of the number of visits (for example, 50), then set the access frequency level of the object in the sub-period to level 0, which is represented by 00 in the sub-space; ) and less than the second access times threshold (for example, 200), then set the access frequency level of the object in this sub-period to level 1, which is represented by 01 in the sub-space; if the number of visits of the object in the sub-period is greater than or equal to The second threshold of access times (for example, 200) and less than the third threshold of access times (for example, 500), then the access frequency level of the object in this sub-period is set to level 2, which is represented by 10 in the subspace; if the object is in the subspace If the number of visits in the period is greater than or equal to the third threshold of visit times (for example, 500), the visit frequency level of the object in the sub-period is set to level 3, which
  • the access frequency level of the object in each sub-period may be stored in the corresponding subspace of the reduced knowledge storage structure.
  • the 16th subspace of the simplified knowledge storage structure can be used to store other state information of the object.
  • the 30th bit can be used to indicate whether the object is an important object. If the object is an important object, set the 30th bit to 1. If it is not an important object, set the 30th bit to 0; you can use the 31st bit to indicate whether the object is the object reserved in the previous cache cycle, if the object is the object reserved in the previous cache cycle, set the 31st bit to 1 , If the object is not an object retained in the last cache cycle, set bit 31 to 0.
  • the value stored in the 1st-3rd subspace is 11, indicating that the access frequency level of the object in the 1st-3rd sub-period is level 3, and it can be considered that the object is in the 1st-3rd sub-period.
  • the object's heat level is the hottest;
  • the value stored in the 4-9 sub-space is 10, indicating that the object's access frequency level in the 4-9 sub-period is level 2, which can be It is considered that the object has more accesses in the 4th-9th sub-period, and the object's heat level is hot;
  • the value stored in the 10-13th sub-space is 01, indicating that the object's access frequency level in the 10-13th sub-period is Level 1, it can be considered that the object has a small amount of access in the 10-13th sub-period, and the object's heat level is warm;
  • the value stored in the 14-15th sub-space is 00, indicating that the object is accessed in the 14-15th sub-period.
  • the frequency level is level 0, it can be considered that the object has basically no access in the 14th-15th sub-period, and the object's heat level is cold.
  • the value stored in the 16th subspace is 00, indicating that the object is not an important object, nor is it an object retained in the previous cache cycle.
  • the access frequency level of the object corresponding to the simplified knowledge storage structure gradually increases. It can be seen that the number of accesses of the object is on the rise, and its popularity also gradually increases.
  • FIG. 3 only takes FIG. 3 as an example to illustrate the simplified knowledge storage structure.
  • Those skilled in the art can determine the size of the storage space of the simplified knowledge storage structure, the division of sub-regions, and the objects according to the actual situation.
  • the division of sub-periods of the time period corresponding to the historical access information, the corresponding relationship between sub-regions and sub-periods, the access frequency level division rules, etc. are set, which are not limited in this application.
  • the historical access information of objects is recorded in the way of access frequency level, which can not only save storage space and computing resources, but also record the access behavior of objects according to time series, so as to realize the access behavior of a large number of objects to improve the prediction accuracy of the object's future visit probability.
  • the control module can not only sense the business scenarios of the business system, but also the changes in the business scenarios or data access modes of the business system, so that the cache device can make adaptive adjustments.
  • a probabilistic prediction model may be deployed in the cache device, for example, a probabilistic prediction model is deployed on a control module of the cache device.
  • the probability prediction model can be used to predict the probability that the object indicated in the write request received by the cache device is accessed, or predict the probability that the object to be eliminated in the storage module of the cache device is accessed.
  • Probabilistic prediction models can be machine learning models such as logistic regression models, neural networks, tree-based models, and support vector machines (SVMs). The present application does not limit the specific type of the probability prediction model.
  • the operation process of the cache device can be divided into multiple cycles according to the update cycle of the probability prediction model.
  • the processing procedure of the control module is exemplarily described below by taking the current cycle as an example.
  • FIG. 4 shows a schematic diagram of a processing procedure of a control module of a cache device according to an embodiment of the present application. As shown in Figure 4, the processing process of the control module includes:
  • Step S401 Mark the candidate object according to the historical access information of the candidate object.
  • the candidate object is all or part of the target object, the target object is the object indicated in the read request received by the cache device, or the target object is the object indicated in the write request received by the cache device, or the target object is to be eliminated in the storage module part of the object. It should be noted that, those skilled in the art can set the specific objects included in the candidate object and the target object (ie, the range of the candidate object and the target object) according to the actual situation, which is not limited in this application.
  • the target object in the business scenario or data access mode of the business system, if the data read accounts for a large proportion (for example, the data read accounts for 95%), the target object can be set to the object indicated in the read request received by the cache device , the candidate object is all or part of the target object; in the business scenario or data access mode of the business system, if data reading and data writing are relatively balanced, the target object can be set to include the object indicated in the read request received by the cache device and the object indicated in the write request received by the cache device, and the candidate object is all or part of the target object.
  • the target object may also be an object to be eliminated in the storage module, and the candidate object may be a part of the target object, that is, the candidate object is a part of the objects to be eliminated in the storage module.
  • the control module may sample one or more candidate objects from multiple target objects.
  • the control module can sample one or more candidate objects from multiple target objects according to a sampling rule, wherein the sampling rule can be random sampling according to the sampling ratio; the sampling rule can also be based on the sampling ratio and the identification of the target object
  • a modulo operation may be performed on the ID of the target object according to the sampling ratio, and sampling may be performed according to the result of the modulo operation. It should be noted that those skilled in the art can set the specific content of the sampling rule according to the actual situation, which is not limited in this application.
  • the number of candidate objects can be reduced, thereby improving processing efficiency.
  • a part of the information in the historical access information of the candidate object may be marked as the reference access information of the candidate object, which is used as the input when training the probability prediction model, that is, as the input for training the probability prediction model.
  • the reference access probability can be used as the reference output when training the probability prediction model.
  • the control module may first determine the reference position in the historical access information of the candidate object.
  • the reference position may be used to indicate, in the historical access information of the candidate object, the boundary position between the information of the reference access information of the candidate object and the information used to determine the reference access probability of the candidate object.
  • the historical access information of the candidate object is recorded through a 32-bit simplified knowledge storage structure, which includes 16 subspaces, and the boundary position between the fourth subspace and the fifth subspace can be set as the reference position.
  • the reference position may also be set according to a plurality of sub-periods corresponding to the reduced knowledge storage structure. This application does not limit the setting method and specific location of the reference location.
  • the information before the reference position in the historical access information of the candidate object can be marked as the reference access information of the candidate object as the input when training the probability prediction model.
  • the historical access information of the candidate object is recorded through a 32-bit simplified knowledge storage structure, which includes 16 subspaces (the 16th subspace is used to record state information), and the reference position is the 4th subspace and the 5th subspace.
  • the boundary position of each subspace can be marked as the reference access information of the candidate object by marking the information in the historical access information of the candidate object before the reference position, that is, the information stored in the 5th to 15th subspaces in the reduced knowledge storage structure.
  • the information after the reference position in the historical access information of the candidate object can be marked as the reference access probability of the candidate object.
  • the probability prediction model is a regression model
  • the historical access information of the candidate object is recorded through a 32-bit simplified knowledge storage structure, which includes 16 subspaces (the 16th subspace is used to record state information), and the reference location is The boundary position between the 4th subspace and the 5th subspace can convert the binary values (that is, the 0th to 7th bits) stored in the 1st to 4th subspaces in the simplified knowledge storage structure into decimal values, and normalize them. After normalization, the normalized value is marked as the reference access probability of the candidate object.
  • the reference access probability of the candidate object may be determined in a manner similar to the regression model described above, which will not be repeated here. After the reference access probability of the candidate object is determined, positive and negative samples can also be marked on the candidate object. For example, candidates with reference access probability greater than a classification threshold (eg, 0.5) may be labeled as positive samples, and candidates with reference access probability less than or equal to the classification threshold (eg, 0.5) may be labeled as negative samples.
  • a classification threshold eg, 0.5
  • FIG. 5a shows a schematic diagram of annotation of a candidate object according to an embodiment of the present application.
  • the historical access information of the candidate object A is recorded through a 32-bit simplified knowledge storage structure 400.
  • the simplified knowledge storage structure 400 includes 16 subspaces (the 16th subspace is used to record state information), and the reference position in the historical access information of the candidate object A is the boundary position between the 4th subspace and the 5th subspace.
  • the dashed line 420 is shown.
  • the information on the left side of the dotted line 420 in the reduced knowledge storage structure 400 can be marked as the reference access information of the candidate object A; the reduced knowledge storage
  • the information on the right side of the dotted line 420 in the structure 400 is marked as the reference access probability of the candidate object A.
  • an access frequency curve 410 of the candidate object A corresponding to the information stored in the reduced knowledge storage structure 400 is shown. It can be seen from the access frequency curve 410 that the access frequency of the candidate object A gradually decreases, that is, the popularity of the candidate object A gradually decreases.
  • FIG. 5b shows a schematic diagram of annotation of a candidate object according to an embodiment of the present application.
  • the historical access information of candidate object B is recorded through a 32-bit simplified knowledge storage structure 430.
  • the simplified knowledge storage structure 430 includes 16 subspaces (the 16th subspace is used to record state information), and the reference position in the historical access information of the candidate object B is the boundary position between the third subspace and the fourth subspace.
  • the dashed line 440 is shown.
  • the information on the left side of the dotted line 440 in the reduced knowledge storage structure 430 can be marked as the reference access information of the candidate object B; the reduced knowledge storage
  • the information on the right side of the dotted line 440 in the structure 430 is marked as the reference access probability of the candidate object B.
  • an access frequency curve 450 of the candidate object B corresponding to the information stored in the reduced knowledge storage structure 430 is shown. It can be seen from the access frequency curve 450 that the access frequency of the candidate object B gradually increases, that is, the popularity of the candidate object B gradually increases.
  • the reference position is determined in the historical access information of the candidate object, and the information in the historical access information of the candidate object before the reference position is marked as the reference access information of the candidate object, and the historical access information of the candidate object is in the reference position.
  • the subsequent information is marked as the reference access probability of the candidate object, so that the candidate object can be automatically marked according to the historical access information during the operation of the cache device, thereby improving the marking efficiency.
  • Step S402 adding the marked candidate objects to the current training set.
  • the current training set is used to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle.
  • the control module may directly store the candidate object in the storage module, That is, direct admission to candidate objects. If the candidate object is an object to be eliminated in the storage module of the cache device, the control module may also directly store the candidate object in the storage module, that is, the candidate object is not eliminated. In this way, the candidate object can be stored in the storage module so as to continuously update the historical access information of the candidate object.
  • Step S403 use the current training set to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle, or use the current training set when the number of candidate objects is greater than or equal to the number threshold.
  • the current training set is used to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle.
  • the current training set can be used to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle, thereby realizing Online Incremental Training of Probabilistic Prediction Models.
  • the training is asynchronous incremental training, which does not affect the online operation of the probability prediction model of the current cycle.
  • the control module after the control module adds the marked candidate objects to the current training set, it can also determine whether the number of candidate objects in the current training set is greater than or equal to a number threshold (eg, 1000, 2000, etc.). If the number of candidate objects in the current training set is less than the number threshold, the control module may repeatedly perform steps S401 and S402 to continuously automatically mark the candidate objects and add them to the current training set. If the number of candidate objects in the current training set is greater than or equal to the number threshold, the control module may use the current training set to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle. The training is also asynchronous incremental training, which does not affect the online operation of the probability prediction model of the current cycle.
  • a number threshold eg, 1000, 2000, etc.
  • a training algorithm that supports incremental training and updating of parameters such as a stochastic gradient descent algorithm
  • the training algorithm that supports incremental training and updating of parameters can calculate the gradient of the loss function of the probability prediction model to its parameters according to a small number of candidate objects, and update the parameters of the probability prediction model in the direction of negative gradient at a certain rate, such as the error back propagation algorithm , thereby reducing the error of the probabilistic prediction model on the candidate object.
  • Incremental training of the probabilistic prediction model through the training sets of each cycle enables the probabilistic prediction model to be continuously updated.
  • the loss function value of the probability prediction model on the candidate object increases, and the gradient increases, which will update the parameters of the probability prediction model in a more drastic way.
  • the parameters of the probability prediction model gradually converge to stable values through multiple iterations of training.
  • the cache device of the embodiment of the present application can use the asynchronous incremental training method, that is, only a small training set is used for each training, and the trained parameters are updated to the probability prediction model running online, so that the training process can be changed. Computational and storage costs are amortized in the running process of the cache device, enabling lightweight online self-supervised learning. At the same time, through online incremental training, the cache device can automatically adapt to changes in business scenarios and changes in data access patterns.
  • the cache device of the embodiment of the present application realizes the online self-supervised learning of the cache device by introducing a probability prediction model driven by object behavior and can be automatically supervised online.
  • the cache hit rate is improved, and the cache device can automatically perceive and adapt to various business scenarios of the business system and changes in business scenarios or data access modes, which can improve the business adaptability of the cache device and reduce the maintenance cost of the cache device.
  • control module not only implements the processing process shown in FIG. 4 , but also simultaneously performs cache admission and cache elimination of the target object.
  • the control module may use the historical access information of the target object as the input of the probability prediction model of the current cycle, and predict that the target object will be affected by the probability prediction model of the current cycle. access probability, and determine whether the predicted probability is greater than or equal to the first probability threshold. If the predicted probability is greater than or equal to the first probability threshold, cache writing is performed to store the target object in the storage module. If the predicted probability is less than the first probability threshold, the cache write is terminated, and the target object is not allowed to be stored in the storage module. In this way, the control module can perform cache access according to the predicted probability of the target object being accessed, thereby improving the accuracy of cache access.
  • the control module may store the target object in the storage module, that is, perform cache writing. In this way, it can be avoided that the target object without historical access information cannot be written into the cache device, thereby improving the adaptability of the cache device to changes in business scenarios or changes in data access patterns.
  • the control module can use the historical access information of the target object as the input of the probability prediction model of the current cycle, predict the probability of the target object being accessed through the probability prediction model of the current cycle, and determine the prediction Whether the probability of is less than or equal to the second probability threshold. If the predicted probability is less than or equal to the second probability threshold, cache elimination is performed, and the target object is eliminated from the storage module. If the predicted probability is greater than the second probability threshold, the target object is not eliminated, and the target is retained in the storage module. In this way, the control module can perform cache elimination according to the predicted probability of the target object being accessed, thereby improving the accuracy of cache elimination.
  • first probability threshold and second probability threshold may be set according to business scenarios, data access modes, existing experience, and the like.
  • the first probability threshold and the second probability threshold may be fixed values or floating values.
  • the second probability threshold may be the same as the first probability threshold, or may be smaller than the first probability threshold.
  • Those skilled in the art can set specific values of the first probability threshold and the second probability threshold according to the actual situation, which is not limited in this application.
  • the cache device When the cache device receives a read request from the data processing device for the target object C (that is, the target object C is the object indicated in the read request received by the cache device), the cache device can find out whether the target object C exists in the storage module.
  • the cache hits, and the data processing device reads the target object C from the storage module of the cache device.
  • the control module of the cache device updates the historical access information of the target object C.
  • the control module can also mark the target object C according to the historical access information of the target object C, and add the marked target object C to the current training set. In this way, the candidate objects related to the read request can be included in the current training set.
  • the cache misses, and the data processing device fails to read the target object C from the cache device.
  • the data processing device then reads the target object C from the data storage device.
  • FIG. 6a shows a schematic diagram of a processing procedure of cache admission of a cache device according to an embodiment of the present application.
  • the candidate objects are all target objects
  • the target objects are the objects indicated in the write request received by the cache device.
  • the cache apparatus receives a write request for the target object D1 in step S601.
  • the control module initiates the cache admission process.
  • step S602 the control module may determine whether the target object D1 (ie, the object indicated in the write request received by the cache device) has historical access information. If the target object D1 has no historical access information, step S607 is executed to store the target object D1 in the storage module. At the same time, since the target object D1 has no historical access information, the control module can establish a corresponding simplified knowledge storage structure for the target object D1, using It is used to record the historical access information of the target object D1. In this way, it is possible to avoid a situation in which a target object without historical access information cannot be written into the cache device, thereby improving the adaptability of the cache device to changes in business scenarios or changes in data access patterns.
  • the target object D1 ie, the object indicated in the write request received by the cache device
  • step S603 is performed to obtain the historical access information of the target object D1
  • step S604 the target object D1 is used as a candidate object, and then steps S608 and S605 are simultaneously performed:
  • step S608 the candidate object (that is, the target object D1) is stored in the storage module, the cache access of the target object D1 is realized, and the historical access information of the target object D1 is updated simultaneously;
  • step S605 the candidate object is marked according to the historical access information of the candidate object, and in step S606, the marked candidate object is added to the current training set. In this way, candidates related to write requests can be included in the current training set.
  • FIG. 6b shows a schematic diagram of a processing procedure of cache admission of a cache device according to an embodiment of the present application.
  • the candidate objects are part of the target objects, and the target objects are the objects indicated in the write request received by the cache device.
  • the cache device receives a write request for the target object D2 in step S611.
  • the control module starts the cache admission process.
  • the control module may determine whether the target object D2 has historical access information in step S612. If the target object D2 has no historical access information, step S617 is executed to store the target object D2 in the storage module. At the same time, since the target object D2 has no historical access information, the control module can establish a corresponding simplified knowledge storage structure for the target object D2, using It is used to record the historical access information of the target object D2.
  • step S613 is executed to obtain the historical access information of the target object D2, and in step S614, it is determined whether the target object D2 is a candidate object. If the target object D2 is a candidate object, step S620 and step S618 are performed simultaneously:
  • step S620 the candidate object (that is, the target object D2) is stored in the storage module, thereby completing the cache access when the target object D2 is the candidate object;
  • step S618 the candidate object is marked according to the historical access information of the candidate object, and in step S619, the marked candidate object is added to the current training set. In this way, candidates related to write requests can be included in the current training set.
  • step S615 is executed, the historical access information of the target object D2 is used as the input of the probability prediction model of the current cycle, the probability of the target object D2 being accessed is predicted by the probability prediction model of the current cycle, and the In step S616, it is determined whether the predicted probability is greater than or equal to the first probability threshold.
  • step S617 is executed, the target object D2 is stored in the storage module, the cache access of the target object D2 is realized, and the historical access information of the target object D2 is updated at the same time .
  • step S621 is executed to terminate the cache writing, that is, the target object D2 does not meet the cache access requirements, and the target object D2 is not written into the storage module.
  • the control module of the cache device can start the process of cache elimination.
  • the target object D1 or the target object D2 can be directly stored in the storage module; and when the storage module of the cache device is full, that is, in the available space of the storage module When the storage space is smaller than the storage space occupied by the target object D1 or the target object D2, in order to free up the storage space for the target object D1 or the target object D2, one or more objects need to be eliminated from the storage module.
  • FIG. 7 is a schematic diagram illustrating a process of cache elimination of a cache device according to an embodiment of the present application.
  • the candidate objects are partial target objects
  • the target objects are objects to be eliminated in the storage module.
  • control module may, in step S701 , determine the target objects E to be eliminated in the storage module, and the target objects E may be one or more. For any target object E, in step S702, the historical access information of the target object E can be obtained, and in step S703, it is determined whether the target object E is a candidate object.
  • step S710 and step S708 are executed simultaneously:
  • step S710 the candidate object (that is, the target object E) is kept in the storage module, that is, the target object E is not eliminated;
  • step S708 the candidate object is marked according to the historical access information of the candidate object (ie, the target object E), and in step S709, the marked candidate object is added to the current training set.
  • the candidate objects to be eliminated in the storage module can be included in the current training set, thereby improving the diversity of the candidate objects in the current training set.
  • step S704 is executed, the historical access information of the target object E is used as the input of the probability prediction model of the current cycle, the probability that the target object E is accessed is predicted by the probability prediction model of the current cycle, and the In step S705, it is determined whether the predicted probability of the target object E being accessed is less than or equal to the second probability threshold.
  • step S706 is executed to eliminate the target object E from the storage module, that is, delete or cover the target object E, and update the historical access information of the target object E at the same time .
  • step S707 is executed to keep the target object E in the storage module, that is, the target object E is not eliminated, and the historical access information of the target object E is updated at the same time.
  • the cache admission may also consider other conditions such as business requirements of the business system, security rules, and load of the cache device; cache elimination
  • the predicted value of the future access probability of the object to be eliminated in the storage module the predicted value of the future access probability of other objects in the storage module, the write rate limit of the cache medium (ie the storage module), etc. can also be considered.
  • Other conditions Those skilled in the art can determine the decision conditions for cache admission and cache elimination according to the actual situation, which is not limited in this application.
  • the caching device of the embodiment of the present application by introducing a probability prediction model driven by object behavior and capable of online automatic supervision and learning, can not only automatically perceive and adapt to various business scenarios of the application system and changes in data access distribution, but also complete probability prediction online.
  • the incremental training of the model on this basis, completes the decision of cache admission and elimination, which can improve the cache hit rate and achieve long-term unattended stable operation.
  • the cache device of the embodiment of the present application uses the simplified knowledge storage structure to record the historical access information of the object, which can also save storage resources and computing resources.
  • the technical solutions of the embodiments of the present application can also be extended to other data-driven scenarios, such as search engine result ranking, personalized recommendation systems, and the like.
  • the technical solution of the present application is applied to the ranking of search engine results, the ranking of the results corresponding to the keywords can be automatically marked according to the user's click on the search results, and the ranking model can be trained online by self-supervision, thereby adapting to changes in data and user preferences.
  • the technical solution of the present application is applied to a personalized recommendation system, according to the user's acceptance of the recommendation results, the good or bad recommendation results can be automatically marked, and the personalized recommendation model can be trained online by self-supervision, thereby improving the accuracy of the recommendation.
  • FIG. 8 shows a flowchart of a caching method according to an embodiment of the present application.
  • the caching method can be applied to a control module in a caching device, and the caching method includes:
  • Step S810 marking the candidate object according to the historical access information of the candidate object; wherein, the candidate object is all or part of the target object, and the target object is the object indicated in the read request received by the cache device, or The target object is the object indicated in the write request received by the cache device, or the target object is the object to be eliminated in the storage module of the cache device;
  • Step S820 adding the marked candidate object to the current training set
  • Step S830 use the current training set to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle, or use the selected object when the number of candidate objects in the current training set is greater than or equal to the number threshold.
  • the current training set is used to train the probability prediction model of the current cycle to obtain the probability prediction model of the next cycle.
  • step S810 may include: determining a reference position in the historical access information of the candidate object; marking information in the historical access information before the reference position as the candidate object The reference visit information of ; mark the information after the reference position in the historical visit information as the reference visit probability of the candidate object.
  • the method further includes: if the target object is the object indicated in the write request received by the cache device, using historical access information of the target object as the probability of the current cycle For the input of the prediction model, the probability of the target object being accessed is predicted by the probability prediction model of the current cycle; when the predicted probability is greater than or equal to a first probability threshold, the target object is stored in the storage module.
  • the method further includes: if the target object is an object to be eliminated in the storage module, using the historical access information of the target object as the probability prediction model of the current cycle The input is to predict the probability of the target object being accessed through the probability prediction model of the current cycle; when the predicted probability is less than or equal to a second probability threshold, the target object is eliminated from the storage module.
  • the method further includes: if the target object is the object indicated in the write request received by the cache device and there is no historical access information of the target object, storing the target object stored in the storage module.
  • the method further includes: sampling one or more candidate objects from a plurality of the target objects.
  • the method further includes: storing the candidate object in the storage module.
  • An embodiment of the present application provides a chip, and the chip is used for deploying any of the foregoing cache devices.
  • Embodiments of the present application provide an electronic device, including: a processor; and a memory for storing instructions executable by the processor, wherein the processor is configured to implement the above method when executing the instructions.
  • Embodiments of the present application provide a non-volatile computer-readable storage medium on which computer program instructions are stored, and when the computer program instructions are executed by a processor, implement the above method.
  • Embodiments of the present application provide a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method.
  • a computer-readable storage medium may be a tangible device that can hold and store instructions for use by the instruction execution device.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • Computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read-only memory (Electrically Programmable Read-Only-Memory, EPROM or flash memory), static random access memory (Static Random-Access Memory, SRAM), portable compact disk read-only memory (Compact Disc Read-Only Memory, CD - ROM), Digital Video Disc (DVD), memory sticks, floppy disks, mechanically encoded devices, such as punch cards or raised structures in grooves on which instructions are stored, and any suitable combination of the foregoing .
  • RAM random access memory
  • ROM read only memory
  • EPROM erasable programmable read-only memory
  • EPROM Errically Programmable Read-Only-Memory
  • SRAM static random access memory
  • portable compact disk read-only memory Compact Disc Read-Only Memory
  • CD - ROM Compact Disc Read-Only Memory
  • DVD Digital Video Disc
  • memory sticks floppy disks
  • Computer readable program instructions or code described herein may be downloaded to various computing/processing devices from a computer readable storage medium, or to an external computer or external storage device over a network such as the Internet, a local area network, a wide area network and/or a wireless network.
  • the network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers.
  • a network adapter card or network interface in each computing/processing device receives computer-readable program instructions from a network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .
  • the computer program instructions used to perform the operations of the present application may be assembly instructions, Instruction Set Architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or in one or more source or object code written in any combination of programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages.
  • the computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement.
  • the remote computer may be connected to the user's computer through any kind of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or, may be connected to an external computer (eg, use an internet service provider to connect via the internet).
  • electronic circuits such as programmable logic circuits, Field-Programmable Gate Arrays (FPGA), or Programmable Logic Arrays (Programmable Logic Arrays), are personalized by utilizing state information of computer-readable program instructions.
  • Logic Array, PLA the electronic circuit can execute computer readable program instructions to implement various aspects of the present application.
  • These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer or other programmable data processing apparatus to produce a machine that causes the instructions when executed by the processor of the computer or other programmable data processing apparatus , resulting in means for implementing the functions/acts specified in one or more blocks of the flowchart and/or block diagrams.
  • These computer readable program instructions can also be stored in a computer readable storage medium, these instructions cause a computer, programmable data processing apparatus and/or other equipment to operate in a specific manner, so that the computer readable medium on which the instructions are stored includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks of the flowchart and/or block diagrams.
  • Computer readable program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other equipment to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other equipment to produce a computer-implemented process , thereby causing instructions executing on a computer, other programmable data processing apparatus, or other device to implement the functions/acts specified in one or more blocks of the flowcharts and/or block diagrams.
  • each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more functions for implementing the specified logical function(s) executable instructions.
  • the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented in hardware (eg, circuits or ASICs (Application) that perform the corresponding functions or actions. Specific Integrated Circuit, application-specific integrated circuit)), or can be implemented by a combination of hardware and software, such as firmware.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Biomedical Technology (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Biophysics (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Medical Informatics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

一种缓存装置、方法及系统,所述缓存装置(200)包括控制模块(210)及存储模块(220),所述控制模块(210)用于:根据候选对象的历史访问信息,对候选对象进行标注;将标注后的候选对象加入到当前训练集中;使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型。在缓存装置(200)运行过程中,自动对候选对象进行标注后加入到当前训练集中,并使用当前训练集对当前周期的概率预测模型进行训练,从而能够实现缓存装置(200)的在线自监督学习。

Description

缓存装置、方法及系统 技术领域
本申请涉及计算机技术领域,尤其涉及一种缓存装置、方法及系统。
背景技术
为了降低数据访问时延,通常会在数据库、内容分发网络、数据存储等业务系统中设置缓存,例如设置缓存组件、缓存子系统等,用于暂时保存业务系统中近期可能会被重复访问的数据。
目前,缓存通常为采用预设准入及淘汰规则的启发式缓存,或者为基于离线机器学习的缓存。然而,在业务系统的业务场景或数据访问模式发生变化时,启发式缓存及基于离线机器学习的缓存均存在业务适应性差、维护成本高等问题。
发明内容
有鉴于此,提出了一种缓存装置、方法及系统。
第一方面,本申请的实施例提供了一种缓存装置,所述缓存装置包括控制模块及存储模块,所述控制模块用于:根据候选对象的历史访问信息,对所述候选对象进行标注;其中,所述候选对象为全部或者部分的目标对象,所述目标对象为所述缓存装置接收的读请求中指示的对象,或者所述目标对象为所述缓存装置接收的写请求中指示的对象,或者所述目标对象为所述存储模块中待淘汰的对象;将标注后的候选对象加入到当前训练集中;使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在所述当前训练集中的候选对象的数量大于或等于数量阈值时使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型。
本申请的实施例,能够在缓存装置运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习(即在线运行过程中自动进行样本标注及训练),进而实现缓存装置的在线自监督学习。
通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
根据第一方面,在所述缓存装置的第一种可能的实现方式中,所述控制模块,用于:在所述候选对象的历史访问信息中确定参考位置;将所述历史访问信息中在所述参考位置之前的信息,标注为所述候选对象的参考访问信息;将所述历史访问信息中在所述参考位置之后的信息,标注为所述候选对象的参考访问概率。
本申请的实施例,通过在候选对象的历史访问信息中确定参考位置,并将候选对象的历史访问信息中在参考位置之前的信息,标注为候选对象的参考访问信息,同时将候选对象的历史访问信息中在参考位置之后的信息,标注为候选对象的参考访问概率,从而能够在缓存装置运行过程中,根据历史访问信息对候选对象进行自动标注,进而提高标注效率。
根据第一方面或第一方面的第一种可能的实现方式,在所述缓存装置的第二种可能的实 现方式中,所述控制模块,用于:如果所述目标对象为所述缓存装置接收的写请求中指示的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;在预测的概率大于或等于第一概率阈值时,将所述目标对象存储到所述存储模块。
本申请的实施例,在目标对象为缓存装置接收的写请求中指示的对象的情况下,控制模块能够通过当前周期的概率预测模型预测目标对象被访问的概率,并根据预测的概率进行缓存准入,从而提高缓存准入的准确性。
根据第一方面、第一方面的第一种可能的实现方式及第一方面的第二种可能的实现方式种的任意一种,在所述缓存装置的第三种可能的实现方式中,所述控制模块,用于:如果所述目标对象为所述存储模块中待淘汰的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;在预测的概率小于或等于第二概率阈值时,将所述目标对象从所述存储模块中淘汰。
本申请的实施例,在目标对象为存储模块中待淘汰的对象的情况下,控制模块能够通过当前周期的概率预测模型预测目标对象被访问的概率,并根据预测的概率进行缓存淘汰,从而提高缓存淘汰的准确性。
根据第一方面或第一方面的第一种可能的实现方式至第一方面的第三种可能的实现方式中的任意一种,在所述缓存装置的第四种可能的实现方式中,所述控制模块,用于:如果所述目标对象为所述缓存装置接收的写请求中指示的对象,且没有所述目标对象的历史访问信息,将所述目标对象存储到所述存储模块。
本申请的实施例,在目标对象为缓存装置接收的写请求中指示的对象且没有目标对象的历史访问信息的情况下,将目标对象存储到存储模块,能够避免没有历史访问信息的目标对象无法写入缓存装置的情况,从而提高缓存装置对业务场景变化或数据访问模式变化的适应性。
根据第一方面或第一方面的第一种可能的实现方式至第一方面的第四种可能的实现方式中的任意一种,在所述缓存装置的第五种可能的实现方式中,所述控制模块,用于:从多个所述目标对象中采样得到一个或多个所述候选对象。
本申请的实施例,通过从多个目标对象中采样得到一个或多个候选对象,能够减少候选对象的数量,从而提高处理效率。
根据第一方面或第一方面的第一种可能的实现方式至第一方面的第五种可能的实现方式中的任意一种,在所述缓存装置的第六种可能的实现方式中,所述控制模块,用于:将所述候选对象存储到所述存储模块。
本申请的实施例,将候选对象存储在存储模块中,从而能够继续更新候选对象的历史访问信息。
根据第一方面或者第一方面的多种可能的实现方式中的一种或几种,在所述缓存装置的第七种可能的实现方式中,与所述目标对象的历史访问信息对应的时间段包括多个子时段,所述目标对象的历史访问信息包括所述目标对象在各个子时段内的访问频率等级。
本申请的实施例,通过目标对象在各个子时段内的访问频率等级记录目标对象的历史访问信息,不仅可以节省存储空间及计算资源,而且能够按照时序记录目标对象的访问行为,从而实现缓存装置中大量对象的访问行为的在线感知。
第二方面,本申请的实施例提供了一种缓存方法,所述方法包括:根据候选对象的历史访问信息,对所述候选对象进行标注;其中,所述候选对象为全部或者部分的目标对象,所 述目标对象为缓存装置接收的读请求中指示的对象,或者所述目标对象为缓存装置接收的写请求中指示的对象,或者所述目标对象为缓存装置的存储模块中待淘汰的对象;将标注后的候选对象加入到当前训练集中;使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在所述当前训练集中的候选对象的数量大于或等于数量阈值时使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型;其中,所述方法应用于所述缓存装置的控制模块。
本申请的实施例,能够在缓存装置运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习(即在线运行过程中自动进行样本标注及训练),进而实现缓存装置的在线自监督学习。
通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
根据第二方面,在所述缓存方法的第一种可能的实现方式中,所述根据候选对象的历史访问信息,对所述候选对象进行标注,包括:在所述候选对象的历史访问信息中确定参考位置;将所述历史访问信息中在所述参考位置之前的信息,标注为所述候选对象的参考访问信息;将所述历史访问信息中在所述参考位置之后的信息,标注为所述候选对象的参考访问概率。
本申请的实施例,通过在候选对象的历史访问信息中确定参考位置,并将候选对象的历史访问信息中在参考位置之前的信息,标注为候选对象的参考访问信息,同时将候选对象的历史访问信息中在参考位置之后的信息,标注为候选对象的参考访问概率,从而能够在缓存装置运行过程中,根据历史访问信息对候选对象进行自动标注,进而提高标注效率。
根据第二方面或第二方面的第一种可能的实现方式,在所述缓存方法的第二种可能的实现方式中,所述方法还包括:如果所述目标对象为所述缓存装置接收的写请求中指示的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;在预测的概率大于或等于第一概率阈值时,将所述目标对象存储到所述存储模块。
本申请的实施例,在目标对象为缓存装置接收的写请求中指示的对象的情况下,控制模块能够通过当前周期的概率预测模型预测目标对象被访问的概率,并根据预测的概率进行缓存准入,从而提高缓存准入的准确性。
根据第二方面、第二方面的第一种可能的实现方式及第二方面的第二种可能的实现方式中的任意一种,在所述缓存方法的第三种可能的实现方式中,所述方法还包括:如果所述目标对象为所述存储模块中待淘汰的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;在预测的概率小于或等于第二概率阈值时,将所述目标对象从所述存储模块中淘汰。
本申请的实施例,在目标对象为存储模块中待淘汰的对象的情况下,控制模块能够通过当前周期的概率预测模型预测目标对象被访问的概率,并根据预测的概率进行缓存淘汰,从而提高缓存淘汰的准确性。
根据第二方面或第二方面的第一种可能的实现方式至第二方面的第三种可能的实现方式 中的任意一种,在所述缓存方法的第四种可能的实现方式中,所述方法,还包括:如果所述目标对象为所述缓存装置接收的写请求中指示的对象,且没有所述目标对象的历史访问信息,将所述目标对象存储到所述存储模块。
本申请的实施例,在目标对象为缓存装置接收的写请求中指示的对象且没有目标对象的历史访问信息的情况下,将目标对象存储到存储模块,能够避免没有历史访问信息的目标对象无法写入缓存装置的情况,从而提高缓存装置对业务场景变化或数据访问模式变化的适应性。
根据第二方面或第二方面的第一种可能的实现方式至第二方面的第四种可能的实现方式中的任意一种,在所述缓存方法的第五种可能的实现方式中,所述方法还包括:从多个所述目标对象中采样得到一个或多个所述候选对象。
本申请的实施例,通过从多个目标对象中采样得到一个或多个候选对象,能够减少候选对象的数量,从而提高处理效率。
根据第二方面或第二方面的第一种可能的实现方式至第二方面的第五种可能的实现方式中的任意一种,在所述缓存方法的第六种可能的实现方式中,所述方法还包括:将所述候选对象存储到所述存储模块。
本申请的实施例,将候选对象存储在存储模块中,从而能够继续更新候选对象的历史访问信息。
根据第二方面或者第二方面的多种可能的实现方式中的一种或几种,在所述缓存方法的第七种可能的实现方式中,与所述目标对象的历史访问信息对应的时间段包括多个子时段,所述目标对象的历史访问信息包括所述目标对象在各个子时段内的访问频率等级。
本申请的实施例,通过目标对象在各个子时段内的访问频率等级记录目标对象的历史访问信息,不仅可以节省存储空间及计算资源,而且能够按照时序记录目标对象的访问行为,从而实现缓存装置中大量对象的访问行为的在线感知。
第三方面,本申请的实施例提供了一种芯片,所述芯片用于部署上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的缓存装置。
本申请的实施例,能够在缓存装置运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习(即在线运行过程中自动进行候选对象标注及训练),进而实现缓存装置的在线自监督学习。
通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
第四方面,本申请的实施例提供了一种缓存系统,包括:缓存装置,用于缓存对象,所述缓存装置为上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的缓存装置;数据处理设备,用于向所述缓存装置发送所述对象的读请求或写请求;数据存储设备,用于存储所述对象。
本申请的实施例,缓存系统包括缓存装置、数据处理设备及数据存储设备,数据处理设备可以向缓存装置发送对象的读请求或写请求,缓存装置在接收到对象的读请求或写请求时,执行相对应的处理,例如,对象读操作、缓存准入处理等。
同时,缓存装置能够运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习,进而实现缓存装置的在线自监督学习。通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
第五方面,本申请的实施例提供了一种缓存系统,包括:数据处理设备,所述数据处理设备包括处理器及用于缓存对象的缓存装置,其中,所述处理器用于向所述缓存装置发送所述对象的读请求或写请求,所述缓存装置为上述第一方面或者第一方面的多种可能的实现方式中的一种或几种的的缓存装置;数据存储设备,用于存储所述对象。
本申请的实施例,缓存系统包括数据处理设备及数据存储设备,数据处理设备包括处理器及缓存装置,处理器可以向缓存装置发送对象的读请求或写请求,缓存装置在接收到对象的读请求或写请求时,执行相对应的处理,例如,对象读操作、缓存准入处理等。
同时,缓存装置在运行过程中,能够自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习,进而实现缓存装置的在线自监督学习。通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
第六方面,本申请的实施例提供了一种电子设备,包括:处理器;用于存储处理器可执行指令的存储器,其中,所述处理器被配置为执行所述指令时实现上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的缓存方法。
本申请的实施例,能够在缓存装置运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习,进而实现缓存装置的在线自监督学习。
通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
第七方面,本申请的实施例提供了一种非易失性计算机可读存储介质,其上存储有计算机程序指令,其特征在于,所述计算机程序指令被处理器执行时实现上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的缓存方法。
本申请的实施例,能够在缓存装置运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从 而能够实现概率预测模型的在线自监督学习,进而实现缓存装置的在线自监督学习。
通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
第八方面,本申请的实施例提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行上述第二方面或者第二方面的多种可能的实现方式中的一种或几种的缓存法。
本申请的实施例,能够在缓存装置运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习,进而实现缓存装置的在线自监督学习。
通过这种方式,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
本申请的这些和其他方面在以下(多个)实施例的描述中会更加简明易懂。
附图说明
包含在说明书中并且构成说明书的一部分的附图与说明书一起示出了本申请的示例性实施例、特征和方面,并且用于解释本申请的原理。
图1a示出根据本申请一实施例的缓存装置的应用场景的示意图。
图1b示出根据本申请一实施例的缓存装置的应用场景的示意图。
图2示出根据本申请一实施例的缓存装置的框图。
图3示出根据本申请一实施例的精简知识存储结构的示意图。
图4示出根据本申请一实施例的缓存装置的控制模块的处理过程的示意图。
图5a示出根据本申请一实施例的候选对象的标注示意图。
图5b示出根据本申请一实施例的候选对象的标注示意图。
图6a示出根据本申请一实施例的缓存装置的缓存准入的处理过程的示意图。
图6b示出根据本申请一实施例的缓存装置的缓存准入的处理过程的示意图。
图7示出根据本申请一实施例的缓存装置的缓存淘汰的处理过程的示意图。
图8示出根据本申请一实施例的缓存方法的流程图。
具体实施方式
以下将参考附图详细说明本申请的各种示例性实施例、特征和方面。附图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施例的各种方面,但是除非特别指出,不必按比例绘制附图。
在这里专用的词“示例性”意为“用作例子、实施例或说明性”。这里作为“示例性”所说明的任何实施例不必解释为优于或好于其它实施例。
另外,为了更好的说明本申请,在下文的具体实施方式中给出了众多的具体细节。本领域技术人员应当理解,没有某些具体细节,本申请同样可以实施。在一些实例中,对于本领域技术人员熟知的方法、手段、元件和电路未作详细描述,以便于凸显本申请的主旨。
在业务系统(也可认为是应用系统)中,缓存通常用于暂时保存近期可能会被重复访问的数据,以减少由于重复访问相同数据带来的磁盘读写开销、网络请求开销等,从而降低数据访问时延。缓存通常以对象作为最小单位来管理数据。一个对象可包括缓存中的一段数据及其对应的描述信息(也可称为元信息)。缓存介质是缓存中用于存储数据的物理介质,例如内存、磁盘等。缓存介质通常访问速度快,但存储容量小。
业务系统通过请求缓存获取数据,如果数据在缓存中,则缓存命中;如果数据不在缓存中,则缓存未命中。缓存命中的数据占所有被请求的数据的比例,称为缓存命中率。缓存命中率越高,业务系统的数据访问速度越快,其性能就越好。
通常情况下,缓存命中率主要是由缓存准入及缓存淘汰机制决定的。缓存准入是指缓存在接收到写请求时,判断是否将写请求指示的对象写入缓存介质的过程。例如,在对象进入缓存介质之前,判断对象是否有缓存的价值,如果对象有缓存的价值,则将该对象写入缓存介质;如果对象没有缓存的价值,则不将该对象写入缓存介质。
由于缓存介质的存储容量小,缓存通常需要不断淘汰旧的对象,为新的对象腾出存储空间,缓存淘汰就是指缓存删除或覆盖缓存介质中的对象的过程。缓存淘汰算法通常倾向于保留新对象,淘汰旧对象,例如淘汰最近最少使用(least recently used,LRU)的对象、对象先进先出(first in first out,FIFO)等。
在一些技术方案中,缓存采用了基于规则的准入和淘汰方法,这类缓存可称为启发式缓存。当前主流的应用级缓存系统(或缓存子系统)大多为启发式缓存。例如阿帕奇流量服务器(apache traffic server,ATS)、分布式内存对象缓存系统(memcached)、鱿鱼缓存代理服务器(squid cache)等均为启发式缓存。
启发式缓存的准入方法通常包括第二次准入(second hit)、基于统计信息的准入等。第二次准入是指近期第一次被访问的对象不写入缓存,近期第二次或更多次被访问的对象才写入缓存。基于统计信息的准入是指分别统计每个对象的近期访问次数,将访问次数超过访问次数阈值的对象写入缓存,否则不写入缓存。启发式缓存的淘汰方法通常包括LRU、FIFO、最不经常使用(least frequency used,LFU)以及与LRU、FIFO、LFU类似的方法等。
在启发式缓存的实际应用中,还可以在基于规则的缓存准入及淘汰的基础上,引入统计模块,用于统计对象短期内被访问的频率,并基于统计模块的统计结果进行缓存准入及淘汰的决策。
由于启发式缓存遵循固定的准入及淘汰规则,在业务系统运行之前,需要预先制定缓存准入及淘汰规则。然而,预先制定的缓存准入及淘汰规则,通常难以适应业务系统实际的数据访问模式(例如数据访问分布),也难以适应业务系统各种不同的业务场景。例如,假设缓存准入规则指定小于1MB的数据不满足准入条件,即不准入缓存,但在业务系统运行时,由于存在数据分片等机制,数据可能均小于1MB或均大于1MB,在该情况下,固定的缓存准入规则无法达到预期效果。因此,启发式缓存的业务适应性较差。
此外,使用启发式缓存时,运维人员(一般是领域专家)不仅需要针对业务系统的不同业务场景,制定不同的缓存准入及淘汰规则,而且,在业务系统运行过程中,运维人员还需要在业务场景发生变化或数据访问模式发生变化的情况下,根据变化人工调整缓存准入及淘汰规则,不仅应对速度慢,而且维护成本高。
在另一些技术方案中,使用了基于离线机器学习的缓存。例如,在缓存中引入用于预测对象被访问概率的机器学习模型,并根据机器学习模型的预测结果,进行缓存准入及淘汰的决策。该方案中,机器学习模型的应用方式为离线训练-在线部署。也就是说,在缓存中引入 机器学习模型后,通常需要采集业务系统访问的数据,并对采集的数据进行离线标注,然后使用标注后的数据,离线训练机器学习模型,训练结束后,再将机器学习模型部署上线。
然而,在各个业务系统的业务场景(即业务模式)不同或数据访问模式不一致的情况下,该方案需要为各个业务系统分别离线训练不同的机器学习模型,从而带来高昂的业务-模型适配成本。例如,对于内容分发网络(content delivery network,CDN),其部署在不同地域的缓存系统通常面对的是不同的业务场景,需要为不同的业务场景,分别离线训练不同的机器学习模型,而不能使用一组训练数据及机器学习模型,适应不同的业务场景,否则会导致预测准确率降低,缓存决策效果差。
而且,在业务系统的业务场景或数据访问模式发生变化时,例如,业务系统的业务场景发生切换或者出现新的业务时,离线预训练的机器学习模型难以自动适应变化后的业务场景,预测准确率下降。通常的解决方式是在观察到业务场景或对象访问模式发生变化时,运维人员需要人工识别当前部署的机器学习模型是否适用该变化,如果不适用,则需要重新进行数据采集,离线训练机器学习模型,再部署上线。这种解决方式不仅应对速度慢,而且重新离线训练机器学习模型,还会增加机器学习模型的更新维护成本。
因此,采用预设准入及淘汰规则的启发式缓存以及基于离线机器学习的缓存,均存在业务适应性差、维护成本高等问题。
为了解决上述技术问题,本申请提供了一种缓存装置。本申请实施例的缓存装置包括控制模块及存储模块,控制模块用于:根据候选对象的历史访问信息,对候选对象进行标注,其中,候选对象为全部或者部分的目标对象,目标对象为缓存装置接收的读请求中指示的对象,或者目标对象为缓存装置接收的写请求中指示的对象,或者目标对象为存储模块中待淘汰的对象;将标注后的候选对象加入到当前训练集中;使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型。
通过这种方式,能够在缓存装置运行过程中,自动对候选对象进行标注,并将标注后的候选对象加入当前训练集中,然后使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在当前训练集中的候选对象的数量大于或等于数量阈值时使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而能够实现概率预测模型的在线自监督学习(即在线运行过程中自动进行样本标注及训练),进而实现缓存装置的在线自监督学习。
本申请实施例的缓存装置,通过引入对象行为驱动的、可在线自动督学习的概率预测模型,实现了缓存装置的在线自监督学习,不仅能够不断优化缓存装置的缓存准入及淘汰决策,提高缓存命中率,而且使得缓存装置能够自动感知并适应多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
图1a示出根据本申请一实施例的缓存装置的应用场景的示意图。如图1a所示,提供了一种缓存系统,包括数据处理设备100、用于缓存对象的缓存装置200及用于存储对象的数据存储设备300。缓存装置200位于数据处理设备100的外部。数据处理设备100可以向缓存装置200发送对象的读请求或写请求,缓存装置200在接收到对象的读请求或写请求时,执行相对应的处理,例如,对象读操作、缓存准入处理等
举例来说,数据处理设备100读取对象时,首先向缓存装置200发送读请求,如果缓存装置200中存在数据处理设备100请求的对象,则缓存命中,数据处理设备100直接从缓存 装置200中读取对象;若缓存装置200中不存在数据处理设备100请求的对象,则缓存未命中,数据处理设备100从数据存储设备300中读取对象。
其中,数据处理设备100用于对数据存储设备300中存储的对象进行处理。在一些实施例中,数据处理设备100可以为内容分发网络、数据存储等业务系统中的服务器、终端设备等设备。需要说明的是,数据处理设备100也可以为其他数据处理设备,本申请对此不作限制。
缓存装置200用于暂时保存近期可能会被数据处理设备100重复访问的对象,以降低数据处理装置100的数据访问时延,提高数据访问效率。
数据处理设备100也可以向缓存装置200发送对象的写请求,缓存装置200在接收到对象的写请求时,启动缓存准入的处理过程,以确定是否允许写请求指示的对象写入缓存装置。
图1b示出根据本申请一实施例的缓存装置的应用场景的示意图。如图1b所示,提供了一种缓存系统,包括数据处理设备100及用于存储对象的数据存储设备300。数据处理设备100包括处理器110及缓存装置200,即缓存装置200位于数据处理设备100的内部。处理器110可向缓存装置200发送对象的读请求或写请求。缓存装置200接收到对象的读请求或写请求时,执行相对应的处理,例如,对象读操作、缓存准入处理等。
在一种可能的实现方式中,在缓存装置200应用于业务系统中时,缓存装置可以实现为业务系统中的独立的缓存子系统(如图1a所示的应用场景),也可以实现为业务系统中服务器等设备的缓存组件(如图1b所示的应用场景)。需要说明的是,本领域技术人员可根据实际情况设置缓存装置的具体实现方式,本申请对此不作限制。
图2示出根据本申请一实施例的缓存装置的框图。如图2所示,缓存装置200包括控制模块210及存储模块220。控制模块210用于实现缓存准入、缓存淘汰、候选对象自动标注、概率预测模型在线训练等功能;存储模块220是缓存装置200的缓存介质(例如内存、磁盘、网络介质等),用于存储数据。
其中,控制模块210可通过处理器实现。处理器可以包括一个或多个处理单元,例如:处理器可以包括中央处理器(central process unit,CPU),应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。本申请对处理器的具体类型不作限制。
在一种可能的实现方式中,缓存装置200以对象为单位对缓存的数据进行管理。控制模块210可记录各个对象的历史访问信息。对象的历史访问信息可包括对象被访问的时刻、对象被访问的次数、对象写入缓存装置200的时刻等。控制模块210在记录对象的历史访问信息时,可以直接记录对象被访问的时刻、对象被访问的次数、对象写入缓存装置200的时刻等原始访问信息;也可以对对象的原始访问信息进行处理后再记录,本申请对此不作限制。
对象的历史访问信息可通过哈希表、有序数组等方式进行记录。存储时,对象的历史访问信息可以附加在对象的数据结构上,与对象一起存储,也可以独立存储。本申请对缓存装置中对象的历史访问信息的记录方式及存储方式均不作限制。
在对象写入存储模块220(即缓存介质)后,控制模块210开始记录其历史访问信息。在对象被读取、对象从存储模块220中淘汰或对象再次写入存储模块220等情况下,控制模块210会实时更新对象的历史访问信息。
需要说明的是,本领域技术人员可根据实际情况设置对象的历史访问信息的更新条件,本申请对此不作限制。例如,可设置对象从存储模块中淘汰后,停止更新其历史访问信息,在该对象再次写入存储模块后,继续更新其历史访问信息,中间停止更新的时间段对应的历史访问信息以预设值(例如0)填充。
在一种可能的实现方式中,可预设对象的历史访问信息的时间长度。例如,假设需要记录对象最近15天内的历史访问信息,可将对象的历史访问信息的时间长度设置为15天。可选的,可根据缓存装置中各个对象的缓存周期,确定历史访问信息的时间长度。对象的缓存周期是指从对象写入缓存装置的存储模块开始至对象从缓存装置的存储模块中淘汰的时间段。为了更好地记录对象的历史访问信息,可设置历史访问信息的时间长度大于缓存装置中各个对象的缓存周期的平均值。此外,设置历史访问信息的时间长度时,还可以考虑业务系统的业务场景、数据访问模式等。本申请对历史访问信息的时间长度的设置依据及具体取值均不作限制。
控制模块记录对象的历史访问信息时,随着当前时刻的向前推移,对象的历史访问信息也不断更新。例如,可将历史访问信息的时间长度看作一个可以向前滑动的时间窗口,随着当前时刻的前移,时间窗口也随之向前滑动,同时,控制模块会根据对象的访问情况,不断更新对象的历史访问信息,使得对象的历史访问信息能够随着当前时刻的前移而不断更新。滑出时间窗口的历史访问信息,可以被覆盖或删除,也可以存储在预设区域,以便后续继续使用,或者进行统计分析等其他处理。
在一种可能的实现方式中,可将与对象的历史访问信息对应的时间段(该时间段的长度为历史访问信息的时间长度)划分为多个子时段,对象的历史访问信息可包括对象在各个子时段内的访问频率等级。对象的历史访问信息可通过精简知识存储结构进行记录。精简知识存储结构可通过预设长度的存储空间(例如4字节)记录对象在各个子时段内的访问频率等级。对象写入存储模块后,控制模块可为该对象建立对应的精简知识存储结构,以记录其历史访问信息。
使用精简知识存储结构记录对象的历史访问信息时,可首先将与对象的历史访问信息对应的时间段划分为多个子时段,同时将精简知识存储结构的存储空间划分为多个子空间,其中,子空间的数量可以与子时段的数量相同,即子空间与子时段一一对应,每个子空间存储对象在对应子时段内的历史访问信息,或者子空间的数量也可以大于子时段的数量,每个子时段对应一个子空间,剩余的子空间可用于存储对象的其他状态信息,例如,对象是否为重要对象、对象是否为上一个缓存周期保留的对象(即上一个缓存周期需要淘汰但未淘汰的对象)等;然后可根据预设的访问频率等级划分规则及对象在各个子时段内的访问次数,确定对象在各个子时段内的访问频率等级,并将访问频率等级记录在对应的子空间中。
也就是说,对象的精简知识存储结构可包括多个子空间,相应的,与对象的历史访问信息对应的时间段也可包括多个子时段,每个子时段对应精简知识存储结构中的一个子空间。对象的历史访问信息可包括对象在各个子时段内的访问频率等级,可将对象在各个子时段内的访问频率等级存储在精简知识存储结构的对应子空间中。
图3示出根据本申请一实施例的精简知识存储结构的示意图。如图3所示,对象的精简知识存储结构的存储空间为32比特位(bit),可将该精简知识存储结构划分为16个子空间,每个子空间的大小为2bit,按照从第0位到第31位的顺序,对16个子空间依次进行编号:第1个子空间为第0-1位,第2个子空间为第2-3位,……,第16个子空间为第30-31位,同时,将与该对象的历史访问信息对应的时间段划分为15个子时段,按照与当前时刻的距离 由近及远的顺序,对15个子时段进行编号:第1个子时段为当前时刻之前且与当前时刻相邻的子时段,第2个子时段为第1个子时段之前且与第1个子时段相邻的子时段,……,第15个子时段为第14个子时段之前且与第14个子时段相邻的子时段。其中,子时段与子空间按照编号进行对应:第1个子时段与第1个子空间相对应,第2个子时段与第2个子空间相对应,……,第15个子时段与第15个子空间相对应。
然后根据预设的访问频率等级划分规则及对象在各个子时段内的访问次数,确定对象在各个子时段内的访问频率等级。由于每个子空间的大小为2bit,可以使用00、01、10、11表示4个状态或等级,可预设访问频率等级划分规则为:若对象在子时段内的访问次数小于第一访问次数阈值(例如50),则将对象在该子时段内的访问频率等级设置为0级,在子空间内使用00表示;若对象在子时段内的访问次数大于或等于第一访问次数阈值(例如50)且小于第二访问次数阈值(例如200),则将对象在该子时段内的访问频率等级设置为1级,在子空间内使用01表示;若对象在子时段内的访问次数大于或等于第二访问次数阈值(例如200)且小于第三访问次数阈值(例如500),则将对象在该子时段内的访问频率等级设置为2级,在子空间内使用10表示;若对象在子时段内的访问次数大于或等于第三访问次数阈值(例如500),则将对象在该子时段内的访问频率等级设置为3级,在子空间内使用11表示。
通过上述方式确定出对象在各个子时段内的访问频率等级后,可将访问频率等级存储在精简知识存储结构的对应子空间中。
精简知识存储结构的第16个子空间可用于存储对象的其他状态信息,例如,可使用第30位表示该对象是否为重要对象,若对象为重要对象,则将第30位设为1,若对象不是重要对象,则将第30位设为0;可使用第31位表示该对象是否为上一个缓存周期保留的对象,若对象为上一个缓存周期保留的对象,则将第31位设为1,若对象不是上一个缓存周期保留的对象,则将第31位设为0。
如图3所示,对象的精简知识存储结构中,第1-3个子空间内存储的值为11,表示对象在第1-3个子时段内的访问频率等级为3级,可认为对象在第1-3个子时段内存在大量访问,对象的热度等级为最热;第4-9个子空间内存储的值为10,表示对象在第4-9个子时段内的访问频率等级为2级,可认为对象在第4-9个子时段内存在较多访问,对象的热度等级为热;第10-13个子空间内存储的值为01,表示对象在第10-13个子时段内的访问频率等级为1级,可认为对象在第10-13个子时段内存在少量访问,对象的热度等级为温;第14-15个子空间内存储的值为00,表示对象在第14-15个子时段内的访问频率等级为0级,可认为对象在第14-15个子时段内基本无访问,对象的热度等级为冷。第16个子空间内存储的值为00,表示对象不是重要对象,也不是上一个缓存周期保留的对象。
由图3所示的精简知识存储结构可以看出,与该精简知识存储结构对应的对象的访问频率等级逐渐变高,可知,该对象的访问次数呈上升趋势,其热度也逐渐上升。
需要说明的是,以上仅以图3作为示例,对精简知识存储结构进行了示例性说明,本领域技术人员可根据实际情况对精简知识存储结构的存储空间的大小、子区域的划分、与对象的历史访问信息对应的时间段的子时段的划分、子区域与子时段的对应关系、访问频率等级划分规则等进行设置,本申请对此均不作限制。
在预设长度的精简知识存储结构中,以访问频率等级的方式记录对象的历史访问信息,不仅可以节省存储空间及计算资源,而且能够按照时序记录对象的访问行为,从而实现大量对象的访问行为的在线感知,以提高对象的未来访问概率的预测准确性。此外,通过在线感知大量对象的访问行为,控制模块不仅能够感知业务系统的业务场景,而且能够感知业务系 统的业务场景或数据访问模式的变化,以便缓存装置进行自适应调整。
在一种可能的实现方式中,可在缓存装置中部署概率预测模型,例如在缓存装置的控制模块上部署概率预测模型。该概率预测模型可用于预测缓存装置接收的写请求中指示的对象被访问的概率,或者预测缓存装置的存储模块中待淘汰的对象被访问的概率。概率预测模型可以是逻辑回归模型、神经网络、基于树的模型、支持向量机(support vector machine,SVM)等机器学习模型。本申请对概率预测模型的具体类型不作限制。
由于需要对概率预测模型进行在线自监督学习,可根据概率预测模型的更新周期,将缓存装置的运行过程划分为多个周期。下面以当前周期作为示例,对控制模块的处理过程做示例性地说明。
图4示出根据本申请一实施例的缓存装置的控制模块的处理过程的示意图。如图4所示,控制模块的处理过程包括:
步骤S401,根据候选对象的历史访问信息,对所述候选对象进行标注。
其中,候选对象为全部或者部分的目标对象,目标对象为缓存装置接收的读请求中指示的对象,或者目标对象为缓存装置接收的写请求中指示的对象,或者目标对象为存储模块中待淘汰的对象中的部分对象。需要说明的是,本领域技术人员可根据实际情况设置候选对象及目标对象包括的具体对象(即候选对象及目标对象的范围),本申请对此不作限制。
例如,在业务系统的业务场景或数据访问模式中,如果数据读取占比很大(例如数据读取占比为95%),则可设置目标对象为缓存装置接收的读请求中指示的对象,候选对象为全部或者部分的目标对象;在业务系统的业务场景或数据访问模式中,如果数据读取及数据写入相对均衡,则可设置目标对象包括缓存装置接收的读请求中指示的对象以及缓存装置接收的写请求中指示的对象,候选对象为全部或者部分的目标对象。在一些实施例中,目标对象还可以为存储模块中待淘汰的对象,候选对象可以为部分目标对象,即候选对象为存储模块中待淘汰的对象中的部分对象。
在一种可能的实现方式中,控制模块可从多个目标对象中采样得到一个或多个候选对象。例如,控制模块可根据采样规则,从多个目标对象中采样得到一个或多个候选对象,其中,采样规则可以为根据采样比例进行随机采样;采样规则也可以为根据采样比例及目标对象的标识符(identity,ID)进行采样,例如,可按照采样比例,对目标对象的ID进行取模运算,根据取模运算的结果进行采样。需要说明的是,本领域技术人员可根据实际情况对采样规则的具体内容进行设置,本申请对此不作限制。
通过从多个目标对象中采样得到一个或多个候选对象,能够减少候选对象的数量,从而提高处理效率。
在一种可能的实现方式中,控制模块对候选对象进行标注时,可将候选对象的历史访问信息中的一部分信息标注为候选对象的参考访问信息,作为训练概率预测模型时的输入,即作为决策依据;将候选对象的历史访问信息中的另一部分信息用于确定候选对象的参考访问概率,该参考访问概率可作为训练概率预测模型时的参考输出。
由于候选对象的历史访问信息具有时序性,控制模块对候选对象进行标注时,可首先在候选对象的历史访问信息中确定参考位置。其中,参考位置可用于指示候选对象的历史访问信息中,作为候选对象的参考访问信息的信息与用于确定候选对象的参考访问概率的信息的分界位置。
例如,假设候选对象的历史访问信息通过32bit的精简知识存储结构进行记录,该精简知识存储结构包括16个子空间,可将第4个子空间与第5个子空间的分界位置,设置为参考 位置。也可根据与精简知识存储结构对应的多个子时段,设置参考位置。本申请对参考位置的设置方式及具体位置均不作限制。
控制模块在候选对象的历史访问信息中确定出参考位置后,可将候选对象的历史访问信息中在参考位置之前的信息,标注为候选对象的参考访问信息,作为训练概率预测模型时的输入。例如,假设候选对象的历史访问信息通过32bit的精简知识存储结构进行记录,该精简知识存储结构包括16个子空间(第16个子空间用于记录状态信息),参考位置为第4个子空间与第5个子空间的分界位置,可将候选对象的历史访问信息中在参考位置之前的信息,即精简知识存储结构中第5-15个子空间存储的信息,标注为候选对象的参考访问信息。
可将候选对象的历史访问信息中在参考位置之后的信息,标注为候选对象的参考访问概率。例如,假设概率预测模型为回归模型,候选对象的历史访问信息通过32bit的精简知识存储结构进行记录,该精简知识存储结构包括16个子空间(第16个子空间用于记录状态信息),参考位置为第4个子空间与第5个子空间的分界位置,可将该精简知识存储结构中,第1-4个子空间中存储的二进制数值(即第0-7位),转换为十进制数值,并进行归一化处理,然后将归一化处理后的值,标注为候选对象的参考访问概率。
在概率预测模型为分类模型的情况下,可通过与上述回归模型类似的方式,确定候选对象的参考访问概率,此处不再赘述。在确定候选对象的参考访问概率后,还可对候选对象进行正负样本标注。例如,可将参考访问概率大于分类阈值(例如0.5)的候选对象标注为正样本,将参考访问概率小于或等于分类阈值(例如0.5)的候选对象标注为负样本。
需要说明的是,本领域技术人员可根据实际情况对候选对象的参考访问概率的标注方式进行设置,本申请对此不作限制。
图5a示出根据本申请一实施例的候选对象的标注示意图。如图5a所示,候选对象A的历史访问信息通过32bit的精简知识存储结构400进行记录。精简知识存储结构400包括16个子空间(第16个子空间用于记录状态信息),候选对象A的历史访问信息中的参考位置为第4个子空间与第5个子空间的分界位置,通过图5a中的虚线420示出。
对候选对象A进行标注时,可将精简知识存储结构400中在虚线420左侧的信息,即第5-15个子空间存储的信息,标注为候选对象A的参考访问信息;可将精简知识存储结构400中在虚线420右侧的信息,即第1-4个子空间存储的信息,标注为候选对象A的参考访问概率。
如图5a所示,在精简知识存储结构400的下方,示出了与精简知识存储结构400中存储的信息对应的候选对象A的访问频率曲线410。从访问频率曲线410可以看出,候选对象A的访问频率逐渐降低,即候选对象A的热度逐渐降低。
图5b示出根据本申请一实施例的候选对象的标注示意图。如图5b所示,候选对象B的历史访问信息通过32bit的精简知识存储结构430进行记录。精简知识存储结构430包括16个子空间(第16个子空间用于记录状态信息),候选对象B的历史访问信息中的参考位置为第3个子空间与第4个子空间的分界位置,通过图5b中的虚线440示出。
对候选对象B进行标注时,可将精简知识存储结构430中在虚线440左侧的信息,即第4-15个子空间存储的信息,标注为候选对象B的参考访问信息;可将精简知识存储结构430中在虚线440右侧的信息,即第1-3个子空间存储的信息,标注为候选对象B的参考访问概率。
如图5b所示,在精简知识存储结构430的下方,示出了与精简知识存储结构430中存储的信息对应的候选对象B的访问频率曲线450。从访问频率曲线450可以看出,候选对象B 的访问频率逐渐升高,即候选对象B的热度逐渐升高。
通过在候选对象的历史访问信息中确定参考位置,并将候选对象的历史访问信息中在参考位置之前的信息,标注为候选对象的参考访问信息,同时将候选对象的历史访问信息中在参考位置之后的信息,标注为候选对象的参考访问概率,从而能够在缓存装置运行过程中,根据历史访问信息对候选对象进行自动标注,进而提高标注效率。
步骤S402,将标注后的候选对象加入到当前训练集中。
其中,当前训练集用于对当前周期的概率预测模型进行训练,以得到下一周期的概率预测模型。
在一种可能的实现方式中,在将标注后的候选对象加入当前训练集的同时,如果候选对象为缓存装置接收的写请求中指示的对象,控制模块可直接将候选对象存储到存储模块,即对候选对象进行直接准入。如果候选对象为缓存装置的存储模块中待淘汰的对象,控制模块也可直接将候选对象存储到存储模块,即不淘汰候选对象。通过这种方式,能够将候选对象存储在存储模块中,以便继续更新候选对象的历史访问信息。
步骤S403,使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在所述当前训练集中的候选对象的数量大于或等于数量阈值时使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型。
在一种可能的实现方式中,控制模块将标注后的候选对象加入到当前训练集中后,可使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,从而实现概率预测模型的在线增量训练。该训练为异步增量训练,不影响当前周期的概率预测模型的在线运行。
在一种可能的实现方式中,控制模块将标注后的候选对象加入到当前训练集中后,也可判断当前训练集中的候选对象的数量是否大于或等于数量阈值(例如1000、2000等)。如果当前训练集中的候选对象的数量小于数量阈值,控制模块可重复执行步骤S401及步骤S402,不断对候选对象进行自动标注,加入到当前训练集中。如果当前训练集中的候选对象的数量大于或等于数量阈值,控制模块可使用当前训练集对当前周期的概率预测模型进行训练来得到下一周期的概率预测模型。该训练也为异步增量训练,不影响当前周期的概率预测模型的在线运行。
在一种可能的实现方式中,对当前周期的概率预测模型进行训练时,可使用随机梯度下降算法等支持参数增量训练更新的训练算法。支持参数增量训练更新的训练算法能够根据小部分候选对象,计算概率预测模型的损失函数对其参数的梯度,并以一定的速率往负梯度方向更新概率预测模型的参数,如误差反传算法,从而减小概率预测模型在候选对象上的误差。
通过各个周期的训练集对概率预测模型的增量训练,使得概率预测模型可以不断更新。当候选对象的分布发生变化时,概率预测模型在候选对象上的损失函数值增大,梯度增加,会以更剧烈的方式更新概率预测模型的参数。当候选对象分布稳定时,通过多次迭代训练,概率预测模型的参数逐渐收敛到稳定的值。
本申请实施例的缓存装置,能够通过异步增量训练的方法,即每次训练仅采用一个小的训练集,并将训练后的参数更新至在线运行的概率预测模型,从而能够把训练过程的计算和存储开销平摊到缓存装置的运行过程中,实现轻量的在线自监督学习。同时,通过在线增量训练,缓存装置能够自动适应业务场景的变化及数据访问模式的变化。
本申请实施例的缓存装置,通过引入对象行为驱动的、可在线自动督学习的概率预测模型,实现了缓存装置的在线自监督学习,不仅能够不断优化缓存装置的缓存准入及淘汰决策, 提高缓存命中率,而且使得缓存装置能够自动感知并适应业务系统的多种业务场景以及业务场景或数据访问模式的变化,在提高缓存装置的业务适应性的同时,还能降低缓存装置的维护成本。
在一种可能的实现方式中,在缓存装置运行过程中,控制模块除了实现图4所示的处理过程外,还同时进行目标对象的缓存准入及缓存淘汰。
举例来说,如果目标对象为缓存装置接收的写请求中指示的对象,控制模块可将目标对象的历史访问信息作为当前周期的概率预测模型的输入,通过当前周期的概率预测模型预测目标对象被访问的概率,并判断预测的概率是否大于或等于第一概率阈值。如果预测的概率大于或等于第一概率阈值,则进行缓存写入,将目标对象存储到存储模块。如果预测的概率小于第一概率阈值,则终止缓存写入,不允许目标对象存储到存储模块。通过这种方式,控制模块能够根据预测的目标对象被访问的概率进行缓存准入,从而提高缓存准入的准确性。
如果目标对象为缓存装置接收的写请求中指示的对象,且没有目标对象的历史访问信息,控制模块可将目标对象存储到存储模块,即进行缓存写入。通过这种方式,能够避免没有历史访问信息的目标对象无法写入缓存装置的情况,从而提高缓存装置对业务场景变化或数据访问模式变化的适应性。
如果目标对象为存储模块中待淘汰的对象,控制模块可将目标对象的历史访问信息作为当前周期的概率预测模型的输入,通过当前周期的概率预测模型预测目标对象被访问的概率,并判断预测的概率是否小于或等于第二概率阈值。如果预测的概率小于或等于第二概率阈值,则进行缓存淘汰,将该目标对象从存储模块中淘汰。如果预测的概率大于第二概率阈值,则不淘汰该目标对象,将该目标保留在存储模块中。通过这种方式,控制模块能够根据预测的目标对象被访问的概率进行缓存淘汰,从而提高缓存淘汰的准确性。
需要说明的是,上述第一概率阈值及第二概率阈值可根据业务场景、数据访问模式、既有经验等进行设置。第一概率阈值及第二概率阈值可以为固定值,也可以为浮动值。第二概率阈值可以与第一概率阈值相同,也可以小于第一概率阈值。本领域技术人员可根据实际情况对第一概率阈值及第二概率阈值的具体取值进行设置,本申请对此不作限制。
下面对本申请实施例的缓存装置的数据访问过程进行示例性说明,并结合图6a、图6b及图7,对本申请实施例的缓存装置的缓存准入及淘汰过程进行示例性地说明。
缓存装置在接收到数据处理设备针对目标对象C的读请求的情况下(即目标对象C为缓存装置接收的读请求中指示的对象),可查找存储模块中是否存在目标对象C。
如果存储模块中存在目标对象C,则缓存命中,数据处理设备从缓存装置的存储模块中读取目标对象C。同时,缓存装置的控制模块更新目标对象C的历史访问信息。且如果目标对象C为候选对象,控制模块还可根据目标对象C的历史访问信息,对目标对象C进行标注,并将标注后的目标对象C到当前训练集中。通过这种方式,能够使得当前训练集中包括读请求相关的候选对象。
在存储模块中不存在目标对象C的情况下,则缓存未命中,数据处理设备从缓存装置中读取目标对象C失败。数据处理设备则从数据存储设备中读取目标对象C。
图6a示出根据本申请一实施例的缓存装置的缓存准入的处理过程的示意图。图6a所示的缓存装置的缓存准入的处理过程中,候选对象为全部的目标对象,目标对象为缓存装置接收的写请求中指示的对象。
如图6a所示,缓存装置在步骤S601中接收到了针对目标对象D1的写请求。在接收到针对目标对象D1的写请求的情况下,控制模块启动缓存准入过程。
控制模块可在步骤S602中,判断目标对象D1(即缓存装置接收的写请求中指示的对象)是否有历史访问信息。如果目标对象D1没有历史访问信息,则执行步骤S607,将目标对象D1存储到存储模块,同时,由于目标对象D1没有历史访问信息,控制模块可为目标对象D1建立对应的精简知识存储结构,用于记录目标对象D1的历史访问信息。通过这种方式,能够避免没有历史访问信息的目标对象无法写入缓存装置的情况,提高缓存装置对业务场景变化或数据访问模式变化的适应性。
若目标对象D1有历史访问信息,则执行步骤S603,获取目标对象D1的历史访问信息,并在步骤S604中,将目标对象D1作为候选对象,然后同时执行步骤S608及步骤S605:
在步骤S608中,将候选对象(即目标对象D1)存储到存储模块,实现目标对象D1的缓存准入,同时更新目标对象D1的历史访问信息;
在步骤S605中,根据候选对象的历史访问信息,对候选对象进行标注,并在步骤S606中,将标注后的候选对象加入当前训练集中。通过这种方式,能够使得当前训练集中包括与写请求相关的候选对象。
图6b示出根据本申请一实施例的缓存装置的缓存准入的处理过程的示意图。图6b所示的缓存装置的缓存准入的处理过程中,候选对象为部分的目标对象,目标对象为缓存装置接收的写请求中指示的对象。
如图6b所示,缓存装置在步骤S611中接收到了针对目标对象D2的写请求。在接收到针对目标对象D2的写请求的情况下,控制模块启动缓存准入过程。
控制模块可在步骤S612中,判断目标对象D2是否有历史访问信息。如果目标对象D2没有历史访问信息,则执行步骤S617,将目标对象D2存储到存储模块,同时,由于目标对象D2没有历史访问信息,控制模块可为目标对象D2建立对应的精简知识存储结构,用于记录目标对象D2的历史访问信息。
若目标对象D2有历史访问信息,则执行步骤S613,获取目标对象D2的历史访问信息,并在步骤S614中,判断目标对象D2是否为候选对象。如果目标对象D2为候选对象,则同时执行步骤S620及步骤S618:
在步骤S620中,将候选对象(即目标对象D2)存储到存储模块,从而完成目标对象D2为候选对象的情况下的缓存准入;
在步骤S618中,根据候选对象的历史访问信息,对候选对象进行标注,并在步骤S619中,将标注后的候选对象加入到当前训练集中。通过这种方式,能够使得当前训练集中包括与写请求相关的候选对象。
如果目标对象D2不为候选对象,则执行步骤S615,将目标对象D2的历史访问信息作为当前周期的概率预测模型的输入,通过当前周期的概率预测模型预测目标对象D2被访问的概率,并在步骤S616中,判断预测的概率是否大于或等于第一概率阈值。
如果预测的目标对象D2被访问的概率大于或等于第一概率阈值,则执行步骤S617,将目标对象D2存储到存储模块,实现目标对象D2的缓存准入,同时更新目标对象D2的历史访问信息。
如果预测的目标对象D2被访问的概率小于预设的第一概率阈值,则执行步骤S621,终止缓存写入,即目标对象D2不满足缓存准入要求,不将目标对象D2写入存储模块。
在缓存装置的存储模块(即缓存介质)存满、对象保存时间超期等情况下,缓存装置的控制模块可启动缓存淘汰的处理过程。
例如,在缓存装置的存储模块未存满的情况下,可直接将目标对象D1或目标对象D2存 储到存储模块;而在缓存装置的存储模块存满的情况下,即在存储模块的可用空间小于目标对象D1或目标对象D2所占用的存储空间的情况下,为了给目标对象D1或目标对象D2腾出存储空间,需要从存储模块中淘汰一个或多个对象。
图7示出根据本申请一实施例的缓存装置的缓存淘汰的处理过程的示意图。图7所示的缓存装置的缓存淘汰的处理过程中,候选对象为部分的目标对象,目标对象为存储模块中待淘汰的对象。
如图7所示,控制模块可在步骤S701中,确定存储模块中待淘汰的目标对象E,目标对象E可以为一个或多个。对于任一目标对象E,可在步骤S702中,获取目标对象E的历史访问信息,并在步骤S703中,判断目标对象E是否为候选对象。
如果目标对象E为候选对象,则同时执行步骤S710及步骤S708:
在步骤S710中,将候选对象(即目标对象E)保留在存储模块中,即不淘汰目标对象E;
在步骤S708中,根据候选对象(即目标对象E)的历史访问信息,对候选对象进行标注,并在步骤S709中,将标注后的候选对象加入到当前训练集中。通过这种方式,能够使得当前训练集中包括存储模块中待淘汰的候选对象,从而提高当前训练集中候选对象的多样性。
如果目标对象E不为候选对象,则执行步骤S704,将目标对象E的历史访问信息作为当前周期的概率预测模型的输入,通过当前周期的概率预测模型预测目标对象E被访问的概率,并在步骤S705中,判断预测的目标对象E被访问的概率是否小于或等于第二概率阈值。
如果预测的目标对象E被访问的概率小于或等于第二概率阈值,则执行步骤S706,将目标对象E从存储模块中淘汰,即删除或覆盖目标对象E,同时更新目标对象E的历史访问信息。
如果预测的目标对象E被访问的概率大于第二概率阈值,则执行步骤S707,将目标对象E保留在存储模块中,即不淘汰目标对象E,同时更新目标对象E的历史访问信息。
需要说明的是,以上仅分别以缓存装置接收的写请求中指示的对象未来被访问概率的预测值、存储模块中待淘汰的对象未来被访问概率的预测值作为依据,来进行缓存准入及缓存淘汰的决策。在一些实施例中,缓存准入在考虑写请求中指示的对象未来被访问概率的预测值的情况下,还可考虑业务系统的业务要求、安全规则、缓存装置的负载等其他条件;缓存淘汰在考虑需要存储模块中待淘汰的对象未来被访问概率的预测值的情况下,还可考虑存储模块中其他对象未来被访问概率的预测值、缓存介质(即存储模块)的写入速率限制等其他条件。本领域技术人员可根据实际情况确定缓存准入及缓存淘汰的决策条件,本申请对此不作限制。
本申请实施例的缓存装置,通过引入对象行为驱动的、可在线自动督学习的概率预测模型,不仅能够自动感知和适应应用系统多样的业务场景及数据访问分布的变化,还能在线完成概率预测模型的增量训练,在此基础上完成缓存准入及淘汰决策,从而能够提升缓存命中率,实现长期无人干预的稳定运行。此外,本申请实施例的缓存装置,使用精简知识存储结构记录对象的历史访问信息,还能够节省存储资源和计算资源。
在一种可能的实现方式中,本申请实施例的技术方案,还可以扩展到其它数据驱动的场景,例如搜索引擎结果排序、个性化推荐系统等。本申请的技术方案应用于搜索引擎结果排序时,可以根据用户对搜索结果的点击情况,自动标注关键词对应结果的排名,在线自监督训练排序模型,从而适应数据及用户喜好的变化。本申请的技术方案应用于个性化推荐系统时,可以根据用户对推荐结果的采纳情况,自动标注推荐结果的好与差,在线自监督训练个性化推荐模型,从而提高推荐的精准性。
图8示出根据本申请一实施例的缓存方法的流程图。所述缓存方法可应用于缓存装置中的控制模块,所述缓存方法包括:
步骤S810,根据候选对象的历史访问信息,对所述候选对象进行标注;其中,所述候选对象为全部或者部分的目标对象,所述目标对象为缓存装置接收的读请求中指示的对象,或者所述目标对象为缓存装置接收的写请求中指示的对象,或者所述目标对象为缓存装置的存储模块中待淘汰的对象;
步骤S820,将标注后的候选对象加入到当前训练集中;
步骤S830,使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在所述当前训练集中的候选对象的数量大于或等于数量阈值时使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型。
在一种可能的实现方式中,步骤S810可包括:在所述候选对象的历史访问信息中确定参考位置;将所述历史访问信息中在所述参考位置之前的信息,标注为所述候选对象的参考访问信息;将所述历史访问信息中在所述参考位置之后的信息,标注为所述候选对象的参考访问概率。
在一种可能的实现方式中,所述方法还包括:如果所述目标对象为所述缓存装置接收的写请求中指示的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;在预测的概率大于或等于第一概率阈值时,将所述目标对象存储到所述存储模块。
在一种可能的实现方式中,所述方法还包括:如果所述目标对象为所述存储模块中待淘汰的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;在预测的概率小于或等于第二概率阈值时,将所述目标对象从所述存储模块中淘汰。
在一种可能的实现方式中,所述方法还包括:如果所述目标对象为所述缓存装置接收的写请求中指示的对象,且没有所述目标对象的历史访问信息,将所述目标对象存储到所述存储模块。
在一种可能的实现方式中,所述方法还包括:从多个所述目标对象中采样得到一个或多个所述候选对象。
在一种可能的实现方式中,所述方法还包括:将所述候选对象存储到所述存储模块。
本申请的实施例提供了一种芯片,所述芯片用于部署上述任意一种缓存装置。
本申请的实施例提供了一种电子设备,包括:处理器;用于存储处理器可执行指令的存储器,其中,所述处理器被配置为执行所述指令时实现上述方法。
本申请的实施例提供了一种非易失性计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。
本申请的实施例提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行上述方法。
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是――但不限于――电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(Random Access Memory,RAM)、只读存储器(Read Only Memory,ROM)、可擦式可编程只读存储器(Electrically  Programmable Read-Only-Memory,EPROM或闪存)、静态随机存取存储器(Static Random-Access Memory,SRAM)、便携式压缩盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、数字多功能盘(Digital Video Disc,DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。
这里所描述的计算机可读程序指令或代码可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。
用于执行本申请操作的计算机程序指令可以是汇编指令、指令集架构(Instruction Set Architecture,ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(Local Area Network,LAN)或广域网(Wide Area Network,WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或可编程逻辑阵列(Programmable Logic Array,PLA),该电子电路可以执行计算机可读程序指令,从而实现本申请的各个方面。
这里参照根据本申请实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本申请的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。
附图中的流程图和框图显示了根据本申请的多个实施例的装置、系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可 以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。
也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行相应的功能或动作的硬件(例如电路或ASIC(Application Specific Integrated Circuit,专用集成电路))来实现,或者可以用硬件和软件的组合,如固件等来实现。
尽管在此结合各实施例对本发明进行了描述,然而,在实施所要求保护的本发明过程中,本领域技术人员通过查看所述附图、公开内容、以及所附权利要求书,可理解并实现所述公开实施例的其它变化。在权利要求中,“包括”(comprising)一词不排除其他组成部分或步骤,“一”或“一个”不排除多个的情况。单个处理器或其它单元可以实现权利要求中列举的若干项功能。相互不同的从属权利要求中记载了某些措施,但这并不表示这些措施不能组合起来产生良好的效果。
以上已经描述了本申请的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。

Claims (20)

  1. 一种缓存装置,其特征在于,所述缓存装置包括控制模块及存储模块;
    所述控制模块,用于:
    根据候选对象的历史访问信息,对所述候选对象进行标注;其中,所述候选对象为全部或者部分的目标对象,所述目标对象为所述缓存装置接收的读请求中指示的对象,或者所述目标对象为所述缓存装置接收的写请求中指示的对象,或者所述目标对象为所述存储模块中待淘汰的对象;
    将标注后的候选对象加入到当前训练集中;
    使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在所述当前训练集中的候选对象的数量大于或等于数量阈值时使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型。
  2. 根据权利要求1所述的装置,其特征在于,所述控制模块,用于:
    在所述候选对象的历史访问信息中确定参考位置;
    将所述历史访问信息中在所述参考位置之前的信息,标注为所述候选对象的参考访问信息;
    将所述历史访问信息中在所述参考位置之后的信息,标注为所述候选对象的参考访问概率。
  3. 根据权利要求1或2所述的装置,其特征在于,所述控制模块,用于:
    如果所述目标对象为所述缓存装置接收的写请求中指示的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;
    在预测的概率大于或等于第一概率阈值时,将所述目标对象存储到所述存储模块。
  4. 根据权利要求1至3中任意一项所述的装置,其特征在于,所述控制模块,用于:
    如果所述目标对象为所述存储模块中待淘汰的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;
    在预测的概率小于或等于第二概率阈值时,将所述目标对象从所述存储模块中淘汰。
  5. 根据权利要求1至4中任意一项所述的装置,其特征在于,所述控制模块,用于:
    如果所述目标对象为所述缓存装置接收的写请求中指示的对象,且没有所述目标对象的历史访问信息,将所述目标对象存储到所述存储模块。
  6. 根据权利要求1至5中任意一项所述的装置,其特征在于,所述控制模块,用于:
    从多个所述目标对象中采样得到一个或多个所述候选对象。
  7. 根据权利要求1至6中任意一项所述的装置,其特征在于,所述控制模块,用于:
    将所述候选对象存储到所述存储模块。
  8. 一种缓存方法,其特征在于,所述方法包括:
    根据候选对象的历史访问信息,对所述候选对象进行标注;其中,所述候选对象为全部或者部分的目标对象,所述目标对象为缓存装置接收的读请求中指示的对象,或者所述目标对象为缓存装置接收的写请求中指示的对象,或者所述目标对象为缓存装置的存储模块中待淘汰的对象;
    将标注后的候选对象加入到当前训练集中;
    使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型,或者在所述当前训练集中的候选对象的数量大于或等于数量阈值时使用所述当前训练集对所述当前周期的概率预测模型进行训练来得到下一周期的概率预测模型;
    其中,所述方法应用于所述缓存装置的控制模块。
  9. 根据权利要求8所述的方法,其特征在于,所述根据候选对象的历史访问信息,对所述候选对象进行标注,包括:
    在所述候选对象的历史访问信息中确定参考位置;
    将所述历史访问信息中在所述参考位置之前的信息,标注为所述候选对象的参考访问信息;
    将所述历史访问信息中在所述参考位置之后的信息,标注为所述候选对象的参考访问概率。
  10. 根据权利要求8或9所述的方法,其特征在于,所述方法还包括:
    如果所述目标对象为所述缓存装置接收的写请求中指示的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;
    在预测的概率大于或等于第一概率阈值时,将所述目标对象存储到所述存储模块。
  11. 根据权利要求8至10中任意一项所述的方法,其特征在于,所述方法还包括:
    如果所述目标对象为所述存储模块中待淘汰的对象,将所述目标对象的历史访问信息作为所述当前周期的概率预测模型的输入,通过所述当前周期的概率预测模型预测所述目标对象被访问的概率;
    在预测的概率小于或等于第二概率阈值时,将所述目标对象从所述存储模块中淘汰。
  12. 根据权利要求8至11中任意一项所述的方法,其特征在于,所述方法,还包括:
    如果所述目标对象为所述缓存装置接收的写请求中指示的对象,且没有所述目标对象的历史访问信息,将所述目标对象存储到所述存储模块。
  13. 根据权利要求8至12中任意一项所述的方法,其特征在于,所述方法还包括:
    从多个所述目标对象中采样得到一个或多个所述候选对象。
  14. 根据权利要求8至13中任意一项所述的方法,其特征在于,所述方法还包括:
    将所述候选对象存储到所述存储模块。
  15. 一种芯片,其特征在于,所述芯片用于部署权利要求1至7中任意一项所述的缓存装置。
  16. 一种缓存系统,其特征在于,包括:
    缓存装置,用于缓存对象,所述缓存装置为权利要求1至7中任意一项所述的缓存装置;
    数据处理设备,用于向所述缓存装置发送所述对象的读请求或写请求;
    数据存储设备,用于存储所述对象。
  17. 一种缓存系统,其特征在于,包括:
    数据处理设备,所述数据处理设备包括处理器及用于缓存对象的缓存装置,其中,所述处理器用于向所述缓存装置发送所述对象的读请求或写请求,所述缓存装置为权利要求1至7中任意一项所述的缓存装置;
    数据存储设备,用于存储所述对象。
  18. 一种缓存装置,其特征在于,包括:
    控制模块;
    用于存储所述控制模块的可执行指令的存储模块;
    其中,所述控制模块被配置为执行所述指令时实现权利要求8至14中任意一项所述的方法。
  19. 一种非易失性计算机可读存储介质,其上存储有计算机程序指令,其特征在于,所述计算机程序指令被处理器执行时实现权利要求8至14中任意一项所述的方法。
  20. 一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行权利要求8至14中任意一项所述的方法。
PCT/CN2022/084333 2021-04-06 2022-03-31 缓存装置、方法及系统 WO2022213871A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202110368192.1 2021-04-06
CN202110368192 2021-04-06
CN202110931957.8A CN115168411A (zh) 2021-04-06 2021-08-13 缓存装置、方法及系统
CN202110931957.8 2021-08-13

Publications (1)

Publication Number Publication Date
WO2022213871A1 true WO2022213871A1 (zh) 2022-10-13

Family

ID=83476061

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/084333 WO2022213871A1 (zh) 2021-04-06 2022-03-31 缓存装置、方法及系统

Country Status (2)

Country Link
CN (1) CN115168411A (zh)
WO (1) WO2022213871A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118012788A (zh) * 2024-04-09 2024-05-10 北京壁仞科技开发有限公司 数据处理器、数据处理方法、电子设备和存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140351188A1 (en) * 2013-05-22 2014-11-27 Exablade Corporation Prefetch system and method
CN110334036A (zh) * 2019-06-28 2019-10-15 京东数字科技控股有限公司 一种实现缓存数据调度的方法和装置
CN111488925A (zh) * 2020-04-07 2020-08-04 北京百度网讯科技有限公司 一种数据标注方法、装置、电子设备及存储介质
CN112261668A (zh) * 2020-10-20 2021-01-22 北京邮电大学 移动边缘网络中的内容缓存方法、装置、电子设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140351188A1 (en) * 2013-05-22 2014-11-27 Exablade Corporation Prefetch system and method
CN110334036A (zh) * 2019-06-28 2019-10-15 京东数字科技控股有限公司 一种实现缓存数据调度的方法和装置
CN111488925A (zh) * 2020-04-07 2020-08-04 北京百度网讯科技有限公司 一种数据标注方法、装置、电子设备及存储介质
CN112261668A (zh) * 2020-10-20 2021-01-22 北京邮电大学 移动边缘网络中的内容缓存方法、装置、电子设备

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118012788A (zh) * 2024-04-09 2024-05-10 北京壁仞科技开发有限公司 数据处理器、数据处理方法、电子设备和存储介质

Also Published As

Publication number Publication date
CN115168411A (zh) 2022-10-11

Similar Documents

Publication Publication Date Title
US11301394B2 (en) Using a machine learning module to select one of multiple cache eviction algorithms to use to evict a track from the cache
TWI684099B (zh) 剖析快取替代
US7669009B2 (en) Method and apparatus for run-ahead victim selection to reduce undesirable replacement behavior in inclusive caches
CN107247675B (zh) 一种基于分类预测的缓存选择方法和系统
US9558123B2 (en) Retrieval hash index
CN107223240B (zh) 与文件高速缓存的上下文感知管理相关联的计算方法和装置
CN106528451B (zh) 针对小文件的二级缓存预取的云存储框架及构建方法
US11620219B2 (en) Storage drive dependent track removal in a cache for storage
US11593268B2 (en) Method, electronic device and computer program product for managing cache
CN110858181A (zh) 用于执行地址转换的装置和方法
CN110795363A (zh) 一种存储介质的热页预测方法和页面调度方法
US20230009375A1 (en) Data prefetching method and apparatus, and storage device
CN111406251B (zh) 数据预取方法及装置
CN117235088B (zh) 一种存储系统的缓存更新方法、装置、设备、介质及平台
US20220350484A1 (en) Machine learning to improve caching efficiency in a storage system
WO2022213871A1 (zh) 缓存装置、方法及系统
US11281588B2 (en) Method, apparatus and computer program product for managing I/O operation using prediction model to predict storage area to be accessed
WO2023165543A1 (zh) 共享缓存的管理方法、装置及存储介质
CN113268458A (zh) 一种基于代价敏感分类算法的缓存方法及系统
CN116472521A (zh) 缓存暂存中继
WO2022156452A1 (zh) 一种缓存管理方法、装置及设备
WO2022148306A1 (zh) 一种淘汰数据的方法、装置、缓存节点以及缓存系统
CN106407242B (zh) 分组处理器转发数据库缓存
Torabi Towards Efficient and Robust Caching: Investigating Alternative Machine Learning Approaches for Edge Caching
WO2023129126A1 (en) Machine learning for stride predictor for memory prefetch

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22783938

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22783938

Country of ref document: EP

Kind code of ref document: A1