panda3d.core.AdaptiveLru

class AdaptiveLru

Bases: Namable

A 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

Inheritance diagram of AdaptiveLru

__init__(name: str, max_size: size_t) → None
beginEpoch() → None

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.

considerEvict() → None

Evicts a sequence of objects if the queue is full.

countActiveSize() → size_t

Returns the total size of the pages that were enqueued since the last call to beginEpoch().

Return type

size_t

evictTo(target_size: size_t) → None

Evicts a sequence of objects until the queue fits within the indicated target size, regardless of its normal max size.

getMaxSize() → size_t

Returns the max size of all objects that are allowed to be active on the LRU.

Return type

size_t

getMaxUpdatesPerFrame() → int

Returns the maximum number of pages the AdaptiveLru will update each frame.

getTotalSize() → size_t

Returns the total size of all objects currently active on the LRU.

Return type

size_t

getWeight() → float

Returns the weight value used to compute the exponential moving average.

output(out: ostream) → None
setMaxSize(max_size: size_t) → None

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.

setMaxUpdatesPerFrame(max_updates_per_frame: int) → None

Specifies the maximum number of pages the AdaptiveLru will update each frame. This is a performance optimization: keeping this number low limits the impact of the AdaptiveLru’s adaptive algorithm.

setWeight(weight: float) → None

The following methods are specific to AdaptiveLru, and do not exist in the SimpleLru implementation. In most cases, the defaults will be sufficient, so you do not need to mess with them.

validate() → bool

Checks that the LRU is internally self-consistent. Returns true if successful, false if there is some problem.

write(out: ostream, indent_level: int) → None