11 #ifndef WRENCH_MEMORYMANAGER_H
12 #define WRENCH_MEMORYMANAGER_H
15 #include <wrench/services/Service.h>
16 #include <wrench/simulation/Simulation.h>
34 simgrid::s4u::Disk *memory;
38 std::vector<Block *> inactive_list;
39 std::vector<Block *> active_list;
47 std::vector<double> time_log;
48 std::vector<double> dirty_log;
49 std::vector<double> cached_log;
50 std::vector<double> free_log;
53 MemoryManager(simgrid::s4u::Disk *memory,
double dirty_ratio,
int interval,
int expired_time, std::string
hostname);
57 void balanceLruLists();
61 double flushExpiredData(std::vector<Block *> &list);
63 double flushLruList(std::vector<Block *> &list,
double amount, std::string excluded_filename);
65 double evictLruList(std::vector<Block *> &lru_list,
double amount, std::string excluded_filename);
70 double dirty_ratio,
int interval,
int expired_time,
77 void setMemory(simgrid::s4u::Disk *memory);
99 double flush(
double amount, std::string excluded_filename);
101 double evict(
double amount, std::string excluded_filename);
103 simgrid::s4u::IoPtr
readToCache(std::string filename, std::shared_ptr<FileLocation> location,
104 double amount,
bool async);
108 void writebackToCache(std::string filename, std::shared_ptr<FileLocation> location,
double amount,
bool is_dirty);
110 void addToCache(std::string filename, std::shared_ptr<FileLocation> location,
double amount,
bool is_dirty);
116 static simgrid::s4u::Disk *
getDisk(std::string mountpoint, std::string
hostname);
129 #endif //WRENCH_MEMORYMANAGER_H
simgrid::s4u::IoPtr readToCache(std::string filename, std::shared_ptr< FileLocation > location, double amount, bool async)
Read data from disk to cache.
Definition: MemoryManager.cpp:396
static simgrid::s4u::Disk * getDisk(std::string mountpoint, std::string hostname)
Retrieve the disk where the file is stored.
Definition: MemoryManager.cpp:666
double getDirty() const
Get number of dirty bytes.
Definition: MemoryManager.cpp:163
A class that implemnets a MemoryManager service to simulate Linux in-memory page caching for I/O oper...
Definition: MemoryManager.h:29
void addToCache(std::string filename, std::shared_ptr< FileLocation > location, double amount, bool is_dirty)
Add a file to cache.
Definition: MemoryManager.cpp:541
std::vector< Block * > getCachedBlocks(std::string filename)
Get list of cached blocks of a file.
Definition: MemoryManager.cpp:640
double flush(double amount, std::string excluded_filename)
Flush dirty data from cache.
Definition: MemoryManager.cpp:261
void readChunkFromCache(std::string filename, double amount)
Simulate a read from cache, re-access and update cached file data.
Definition: MemoryManager.cpp:419
void writebackToCache(std::string filename, std::shared_ptr< FileLocation > location, double amount, bool is_dirty)
Simulate a file write to cache.
Definition: MemoryManager.cpp:526
simgrid::s4u::Disk * getMemory() const
Get the memory disk.
Definition: MemoryManager.cpp:97
void export_log(std::string filename)
Export the log to a file.
Definition: MemoryManager.cpp:701
double getFreeMemory() const
Get the amount of free memory.
Definition: MemoryManager.cpp:129
double getDirtyRatio() const
Get the dirty ratio.
Definition: MemoryManager.cpp:113
static std::shared_ptr< MemoryManager > initAndStart(Simulation *simulation, simgrid::s4u::Disk *memory, double dirty_ratio, int interval, int expired_time, std::string hostname)
Initialize and start the memory_manager_service manager.
Definition: MemoryManager.cpp:52
double getAvailableMemory()
Get currently available cache memory.
Definition: MemoryManager.cpp:183
void kill()
Immediately terminate periodical flushing.
Definition: MemoryManager.cpp:89
void setMemory(simgrid::s4u::Disk *memory)
Set the memory disk.
Definition: MemoryManager.cpp:105
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
double evict(double amount, std::string excluded_filename)
Evicted clean data from page cache.
Definition: MemoryManager.cpp:333
void releaseMemory(double released_amt)
Release memory.
Definition: MemoryManager.cpp:137
double getCachedAmount(std::string filename)
Get amount of cached data of a file in cache.
Definition: MemoryManager.cpp:616
double getTotalMemory()
Get total available cache memory.
Definition: MemoryManager.cpp:191
void setDirtyRatio(double dirty_ratio)
Set the dirty ratio.
Definition: MemoryManager.cpp:121
A service that can be added to the simulation and that can be used by a WMS when executing a workflow...
Definition: Service.h:26
void useAnonymousMemory(double used_amt)
Update the amount of used memory.
Definition: MemoryManager.cpp:146
void log()
Append to the log.
Definition: MemoryManager.cpp:690
double getTotalCachedAmount() const
Get total number of cached bytes.
Definition: MemoryManager.cpp:155
double getEvictableMemory()
Get current evictable memory.
Definition: MemoryManager.cpp:171
Simulation * simulation
a pointer to the simulation object
Definition: S4U_Daemon.h:105