|
rambrain
|
An implementation of managedSwap that is capable of kernel asynchronousIO. More...
#include <managedFileSwap.h>
Public Member Functions | |
| managedFileSwap (global_bytesize size, const char *filemask, global_bytesize oneFile=0, bool enableDMA=false) | |
| virtual | ~managedFileSwap () |
| virtual void | swapDelete (managedMemoryChunk *chunk) |
| Mark chunk as deleted. More... | |
| virtual global_bytesize | swapIn (managedMemoryChunk **chunklist, unsigned int nchunks) |
| Trigger swap in of the chunks pointed to by chunklist. More... | |
| virtual global_bytesize | swapIn (managedMemoryChunk *chunk) |
| Trigger swap in of the chunk pointed to by chunk. More... | |
| virtual global_bytesize | swapOut (managedMemoryChunk **chunklist, unsigned int nchunks) |
| Trigger swap out of the chunks pointed to by chunklist. More... | |
| virtual global_bytesize | swapOut (managedMemoryChunk *chunk) |
| Trigger swap out of the chunk pointed to by chunk. More... | |
| virtual bool | extendSwap (global_bytesize size) |
| extend swap by size number of bytes More... | |
| virtual bool | extendSwapByPolicy (global_bytesize min_size) |
| extend swap by policy More... | |
| void | setDMA (bool arg1) |
| virtual void | close () |
| Close the swap if not already closed. More... | |
Public Member Functions inherited from rambrain::managedSwap | |
| managedSwap (global_bytesize size) | |
| virtual | ~managedSwap () |
| virtual global_bytesize | getSwapSize () const |
| Simple getter. More... | |
| virtual global_bytesize | getUsedSwap () const |
| Simple getter. More... | |
| virtual global_bytesize | getFreeSwap () const |
| Simple getter. More... | |
| virtual swapPolicy | getSwapPolicy () const |
| virtual swapPolicy | setSwapPolicy (swapPolicy newPolicy) |
| size_t | getMemoryAlignment () const |
| Returns possible memory alignment restrictions. More... | |
| void | claimUsageof (global_bytesize bytes, bool rambytes, bool used) |
| account for memory usage change More... | |
| void | waitForCleanExit () |
| Function waits for all asynchronous IO to complete. The wait is implemented non-performant as a normal user does not have to wait for this. Implementing this with a _cond just destroys performance in the respective swapIn/out procedures without increasing any user space functionality. More... | |
Public Attributes | |
| const unsigned int | pageSize |
Protected Member Functions | |
| void | asyncIoArrived (rambrain::pageFileLocation *ref, struct io_event *aio) |
| deals with a single asynchronous IO event completion More... | |
| void | completeTransactionOn (rambrain::pageFileLocation *ref, bool lock=true) |
| called to finish a transaction when all pending aio on a managedMemoryChunk has completed More... | |
| virtual bool | checkForAIO () |
| gives this class the chance to treat incoming aio events More... | |
| void | my_io_submit (struct iocb *aio) |
| bool | cleanupCachedElements (rambrain::global_bytesize minimum_size=0) |
| throws out cached elements still in ram but also resident on disk. This makes space in situations of low swap memory More... | |
| virtual void | invalidateCacheFor (managedMemoryChunk &chunk) |
| tells managedFileSwap that the chunk under consideration might have been changed by user and needs to be copied out freshly More... | |
| global_bytesize | getFreeDiskSpace () |
| returns free disk space at file system location specified by filemask More... | |
Static Protected Member Functions | |
| static void | sigStat (int signum) |
| returns some statistics. Typically, we will be sensitive to SIGUSR2 if compiled with -DSWAPSTATS=on More... | |
| static void * | io_submit_worker (void *ptr) |
| static void * | io_arrrive_worker (void *ptr) |
Protected Attributes | |
| bool | deleteFilesOnExit = true |
| struct iocb | aio_template |
| io_context_t | aio_context = 0 |
| unsigned int | aio_max_transactions = 10240 |
| struct io_event * | aio_eventarr |
| pthread_mutex_t | aioWaiterLock = PTHREAD_MUTEX_INITIALIZER |
| std::unordered_map< struct iocb *, pageFileLocation * > | pendingAios |
| pthread_mutex_t | io_submit_lock = PTHREAD_MUTEX_INITIALIZER |
| pthread_cond_t | io_submit_cond = PTHREAD_COND_INITIALIZER |
| unsigned int | io_submit_num_threads = 1 |
| pthread_t * | io_submit_threads |
| pthread_t | io_waiter_thread |
| pthread_t | io_arrive_thread |
| std::queue< struct iocb * > | io_submit_requests |
| bool | io_arrive_work = true |
Protected Attributes inherited from rambrain::managedSwap | |
| global_bytesize | swapSize |
| global_bytesize | swapUsed |
| global_bytesize | swapFree |
| unsigned int | totalSwapActionsQueued = 0 |
| size_t | memoryAlignment = 1 |
| swapPolicy | policy = swapPolicy::fixed |
| bool | closed = false |
Static Protected Attributes | |
| static managedFileSwap * | instance = NULL |
Private Member Functions | |
| pageFileLocation | determinePFLoc (global_offset g_offset, global_bytesize length) const |
| generate a pageFileLocation object given a global offset and a length of the data. This maps our "virtual" adress space to physical locations in a certain file More... | |
| global_offset | determineGlobalOffset (const pageFileLocation &ref) const |
| maps from physical location to "virtual" adress More... | |
| bool | openSwapFiles () |
| opens swap files according to settings More... | |
| bool | openSwapFileRange (unsigned int start, unsigned int stop) |
| opens certain range of swap files according to settings More... | |
| void | closeSwapFiles () |
| closes swap files More... | |
| void | scheduleCopy (rambrain::pageFileLocation &ref, void *ramBuf, int *tracker, bool reverse=false) |
| Schedules an elementary pageFileLocation chunk for copying (in or out) More... | |
| void | copyMem (rambrain::pageFileLocation &ref, void *ramBuf, bool reverse=false) |
| Schedules copying on level of whole managedMemoryChunks and calls scheduleCopy on the assigned parts. More... | |
| void | copyMem (void *ramBuf, rambrain::pageFileLocation &ref) |
| Convenience function for reverse copying. More... | |
| void | scheduleCopy (void *ramBuf, pageFileLocation &ref, int *parttracker) |
| Convenience function for reverse scheduling a copy. More... | |
| size_t | getMemoryAlignment () const |
| If we have any restrictions regarding memory alignment of RAM buffers(DMA), this function tells us about it. More... | |
| pageFileLocation * | pfmalloc (rambrain::global_bytesize size, rambrain::managedMemoryChunk *chunk) |
| Tries to find space in the swapFiles to write out an object of size size and returns first pageFileLocation to it. More... | |
| void | pffree (pageFileLocation *pagePtr) |
| pageFileLocation * | allocInFree (pageFileLocation *freeChunk, global_bytesize size) |
| Helper function for pfmalloc. More... | |
Private Attributes | |
| const char * | filemask |
| unsigned int | pageFileNumber |
| global_bytesize | pageFileSize |
| float | swapFileResizeFrac = .1 |
| struct swapFileDesc * | swapFiles = NULL |
| std::map< global_offset, pageFileLocation * > | free_space |
| std::map< global_offset, pageFileLocation * > | all_space |
| bool | enableDMA = false |
An implementation of managedSwap that is capable of kernel asynchronousIO.
Definition at line 107 of file managedFileSwap.h.
| rambrain::managedFileSwap::managedFileSwap | ( | global_bytesize | size, |
| const char * | filemask, | ||
| global_bytesize | oneFile = 0, |
||
| bool | enableDMA = false |
||
| ) |
Definition at line 44 of file managedFileSwap.cpp.
|
virtual |
Definition at line 113 of file managedFileSwap.cpp.
|
private |
Helper function for pfmalloc.
Definition at line 399 of file managedFileSwap.cpp.
|
protected |
deals with a single asynchronous IO event completion
Definition at line 828 of file managedFileSwap.cpp.
|
protectedvirtual |
gives this class the chance to treat incoming aio events
Reimplemented from rambrain::managedSwap.
Definition at line 767 of file managedFileSwap.cpp.
|
protectedvirtual |
throws out cached elements still in ram but also resident on disk. This makes space in situations of low swap memory
Reimplemented from rambrain::managedSwap.
Definition at line 924 of file managedFileSwap.cpp.
|
virtual |
Close the swap if not already closed.
Implements rambrain::managedSwap.
Definition at line 143 of file managedFileSwap.cpp.
|
private |
closes swap files
Definition at line 119 of file managedFileSwap.cpp.
|
protected |
called to finish a transaction when all pending aio on a managedMemoryChunk has completed
Definition at line 708 of file managedFileSwap.cpp.
|
private |
Schedules copying on level of whole managedMemoryChunks and calls scheduleCopy on the assigned parts.
| ref | the pageFileLocation the chunks data should be copied to |
| ramBuf | pointer to the managedMemoryChunk data buffer |
| reverse | copy in the other direction |
Definition at line 865 of file managedFileSwap.cpp.
|
inlineprivate |
Convenience function for reverse copying.
Definition at line 161 of file managedFileSwap.h.
|
inlineprivate |
maps from physical location to "virtual" adress
Definition at line 604 of file managedFileSwap.cpp.
|
private |
generate a pageFileLocation object given a global offset and a length of the data. This maps our "virtual" adress space to physical locations in a certain file
Definition at line 608 of file managedFileSwap.cpp.
|
virtual |
extend swap by size number of bytes
Reimplemented from rambrain::managedSwap.
Definition at line 262 of file managedFileSwap.cpp.
|
virtual |
extend swap by policy
| min_size | Minimum size the swap has to be extended before success is returned |
Reimplemented from rambrain::managedSwap.
Definition at line 207 of file managedFileSwap.cpp.
|
protected |
returns free disk space at file system location specified by filemask
Definition at line 289 of file managedFileSwap.cpp.
|
inlineprivate |
If we have any restrictions regarding memory alignment of RAM buffers(DMA), this function tells us about it.
Definition at line 170 of file managedFileSwap.h.
|
protectedvirtual |
tells managedFileSwap that the chunk under consideration might have been changed by user and needs to be copied out freshly
Reimplemented from rambrain::managedSwap.
Definition at line 947 of file managedFileSwap.cpp.
|
staticprotected |
Definition at line 682 of file managedFileSwap.cpp.
|
staticprotected |
Definition at line 655 of file managedFileSwap.cpp.
|
protected |
Definition at line 699 of file managedFileSwap.cpp.
|
private |
opens certain range of swap files according to settings
Definition at line 171 of file managedFileSwap.cpp.
|
private |
opens swap files according to settings
Definition at line 192 of file managedFileSwap.cpp.
|
private |
Definition at line 434 of file managedFileSwap.cpp.
|
private |
Tries to find space in the swapFiles to write out an object of size size and returns first pageFileLocation to it.
Priority: -Use first free chunk that fits completely -Distribute over free locations -look for read-in memory that can be overwritten -delete cached files and look again
Definition at line 306 of file managedFileSwap.cpp.
|
private |
Schedules an elementary pageFileLocation chunk for copying (in or out)
Definition at line 617 of file managedFileSwap.cpp.
|
inlineprivate |
Convenience function for reverse scheduling a copy.
Definition at line 165 of file managedFileSwap.h.
| void rambrain::managedFileSwap::setDMA | ( | bool | arg1 | ) |
Definition at line 137 of file managedFileSwap.cpp.
|
staticprotected |
returns some statistics. Typically, we will be sensitive to SIGUSR2 if compiled with -DSWAPSTATS=on
Definition at line 890 of file managedFileSwap.cpp.
|
virtual |
Mark chunk as deleted.
Implements rambrain::managedSwap.
Definition at line 504 of file managedFileSwap.cpp.
|
virtual |
Trigger swap in of the chunks pointed to by chunklist.
Implements rambrain::managedSwap.
Definition at line 539 of file managedFileSwap.cpp.
|
virtual |
Trigger swap in of the chunk pointed to by chunk.
Implements rambrain::managedSwap.
Definition at line 516 of file managedFileSwap.cpp.
|
virtual |
Trigger swap out of the chunks pointed to by chunklist.
Implements rambrain::managedSwap.
Definition at line 594 of file managedFileSwap.cpp.
|
virtual |
Trigger swap out of the chunk pointed to by chunk.
Implements rambrain::managedSwap.
Definition at line 548 of file managedFileSwap.cpp.
|
friend |
Definition at line 241 of file managedFileSwap.h.
|
friend |
Definition at line 242 of file managedFileSwap.h.
|
friend |
Definition at line 240 of file managedFileSwap.h.
|
friend |
Definition at line 243 of file managedFileSwap.h.
|
protected |
Definition at line 203 of file managedFileSwap.h.
|
protected |
Definition at line 205 of file managedFileSwap.h.
|
protected |
Definition at line 204 of file managedFileSwap.h.
|
protected |
Definition at line 202 of file managedFileSwap.h.
|
protected |
Definition at line 206 of file managedFileSwap.h.
|
private |
Definition at line 183 of file managedFileSwap.h.
|
protected |
Definition at line 188 of file managedFileSwap.h.
|
private |
Definition at line 186 of file managedFileSwap.h.
|
private |
Definition at line 141 of file managedFileSwap.h.
|
private |
Definition at line 182 of file managedFileSwap.h.
|
staticprotected |
Definition at line 210 of file managedFileSwap.h.
|
protected |
Definition at line 220 of file managedFileSwap.h.
|
protected |
Definition at line 228 of file managedFileSwap.h.
|
protected |
Definition at line 216 of file managedFileSwap.h.
|
protected |
Definition at line 215 of file managedFileSwap.h.
|
protected |
Definition at line 217 of file managedFileSwap.h.
|
protected |
Definition at line 222 of file managedFileSwap.h.
|
protected |
Definition at line 218 of file managedFileSwap.h.
|
protected |
Definition at line 219 of file managedFileSwap.h.
|
private |
Definition at line 143 of file managedFileSwap.h.
|
private |
Definition at line 144 of file managedFileSwap.h.
| const unsigned int rambrain::managedFileSwap::pageSize |
Definition at line 126 of file managedFileSwap.h.
|
protected |
Definition at line 208 of file managedFileSwap.h.
|
private |
Definition at line 147 of file managedFileSwap.h.
|
private |
Definition at line 149 of file managedFileSwap.h.