FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
parameters.h
1 #ifndef __MY_PARAMETERS_H__
2 #define __MY_PARAMETERS_H__
3 
4 /*
5  * Copyright 2014 Open Connectome Project (http://openconnecto.me)
6  * Written by Da Zheng (zhengda1936@gmail.com)
7  *
8  * This file is part of SAFSlib.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include <assert.h>
24 
25 #include <iostream>
26 #include <map>
27 #include <string>
28 #include <memory>
29 
30 #define USE_GCLOCK
31 
32 #define MIN_BLOCK_SIZE 512
33 
34 namespace safs
35 {
36 
37 class sys_parameters
38 {
39  int RAID_block_size;
40  int SA_min_cell_size;
41  int io_depth_per_file;
42  int cache_type;
43  long cache_size;
44  int RAID_mapping_option;
45  bool use_virt_aio;
46  bool verify_content;
47  bool use_flusher;
48  bool cache_large_write;
49  int vaio_print_freq;
50  int numa_num_process_threads;
51  int num_nodes;
52  bool merge_reqs;
53  int max_obj_alloc_size;
54  bool writable;
55  int max_num_pending_ios;
56  bool huge_page_enabled;
57  bool busy_wait;
58  // The number of I/O threads per NUMA node.
59  int num_io_threads;
60  // Bind a I/O thread to a specific CPU core and ensure no other threads
61  // to use this core.
62  bool bind_io_thread;
63 public:
64  sys_parameters();
65 
66  void init(const std::map<std::string, std::string> &parameters);
67 
68  void print();
69  void print_help();
70 
71  bool is_busy_wait() const {
72  return busy_wait;
73  }
74 
75  // in pages
76  int get_RAID_block_size() const {
77  return RAID_block_size;
78  }
79 
80  int get_SA_min_cell_size() const {
81  return SA_min_cell_size;
82  }
83 
84  int get_aio_depth_per_file() const {
85  return io_depth_per_file;
86  }
87 
88  int get_cache_type() const {
89  return cache_type;
90  }
91 
92  long get_cache_size() const {
93  return cache_size;
94  }
95 
96  int get_RAID_mapping_option() const {
97  return RAID_mapping_option;
98  }
99 
100  bool is_use_virt_aio() const {
101  return use_virt_aio;
102  }
103 
104  bool is_verify_content() const {
105  return verify_content;
106  }
107 
108  bool is_use_flusher() const {
109  return use_flusher;
110  }
111 
112  bool is_cache_large_write() const {
113  return cache_large_write;
114  }
115 
116  int get_vaio_print_freq() const {
117  return vaio_print_freq;
118  }
119 
120  int get_numa_num_process_threads() const {
121  return numa_num_process_threads;
122  }
123 
124  int get_num_nodes() const {
125  return num_nodes;
126  }
127 
128  bool is_merge_reqs() const {
129  return merge_reqs;
130  }
131 
132  int get_max_obj_alloc_size() const {
133  return max_obj_alloc_size;
134  }
135 
136  bool is_writable() const {
137  return writable;
138  }
139 
140  int get_max_num_pending_ios() const {
141  return max_num_pending_ios;
142  }
143 
144  bool is_huge_page_enabled() const {
145  return huge_page_enabled;
146  }
147 
148  // The number of I/O threads per NUMA node.
149  int get_num_io_threads() const {
150  return num_io_threads;
151  }
152 
153  bool is_bind_io_thread() const {
154  return bind_io_thread;
155  }
156 };
157 
158 extern sys_parameters params;
159 
160 #define AIO_DEPTH_PER_FILE params.get_aio_depth_per_file()
161 
166 #define IO_MSG_SIZE AIO_DEPTH_PER_FILE
167 
171 const int IO_QUEUE_SIZE = 10;
172 const int MAX_FETCH_REQS = 3;
173 const int AIO_COMPLETE_BUF_SIZE = 8;
174 
180 const int MAX_NUM_FLUSHES_PER_FILE = 2048;
181 
182 const int MAX_DISK_CACHED_REQS = 1000;
183 
188 const int NUM_REQS_BY_USER = 1000;
189 
193 const int MIN_NUM_ALLOC_IOVECS = 16;
194 const int NUM_EMBEDDED_IOVECS = 1;
195 
196 const int CELL_SIZE = 16;
197 const int CELL_MIN_NUM_PAGES = 8;
198 
199 const int MAX_NUM_DIRTY_CELLS_IN_QUEUE = 1000;
200 const int DIRTY_PAGES_THRESHOLD = 1;
201 const int NUM_WRITEBACK_DIRTY_PAGES = 2;
202 const int MAX_NUM_WRITEBACK = 4;
203 const int DISCARD_FLUSH_THRESHOLD = 6;
204 
205 const long MAX_CACHE_SIZE = 512L * 1024 * 1024 * 1024;
206 
207 const int NUMA_MSG_SIZE = 4096;
208 const int NUMA_REPLY_CACHE_SIZE = 50;
209 
210 const int LOCAL_BUF_SIZE = 100;
211 
212 }
213 
214 struct str2int {
215  std::string name;
216  int value;
217 };
218 
219 class str2int_map {
220  str2int *maps;
221  int num;
222 public:
223  str2int_map(str2int *maps, int num) {
224  this->maps = maps;
225  this->num = num;
226  }
227 
228  int map(const std::string &str) {
229  for (int i = 0; i < num; i++) {
230  if (maps[i].name.compare(str) == 0)
231  return i;
232  }
233  return -1;
234  }
235 
236  void print(const std::string &str) {
237  std::cout<<str;
238  for (int i = 0; i < num; i++) {
239  std::cout<<maps[i].name;
240  if (i < num - 1)
241  std::cout<<", ";
242  }
243  std::cout<<std::endl;
244  }
245 };
246 
247 #endif
const int NUM_REQS_BY_USER
Definition: parameters.h:188
const int IO_QUEUE_SIZE
Definition: parameters.h:171
const int MAX_NUM_FLUSHES_PER_FILE
Definition: parameters.h:180
const int MIN_NUM_ALLOC_IOVECS
Definition: parameters.h:193