11 #ifndef WRENCH_MEMORYMANAGER_H
12 #define WRENCH_MEMORYMANAGER_H
15 #include "wrench/services/Service.h"
16 #include "wrench/simulation/Simulation.h"
29 class MemoryManager :
public Service {
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);
69 static std::shared_ptr<MemoryManager> initAndStart(Simulation *simulation, simgrid::s4u::Disk *memory,
70 double dirty_ratio,
int interval,
int expired_time,
71 std::string hostname);
75 simgrid::s4u::Disk *getMemory()
const;
77 void setMemory(simgrid::s4u::Disk *memory);
79 double getDirtyRatio()
const;
81 void setDirtyRatio(
double dirty_ratio);
83 double getFreeMemory()
const;
85 void releaseMemory(
double released_amt);
87 void useAnonymousMemory(
double used_amt);
89 double getTotalCachedAmount()
const;
91 double getDirty()
const;
93 double getEvictableMemory();
95 double getAvailableMemory();
97 double getTotalMemory();
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);
106 void readChunkFromCache(std::string filename,
double amount);
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);
112 double getCachedAmount(std::string filename);
114 std::vector<Block*> getCachedBlocks(std::string filename);
116 static simgrid::s4u::Disk *getDisk(std::string mountpoint, std::string hostname);
120 void export_log(std::string filename);
129 #endif //WRENCH_MEMORYMANAGER_H