HavoqGT
cache_utilities.hpp File Reference
#include <sys/mman.h>
#include <unistd.h>
Include dependency graph for cache_utilities.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DIRTY_THRESHOLD_GB   70
 

Functions

template<typename Vector >
char * get_address (Vector &vec)
 
template<typename Vector >
size_t get_length (Vector &vec)
 
template<typename Vector >
void advise_vector_rand (Vector &vec)
 
template<typename Vector >
void flush_advise_vector_dont_need (Vector &vec)
 
template<typename Vector >
void flush_vector (Vector &vec)
 
template<typename Vector >
void flush_advise_vector (Vector &vec)
 
uint32_t get_disk_utilization ()
 
void print_system_info (bool print_dimmap)
 
void print_dmesg ()
 
uint32_t get_dirty_pages ()
 
bool check_dirty_pages ()
 
void get_io_stat_info (int &r, int &w)
 

Macro Definition Documentation

#define DIRTY_THRESHOLD_GB   70

Definition at line 127 of file cache_utilities.hpp.

Function Documentation

template<typename Vector >
void advise_vector_rand ( Vector &  vec)

Definition at line 76 of file cache_utilities.hpp.

76  {
77  char * addr = get_address(vec);
78  size_t length = get_length(vec);
79 
80  int t = madvise(addr, length, MADV_RANDOM);
81  assert(t == 0);
82 }
size_t get_length(Vector &vec)
char * get_address(Vector &vec)

Here is the call graph for this function:

bool check_dirty_pages ( )

Definition at line 209 of file cache_utilities.hpp.

209  {
210  uint32_t dirty_kb = get_dirty_pages();
211  const uint32_t dirty_threshold_kb = DIRTY_THRESHOLD_GB * 1000000;
212  return (dirty_kb > dirty_threshold_kb);
213 }
uint32_t get_dirty_pages()
#define DIRTY_THRESHOLD_GB

Here is the call graph for this function:

template<typename Vector >
void flush_advise_vector ( Vector &  vec)

Definition at line 111 of file cache_utilities.hpp.

111  {
112  char * addr = get_address(vec);
113  size_t length = get_length(vec);
114 
115  int t = msync(addr, length, MS_SYNC);
116  if (t == 0) {
117  int t2 = madvise(addr, length, MADV_DONTNEED);
118  assert(t2 == 0);
119  t2 = madvise(addr, length, MADV_RANDOM);
120  assert(t2 == 0);
121  } else {
122  assert(t == 0);
123  }
124 }
size_t get_length(Vector &vec)
char * get_address(Vector &vec)

Here is the call graph for this function:

template<typename Vector >
void flush_advise_vector_dont_need ( Vector &  vec)

Definition at line 86 of file cache_utilities.hpp.

86  {
87  char * addr = get_address(vec);
88  size_t length = get_length(vec);
89 
90  int t = msync(addr, length, MS_SYNC);
91  if (t == 0) {
92  int t2 = madvise(addr, length, MADV_DONTNEED);
93  assert(t2 == 0);
94  } else {
95  assert(t == 0);
96  }
97 
98 }
size_t get_length(Vector &vec)
char * get_address(Vector &vec)

Here is the call graph for this function:

template<typename Vector >
void flush_vector ( Vector &  vec)

Definition at line 102 of file cache_utilities.hpp.

102  {
103  char * addr = get_address(vec);
104  size_t length = get_length(vec);
105 
106  int t = msync(addr, length, MS_SYNC);
107  assert(t == 0);
108 }
size_t get_length(Vector &vec)
char * get_address(Vector &vec)

Here is the call graph for this function:

template<typename Vector >
char* get_address ( Vector &  vec)

Definition at line 60 of file cache_utilities.hpp.

60  {
61  uintptr_t temp = reinterpret_cast<uintptr_t>(&(vec[0]));
62  temp -= temp % 4096;
63  return reinterpret_cast<char *>(temp);
64 }

Here is the caller graph for this function:

uint32_t get_dirty_pages ( )

Definition at line 198 of file cache_utilities.hpp.

198  {
199  uint32_t dirty_kb;
200 
201  //FILE *pipe;
202  //pipe = popen("grep Dirty /proc/meminfo | awk '{print $2}'", "r" );
203  //fscanf(pipe, "%u", &dirty_kb);
204  //pclose(pipe);
205 
206  return dirty_kb;
207 }

Here is the caller graph for this function:

uint32_t get_disk_utilization ( )

Definition at line 130 of file cache_utilities.hpp.

130  {
131  uint32_t dirty_kb;
132 
133  //FILE *pipe;
134  //pipe = popen("df -h /l/ssd | grep /dev/md0 | awk '{print $3}'", "r" );
135  //fscanf(pipe, "%u", &dirty_kb);
136  //pclose(pipe);
137 
138  return dirty_kb;
139 }

Here is the caller graph for this function:

void get_io_stat_info ( int &  r,
int &  w 
)

Definition at line 216 of file cache_utilities.hpp.

216  {
217  //FILE *pipe;
218  //char str[250];
219  //pipe = popen("iostat -m | grep md0 2>&1 | awk '{printf \"%d %d\\n\" , $5, $6}'", "r" );
220 
221  //fscanf(pipe, "%d %d", &r, &w);
222  //pclose(pipe);
223 };

Here is the caller graph for this function:

template<typename Vector >
size_t get_length ( Vector &  vec)

Definition at line 68 of file cache_utilities.hpp.

68  {
69  size_t length = vec.size() * sizeof(vec[0]);
70  length += (4096 - length%4096);
71  return length;
72 }

Here is the caller graph for this function:

void print_dmesg ( )

Definition at line 188 of file cache_utilities.hpp.

188  {
189  printf("\n-----------------------------------------------------------------\n");
190  printf("dmesg\n");
191  printf("-----------------------------------------------------------------\n");
192 
193  system("dmesg");
194 
195  printf("\n\n");
196 }
void print_system_info ( bool  print_dimmap)

Definition at line 141 of file cache_utilities.hpp.

141  {
142  printf("#################################################################\n");
143  printf("System Information\n");
144  printf("#################################################################\n");
145 
146 
147  printf("\n-----------------------------------------------------------------\n");
148  system("echo \"SLURM_NODELIST = $SLURM_NODELIST \"");
149  printf("-----------------------------------------------------------------\n");
150 
151  printf("\n-----------------------------------------------------------------\n");
152  printf("Tuned Info:\n");
153  printf("-----------------------------------------------------------------\n");
154  system("echo \"/proc/sys/vm/dirty_ratio = $(cat /proc/sys/vm/dirty_ratio)\"");
155  system("echo \"/proc/sys/vm/dirty_background_ratio = $(cat /proc/sys/vm/dirty_background_ratio)\"");
156  system("echo \"/proc/sys/vm/dirty_expire_centisecs = $(cat /proc/sys/vm/dirty_expire_centisecs)\"");
157 
158  printf("\n-----------------------------------------------------------------\n");
159  printf("df -h /l/ssd\n");
160  printf("-----------------------------------------------------------------\n");
161  system("df -h /l/ssd");
162 
163  printf("\n-----------------------------------------------------------------\n");
164  printf("ls /l/ssd\n");
165  printf("-----------------------------------------------------------------\n");
166  system("ls /l/ssd");
167 
168 
169  printf("\n-----------------------------------------------------------------\n");
170  printf("io-stat -m | grep md0 2>&1\n");
171  printf("-----------------------------------------------------------------\n");
172  system("iostat -m | grep Device 2>&1");
173  system("iostat -m | grep md0 2>&1");
174 
175 
176  if (print_dimmap) {
177  printf("\n-----------------------------------------------------------------\n");
178  system("echo \"/proc/di-mmap-runtimeA-stats = $(cat /proc/di-mmap-runtimeA-stats)\"");
179  printf("-----------------------------------------------------------------\n");
180  }
181 
182 
183 
184  printf("\n\n");
185 
186 }