Panda3D
Public Member Functions | List of all members
AdaptiveLru Class Reference

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. More...

Inheritance diagram for AdaptiveLru:
Namable MemoryBase

Public Member Functions

 __init__ (str name, size_t max_size)
 
 beginEpoch ()
 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. More...
 
 considerEvict ()
 Evicts a sequence of objects if the queue is full. More...
 
size_t countActiveSize ()
 Returns the total size of the pages that were enqueued since the last call to begin_epoch(). More...
 
 evictTo (size_t target_size)
 Evicts a sequence of objects until the queue fits within the indicated target size, regardless of its normal max size. More...
 
size_t getMaxSize ()
 Returns the max size of all objects that are allowed to be active on the LRU. More...
 
int getMaxUpdatesPerFrame ()
 Returns the maximum number of pages the AdaptiveLru will update each frame. More...
 
size_t getTotalSize ()
 Returns the total size of all objects currently active on the LRU. More...
 
float getWeight ()
 Returns the weight value used to compute the exponential moving average. More...
 
 output (Ostream out)
 
 setMaxSize (size_t max_size)
 Changes the max size of all objects that are allowed to be active on the LRU. More...
 
 setMaxUpdatesPerFrame (int max_updates_per_frame)
 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. More...
 
 setWeight (float weight)
 Specifies the weight value used to compute the exponential moving average. More...
 
bool validate ()
 Checks that the LRU is internally self-consistent. Returns true if successful, false if there is some problem. More...
 
 write (Ostream out, int indent_level)
 
- Public Member Functions inherited from Namable
 __init__ (const Namable copy)
 
 __init__ (str initial_name)
 
 clearName ()
 Resets the Namable's name to empty. More...
 
str getName ()
 
bool hasName ()
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
Namable operator= (const Namable other)
 
 output (Ostream out)
 Outputs the Namable. This function simply writes the name to the output stream; most Namable derivatives will probably redefine this. More...
 
 setName (str name)
 

Additional Inherited Members

- Static Public Member Functions inherited from Namable
static TypeHandle getClassType ()
 

Detailed Description

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.

Member Function Documentation

◆ __init__()

__init__ ( str  name,
size_t  max_size 
)

◆ beginEpoch()

beginEpoch ( )

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()

considerEvict ( )

Evicts a sequence of objects if the queue is full.

◆ countActiveSize()

size_t countActiveSize ( )

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

◆ evictTo()

evictTo ( size_t  target_size)

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

◆ getMaxSize()

size_t getMaxSize ( )

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

◆ getMaxUpdatesPerFrame()

int getMaxUpdatesPerFrame ( )

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

◆ getTotalSize()

size_t getTotalSize ( )

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

◆ getWeight()

float getWeight ( )

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

◆ output()

output ( Ostream  out)

◆ setMaxSize()

setMaxSize ( size_t  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.

◆ setMaxUpdatesPerFrame()

setMaxUpdatesPerFrame ( int  max_updates_per_frame)

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()

setWeight ( float  weight)

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

◆ validate()

bool validate ( )

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

◆ write()

write ( Ostream  out,
int  indent_level 
)