Struct mlcr::Cache [] [src]

pub struct Cache { /* fields omitted */ }

A learning cache tracker.

This keeps track of cache blocks.

A cache block represents some data, which is not managed by the cache tracker. The cache block is said to be touched when this data is used in some way.

The ideal replacement is the block which is used in the most distant future. As this is not possible to know in advance, we make a prediction or a approximate ideal replacement, which is based around various data points of the block such as the time of the last uses, or the number of touches.

The aim of the cache tracker is to provided approximate ideal replacements. Numerous algorithms for making these predictions exists (examples are LRU, PLRU, LFU, MFU, MRU, ARC, etc.), but MLCR uses an approach which is radically different: It feeds the data points into a neural network and lets this estimate the tick of the next touch.

Methods

impl Cache
[src]

Create a new cache tracker.

Touch a cache block.

This should be called whenever the object id represents is used (read, written, etc.).

This will train the neural network with the new data.

Insert a new cache block into the cache tracker.

Remove a cache block.

Get an iterator over blocks from cold to hot.

Get at iterator over blocks to remove to trim the cache tracker to to.

Note that this won't remove the blocks, and this should be handled manually with the remove method.