24 #ifndef GRAPHLAB_DISTRIBUTED_EVENT_LOG_HPP
25 #define GRAPHLAB_DISTRIBUTED_EVENT_LOG_HPP
29 #include <boost/bind.hpp>
30 #include <boost/function.hpp>
31 #include <graphlab/parallel/pthread_tools.hpp>
32 #include <graphlab/parallel/atomic.hpp>
33 #include <graphlab/util/timer.hpp>
34 #include <graphlab/util/dense_bitset.hpp>
35 #include <graphlab/util/stl_util.hpp>
43 class distributed_control;
47 const size_t MAX_LOG_SIZE = 256;
48 const size_t MAX_LOG_THREADS = 1024;
49 const double TICK_FREQUENCY = 0.5;
50 const double RECORD_FREQUENCY = 5.0;
60 explicit log_entry(
double value = 0): value(value) { }
87 boost::function<double(void)> callback;
89 size_t sum_of_instantaneous_entries;
90 size_t count_of_instantaneous_entries;
92 bool machine_log_modified;
93 size_t earliest_modified_log;
96 std::vector<std::vector<log_entry> >
machine;
116 class distributed_event_logger {
130 mutex log_entry_lock;
140 mutex thread_local_count_lock;
146 size_t allocate_log_entry(
log_group* group);
156 void rpc_collect_log(
size_t srcproc,
size_t record_ctr,
157 std::vector<double> srccounts);
159 void collect_instantaneous_log();
164 void local_collect_log(
size_t record_ctr);
167 void build_aggregate_log();
169 mutex periodic_timer_lock;
171 bool periodic_timer_stop;
176 void periodic_timer();
178 distributed_event_logger();
181 void destroy_event_logger();
197 size_t create_log_entry(std::string name, std::string units,
198 log_type::log_type_enum logtype);
209 size_t create_callback_entry(std::string name,
211 boost::function<
double(
void)> callback,
212 log_type::log_type_enum logtype);
214 void free_callback_entry(
size_t entry);
219 void thr_inc_log_entry(
size_t entry,
size_t value);
224 void thr_dec_log_entry(
size_t entry,
size_t value);
228 inline double get_current_time()
const {
229 return ti.current_time();
232 inline log_group** get_logs_ptr() {
236 inline fixed_dense_bitset<MAX_LOG_SIZE>& get_logs_bitset() {
237 return has_log_entry;
245 extern distributed_event_logger& get_event_log();
249 #define DECLARE_EVENT(name) size_t name;
251 #define INITIALIZE_EVENT_LOG(dc) graphlab::get_event_log().set_dc(dc);
252 #define ADD_CUMULATIVE_EVENT(name, desc, units) \
253 name = graphlab::get_event_log().create_log_entry(desc, units, graphlab::log_type::CUMULATIVE);
255 #define ADD_INSTANTANEOUS_EVENT(name, desc, units) \
256 name = graphlab::get_event_log().create_log_entry(desc, units, graphlab::log_type::INSTANTANEOUS);
258 #define ADD_CUMULATIVE_CALLBACK_EVENT(name, desc, units, callback) \
259 name = graphlab::get_event_log().create_callback_entry(desc, units, callback, \
260 graphlab::log_type::CUMULATIVE);
263 #define ADD_INSTANTANEOUS_CALLBACK_EVENT(name, desc, units, callback) \
264 name = graphlab::get_event_log().create_callback_entry(desc, units, callback, \
265 graphlab::log_type::INSTANTANEOUS);
269 #define FREE_CALLBACK_EVENT(name) \
270 graphlab::get_event_log().free_callback_entry(name);
272 #define INCREMENT_EVENT(name, count) graphlab::get_event_log().thr_inc_log_entry(name, count);
273 #define DECREMENT_EVENT(name, count) graphlab::get_event_log().thr_dec_log_entry(name, count);