AdaptiveLru¶
from acron.core import AdaptiveLru
- class AdaptiveLru¶
Bases:
Bases:
NamableA basic LRU-type algorithm, except that it is adaptive and attempts to avoid evicting pages that have been used more frequently (even if less recently) than other pages.
The interface is designed to be identical to that for
SimpleLru, so that it may be used as a drop-in replacement.Inheritance diagram
digraph inheritance1b79f1579c { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "AdaptiveLru" [URL="acron.core.AdaptiveLru.html#acron.core.AdaptiveLru",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "Namable" -> "AdaptiveLru" [arrowsize=0.75,style=""]; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "Namable" [URL="acron.core.Namable.html#acron.core.Namable",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "Namable" [arrowsize=0.75,style=""]; }- __init__()¶
- begin_epoch()¶
Marks the end of the previous epoch and the beginning of the next one. This will evict any objects that are pending eviction, and also update any internal bookkeeping.
- consider_evict()¶
Evicts a sequence of objects if the queue is full.
- count_active_size()¶
Returns the total size of the pages that were enqueued since the last call to
begin_epoch().
- evict_to()¶
Evicts a sequence of objects until the queue fits within the indicated target size, regardless of its normal max size.
- get_max_size()¶
Returns the max size of all objects that are allowed to be active on the LRU.
- get_max_updates_per_frame()¶
Returns the maximum number of pages the
AdaptiveLruwill update each frame.
- get_total_size()¶
Returns the total size of all objects currently active on the LRU.
- get_weight()¶
Returns the weight value used to compute the exponential moving average.
- output()¶
- set_max_size()¶
Changes the max size of all objects that are allowed to be active on the LRU.
If the size is (size_t)-1, there is no limit.
- set_max_updates_per_frame()¶
Specifies the maximum number of pages the
AdaptiveLruwill update each frame. This is a performance optimization: keeping this number low limits the impact of the AdaptiveLru’s adaptive algorithm.
- set_weight()¶
The following methods are specific to
AdaptiveLru, and do not exist in theSimpleLruimplementation. In most cases, the defaults will be sufficient, so you do not need to mess with them.Specifies the weight value used to compute the exponential moving average.
- validate()¶
Checks that the LRU is internally self-consistent. Returns true if successful, false if there is some problem.
- write()¶