|
rambrain
|
scheduler working with a double linked cycle. Details see paper. More...
#include <cyclicManagedMemory.h>
Classes | |
| struct | chain |
Public Member Functions | |
| cyclicManagedMemory (rambrain::managedSwap *swap, rambrain::global_bytesize size) | |
| virtual | ~cyclicManagedMemory () |
| void | printCycle () const |
| prints out all elements known to the scheduler with their respective status More... | |
| void | printMemUsage () const |
| prints out current memory usage More... | |
| bool | checkCycle () |
| checks whether the scheduler believes to be sane and prints an error message if not More... | |
| bool | setPreemptiveLoading (bool preemptive) |
| sets whether scheduler should guess next needed items More... | |
| bool | setPreemptiveUnloading (bool preemptive) |
| sets whether scheduler should swap out elements without strict need More... | |
Public Member Functions inherited from rambrain::managedMemory | |
| managedMemory (managedSwap *swap, global_bytesize size=gig) | |
| Standard constructor. More... | |
| virtual | ~managedMemory () |
| void | closeSwap () |
| powers down the swap class, ergo a cleanup More... | |
| bool | setMemoryLimit (global_bytesize size) |
| dynamically adjusts allowed ram usage More... | |
| global_bytesize | getMemoryLimit () const |
| returns current memory limit More... | |
| global_bytesize | getUsedMemory () const |
| returns current ram usage More... | |
| global_bytesize | getSwappedMemory () const |
| returns current swap usage More... | |
| global_bytesize | getFreeSwapMemory () const |
| return current swap free capacity More... | |
| global_bytesize | getTotalSwapMemory () const |
| return current swap capacity More... | |
| bool | setOutOfSwapIsFatal (bool fatal=true) |
| set policy what to do when out of memory in both ram and swap More... | |
| bool | prepareUse (rambrain::managedMemoryChunk &chunk, bool acquireLock=true) |
| Triggers swapin of chunk. More... | |
| bool | setUse (memoryID id) |
| Convenience interface for setUse( managedMemoryChunk &chunk, bool writeAccess ) More... | |
| bool | unsetUse (memoryID id) |
| Convenience interface for unsetUse ( managedMemoryChunk &chunk, bool writeAccess ) More... | |
| bool | setUse (managedMemoryChunk &chunk, bool writeAccess) |
| Marks chunk as used and prevents swapout. More... | |
| bool | unsetUse (managedMemoryChunk &chunk, unsigned int no_unsets=1) |
| Marks chunk as unused again. More... | |
| unsigned int | getNumberOfChildren (const memoryID &id) |
| conveniently returns number of children of the memoryChunk with id id More... | |
| void | printTree (managedMemoryChunk *current=NULL, unsigned int nspaces=0) |
| prints the tree of managed objects for further inspection More... | |
| void | recursiveMfree (memoryID id) |
| recursively deletes the objects in memory, first children, then parents. More... | |
| void | linearMfree () |
| linearly deletes all objects in memory More... | |
| void | printSwapstats () const |
| print statistic about the number, size and efficiency of swapping actions More... | |
| void | resetSwapstats () |
| reset statistic about the number, size and efficiency of swapping actions More... | |
| double | getHitsOverMisses () |
| returns current hits over misses rate for accessing elements. More... | |
| double | getTotalSwappedOutBytes () |
| simple Getter More... | |
| double | getTotalSwappedInBytes () |
| simple Getter More... | |
Private Member Functions | |
| virtual bool | swapIn (managedMemoryChunk &chunk) |
| cyclic implementation of swapIn, see paper More... | |
| virtual swapErrorCode | swapOut (global_bytesize min_size) |
| cyclic implementation of swapOut, see paper More... | |
| virtual bool | touch (managedMemoryChunk &chunk) |
| marks chunk as recently active as a hint for scheduling More... | |
| virtual void | untouch (managedMemoryChunk &chunk) |
| tries to regulate immediately usable free memory in ram to a level optimal for preemptive loading More... | |
| virtual void | schedulerRegister (managedMemoryChunk &chunk) |
| gives scheduler code the opportunity to register its own datastructures associated with a chunk More... | |
| virtual void | schedulerDelete (managedMemoryChunk &chunk) |
| signals deletion of chunk to scheduler code More... | |
| void | decay (global_bytesize bytes) |
| : Tries to unload around bytes bytes of preemptive elements More... | |
| struct cyclicManagedMemory::chain | filterChain (chain &toFilter, const memoryStatus *separateStatus, bool *preemptiveLoaded=NULL) |
| : separates all chunks matching state in list separateStatus or preeemptiveLoaded from the ring More... | |
| void | printBacklog () const |
Static Private Member Functions | |
| static void | insertBefore (cyclicAtime *pos, chain separated) |
| static void | printChain (const char *name, const chain mchain) |
Private Attributes | |
| cyclicAtime * | active = NULL |
| cyclicAtime * | counterActive = NULL |
| cyclicAtime * | preemptiveStart = NULL |
| float | swapOutFrac = .8 |
| float | swapInFrac = .9 |
| bool | preemtiveSwapIn = true |
| bool | preemtiveSwapOut = true |
| global_bytesize | preemptiveBytes = 0 |
| unsigned int | consecutivePreemptiveTransactions = 0 |
| unsigned int | preemptiveSinceLast = 0 |
| double | preemptiveTurnoffFraction = .01 |
| backlog_entry | backlog [backlog_size] |
| unsigned int | backlog_pos = 0 |
Static Private Attributes | |
| static pthread_mutex_t | cyclicTopoLock = PTHREAD_MUTEX_INITIALIZER |
| static const unsigned int | backlog_size = 100 |
Additional Inherited Members | |
Static Public Member Functions inherited from rambrain::managedMemory | |
| static void | signalSwappingCond () |
| signals that a swapping action has completed and memory limits have changed More... | |
| static void | sigswapstats (int sig) |
| static binding that will print out some stats. Compile with cmake -DSWAPSTATS=on and send process SIGUSR1 to call this function More... | |
| static void | versionInfo () |
| prints out a GIT version info and a diff on this version at compile time More... | |
Static Public Attributes inherited from rambrain::managedMemory | |
| static const memoryID | root = 1 |
| static memoryID | parent = managedMemory::root |
| static bool | threadSynced = false |
| static pthread_mutex_t | parentalMutex = PTHREAD_MUTEX_INITIALIZER |
| static pthread_cond_t | parentalCond = PTHREAD_COND_INITIALIZER |
| static pthread_t | creatingThread = 0 |
| static managedMemory * | defaultManager |
| static const memoryID | invalid = 0 |
Protected Types inherited from rambrain::managedMemory | |
| enum | swapErrorCode { ERR_SUCCESS, ERR_SWAPFULL, ERR_MORETHANTOTALRAM, ERR_NOTENOUGHCANDIDATES } |
| Error codes for swapOut requests. More... | |
Protected Member Functions inherited from rambrain::managedMemory | |
| managedMemoryChunk * | mmalloc (global_bytesize sizereq) |
| allocates and registers a new raw memory chunk of size sizereq to be filled in by managedPtr More... | |
| bool | mrealloc (memoryID id, global_bytesize sizereq) |
| this function is a stub. In the future it should be capable of resizing an existing allocation More... | |
| void | mfree (rambrain::memoryID id, bool inCleanup=false) |
| this function unregisters and deallocates a chunk More... | |
| managedMemoryChunk & | resolveMemChunk (const memoryID &id) |
| returns a reference to the memoryChunk indexed by id id More... | |
| virtual bool | swapIn (memoryID id) |
| Convenience function for swapIn ( managedMemoryChunk &chunk ) More... | |
| bool | ensureEnoughSpace (global_bytesize sizereq, managedMemoryChunk *orIsSwappedin=NULL) |
| This function ensures that there is sizereq space left in ram. More... | |
| bool | waitForSwapin (managedMemoryChunk &chunk, bool keepSwapLock=false) |
| Waits until a certain chunk is present. More... | |
| bool | waitForSwapout (managedMemoryChunk &chunk, bool keepSwapLock=false) |
| Waits until a certain chunk is swapped out. More... | |
| void | claimUsageof (global_bytesize bytes, bool rambytes, bool used) |
| account for memory usage change More... | |
| void | claimTobefreed (global_bytesize bytes, bool tobefreed) |
| account for future availability of bytes More... | |
| void | waitForAIO () |
| wait for some asynchronous action to occur More... | |
Static Protected Member Functions inherited from rambrain::managedMemory | |
| static bool | Throw (memoryException e) |
| Custom throw function, as we need to prevent throwing exceptions in construtors. More... | |
Protected Attributes inherited from rambrain::managedMemory | |
| managedSwap * | swap = 0 |
| global_bytesize | memory_max |
| global_bytesize | memory_used = 0 |
| global_bytesize | memory_swapped = 0 |
| global_bytesize | memory_tobefreed = 0 |
| bool | outOfSwapIsFatal = true |
| std::map< memoryID, managedMemoryChunk * > | memChunks |
| memoryAtime | atime = 0 |
| memoryID | memID_pace = 1 |
| managedMemory * | previousManager |
| global_bytesize | n_swap_out = 0 |
| global_bytesize | n_swap_in = 0 |
| global_bytesize | swap_out_scheduled_bytes = 0 |
| global_bytesize | swap_in_scheduled_bytes = 0 |
| global_bytesize | swap_out_bytes = 0 |
| global_bytesize | swap_in_bytes = 0 |
| global_bytesize | swap_out_bytes_last = 0 |
| global_bytesize | swap_in_bytes_last = 0 |
| global_bytesize | swap_hits = 0 |
| global_bytesize | swap_misses = 0 |
| size_t | memoryAlignment = 1 |
Static Protected Attributes inherited from rambrain::managedMemory | |
| static pthread_mutex_t | stateChangeMutex = PTHREAD_MUTEX_INITIALIZER |
| static pthread_cond_t | swappingCond = PTHREAD_COND_INITIALIZER |
| static FILE * | logFile = fopen ( "rambrain-swapstats.log", "w" ) |
| static bool | firstLog = true |
scheduler working with a double linked cycle. Details see paper.
Definition at line 50 of file cyclicManagedMemory.h.
| rambrain::cyclicManagedMemory::cyclicManagedMemory | ( | rambrain::managedSwap * | swap, |
| rambrain::global_bytesize | size | ||
| ) |
Definition at line 47 of file cyclicManagedMemory.cpp.
|
virtual |
Definition at line 1095 of file cyclicManagedMemory.cpp.
| bool rambrain::cyclicManagedMemory::checkCycle | ( | ) |
checks whether the scheduler believes to be sane and prints an error message if not
Definition at line 653 of file cyclicManagedMemory.cpp.
|
private |
: Tries to unload around bytes bytes of preemptive elements
Definition at line 309 of file cyclicManagedMemory.cpp.
|
private |
: separates all chunks matching state in list separateStatus or preeemptiveLoaded from the ring
Definition at line 224 of file cyclicManagedMemory.cpp.
|
staticprivate |
Definition at line 212 of file cyclicManagedMemory.cpp.
|
private |
Definition at line 1106 of file cyclicManagedMemory.cpp.
|
staticprivate |
Definition at line 878 of file cyclicManagedMemory.cpp.
| void rambrain::cyclicManagedMemory::printCycle | ( | ) | const |
prints out all elements known to the scheduler with their respective status
Definition at line 813 of file cyclicManagedMemory.cpp.
| void rambrain::cyclicManagedMemory::printMemUsage | ( | ) | const |
prints out current memory usage
Definition at line 207 of file cyclicManagedMemory.cpp.
|
privatevirtual |
signals deletion of chunk to scheduler code
Implements rambrain::managedMemory.
Definition at line 80 of file cyclicManagedMemory.cpp.
|
privatevirtual |
gives scheduler code the opportunity to register its own datastructures associated with a chunk
Implements rambrain::managedMemory.
Definition at line 52 of file cyclicManagedMemory.cpp.
| bool rambrain::cyclicManagedMemory::setPreemptiveLoading | ( | bool | preemptive | ) |
sets whether scheduler should guess next needed items
| preemtive | iff set to true, scheduler will guess (default) |
Definition at line 193 of file cyclicManagedMemory.cpp.
| bool rambrain::cyclicManagedMemory::setPreemptiveUnloading | ( | bool | preemptive | ) |
sets whether scheduler should swap out elements without strict need
| preemtive | iff set to true, scheduler will guess (default) |
Definition at line 200 of file cyclicManagedMemory.cpp.
|
privatevirtual |
cyclic implementation of swapIn, see paper
Implements rambrain::managedMemory.
Definition at line 381 of file cyclicManagedMemory.cpp.
|
privatevirtual |
cyclic implementation of swapOut, see paper
Implements rambrain::managedMemory.
Definition at line 898 of file cyclicManagedMemory.cpp.
|
privatevirtual |
marks chunk as recently active as a hint for scheduling
Implements rambrain::managedMemory.
Definition at line 128 of file cyclicManagedMemory.cpp.
|
privatevirtual |
tries to regulate immediately usable free memory in ram to a level optimal for preemptive loading
Implements rambrain::managedMemory.
Definition at line 636 of file cyclicManagedMemory.cpp.
|
private |
Definition at line 106 of file cyclicManagedMemory.h.
|
private |
Definition at line 131 of file cyclicManagedMemory.h.
|
private |
Definition at line 132 of file cyclicManagedMemory.h.
|
staticprivate |
Definition at line 130 of file cyclicManagedMemory.h.
|
private |
Definition at line 116 of file cyclicManagedMemory.h.
|
private |
Definition at line 107 of file cyclicManagedMemory.h.
|
staticprivate |
Definition at line 119 of file cyclicManagedMemory.h.
|
private |
Definition at line 115 of file cyclicManagedMemory.h.
|
private |
Definition at line 117 of file cyclicManagedMemory.h.
|
private |
Definition at line 108 of file cyclicManagedMemory.h.
|
private |
Definition at line 121 of file cyclicManagedMemory.h.
|
private |
Definition at line 113 of file cyclicManagedMemory.h.
|
private |
Definition at line 114 of file cyclicManagedMemory.h.
|
private |
Definition at line 111 of file cyclicManagedMemory.h.
|
private |
Definition at line 110 of file cyclicManagedMemory.h.