Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
runtime-profile.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_UTIL_RUNTIME_PROFILE_H
17 #define IMPALA_UTIL_RUNTIME_PROFILE_H
18 
19 #include <boost/function.hpp>
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/thread/mutex.hpp>
22 #include <boost/unordered_map.hpp>
23 #include <iostream>
24 #include <sys/time.h>
25 #include <sys/resource.h>
26 
27 #include "common/atomic.h"
28 #include "common/logging.h"
29 #include "common/object-pool.h"
30 #include "util/thread.h"
31 #include "util/stopwatch.h"
32 #include "util/streaming-sampler.h"
33 #include "gen-cpp/RuntimeProfile_types.h"
34 
35 namespace impala {
36 
40 #define ENABLE_COUNTERS 1
41 
43 #define CONCAT_IMPL(x, y) x##y
44 #define MACRO_CONCAT(x, y) CONCAT_IMPL(x, y)
45 
46 #if ENABLE_COUNTERS
47  #define ADD_COUNTER(profile, name, unit) (profile)->AddCounter(name, unit)
48  #define ADD_TIME_SERIES_COUNTER(profile, name, src_counter) \
49  (profile)->AddTimeSeriesCounter(name, src_counter)
50  #define ADD_TIMER(profile, name) (profile)->AddCounter(name, TUnit::TIME_NS)
51  #define ADD_CHILD_TIMER(profile, name, parent) \
52  (profile)->AddCounter(name, TUnit::TIME_NS, parent)
53  #define SCOPED_TIMER(c) \
54  ScopedTimer<MonotonicStopWatch> MACRO_CONCAT(SCOPED_TIMER, __COUNTER__)(c)
55  #define COUNTER_ADD(c, v) (c)->Add(v)
56  #define COUNTER_SET(c, v) (c)->Set(v)
57  #define ADD_THREAD_COUNTERS(profile, prefix) (profile)->AddThreadCounters(prefix)
58  #define SCOPED_THREAD_COUNTER_MEASUREMENT(c) \
59  ThreadCounterMeasurement \
60  MACRO_CONCAT(SCOPED_THREAD_COUNTER_MEASUREMENT, __COUNTER__)(c)
61 #else
62  #define ADD_COUNTER(profile, name, unit) NULL
63  #define ADD_TIME_SERIES_COUNTER(profile, name, src_counter) NULL
64  #define ADD_TIMER(profile, name) NULL
65  #define ADD_CHILD_TIMER(profile, name, parent) NULL
66  #define SCOPED_TIMER(c)
67  #define COUNTER_ADD(c, v)
68  #define COUNTER_SET(c, v)
69  #define ADD_THREAD_COUNTERS(profile, prefix) NULL
70  #define SCOPED_THREAD_COUNTER_MEASUREMENT(c)
71 #endif
72 
73 class ObjectPool;
74 
84  public:
85  class Counter {
86  public:
87  Counter(TUnit::type unit, int64_t value = 0) :
88  value_(value),
89  unit_(unit) {
90  }
91  virtual ~Counter(){}
92 
93  virtual void Add(int64_t delta) {
94  value_ += delta;
95  }
96 
98  void BitOr(int64_t delta) {
99  value_ |= delta;
100  }
101 
102  virtual void Set(int64_t value) { value_ = value; }
103 
104  virtual void Set(double value) {
105  value_ = *reinterpret_cast<int64_t*>(&value);
106  }
107 
108  virtual int64_t value() const { return value_; }
109 
110  virtual double double_value() const {
111  return *reinterpret_cast<const double*>(&value_);
112  }
113 
114  TUnit::type unit() const { return unit_; }
115 
116  protected:
117  friend class RuntimeProfile;
118 
120  TUnit::type unit_;
121  };
122 
125  class HighWaterMarkCounter : public Counter {
126  public:
127  HighWaterMarkCounter(TUnit::type unit) : Counter(unit) {}
128 
129  virtual void Add(int64_t delta) {
130  int64_t new_val = current_value_.UpdateAndFetch(delta);
131  value_.UpdateMax(new_val);
132  }
133 
136  bool TryAdd(int64_t delta, int64_t max) {
137  while (true) {
138  int64_t old_val = current_value_;
139  int64_t new_val = old_val + delta;
140  if (new_val > max) return false;
141  if (LIKELY(current_value_.CompareAndSwap(old_val, new_val))) {
142  value_.UpdateMax(new_val);
143  return true;
144  }
145  }
146  }
147 
148  virtual void Set(int64_t v) {
149  current_value_ = v;
150  value_.UpdateMax(v);
151  }
152 
153  int64_t current_value() const { return current_value_; }
154 
155  private:
159  };
160 
161  typedef boost::function<int64_t ()> DerivedCounterFunction;
162 
165  class DerivedCounter : public Counter {
166  public:
167  DerivedCounter(TUnit::type unit, const DerivedCounterFunction& counter_fn)
168  : Counter(unit),
169  counter_fn_(counter_fn) {}
170 
171  virtual int64_t value() const {
172  return counter_fn_();
173  }
174 
175  private:
177  };
178 
183  class AveragedCounter : public Counter {
184  public:
185  AveragedCounter(TUnit::type unit)
186  : Counter(unit),
187  current_double_sum_(0.0),
188  current_int_sum_(0) {
189  }
190 
195  void UpdateCounter(Counter* new_counter) {
196  DCHECK_EQ(new_counter->unit_, unit_);
197  boost::unordered_map<Counter*, int64_t>::iterator it =
198  counter_value_map_.find(new_counter);
199  int64_t old_val = 0;
200  if (it != counter_value_map_.end()) {
201  old_val = it->second;
202  it->second = new_counter->value_;
203  } else {
204  counter_value_map_[new_counter] = new_counter->value();
205  }
206 
207  if (unit_ == TUnit::DOUBLE_VALUE) {
208  double old_double_val = *reinterpret_cast<double*>(&old_val);
209  current_double_sum_ += (new_counter->double_value() - old_double_val);
210  double result_val = current_double_sum_ / (double) counter_value_map_.size();
211  value_ = *reinterpret_cast<int64_t*>(&result_val);
212  } else {
213  current_int_sum_ += (new_counter->value_ - old_val);
215  }
216  }
217 
220  virtual void Set(double value) {
221  DCHECK(false);
222  }
223 
224  virtual void Set(int64_t value) {
225  DCHECK(false);
226  }
227 
228  virtual void Add(int64_t delta) {
229  DCHECK(false);
230  }
231 
232  private:
234  boost::unordered_map<Counter*, int64_t> counter_value_map_;
235 
241  };
242 
245  private:
247  friend class RuntimeProfile;
248 
249  Counter* total_time_; // total wall clock time
250  Counter* user_time_; // user CPU time
251  Counter* sys_time_; // system CPU time
252 
256 
260  };
261 
268  public:
270 
272  EventSequence(const std::vector<int64_t>& timestamps,
273  const std::vector<std::string>& labels) {
274  DCHECK(timestamps.size() == labels.size());
275  for (int i = 0; i < timestamps.size(); ++i) {
276  events_.push_back(make_pair(labels[i], timestamps[i]));
277  }
278  }
279 
281  void Start() { sw_.Start(); }
282 
286  void MarkEvent(const std::string& label) {
287  boost::lock_guard<boost::mutex> event_lock(lock_);
288  events_.push_back(make_pair(label, sw_.ElapsedTime()));
289  }
290 
291  int64_t ElapsedTime() { return sw_.ElapsedTime(); }
292 
294  typedef std::pair<std::string, int64_t> Event;
295 
297  typedef std::vector<Event> EventList;
298 
301  void GetEvents(std::vector<Event>* events) {
302  events->clear();
303  boost::lock_guard<boost::mutex> event_lock(lock_);
304  events->insert(events->end(), events_.begin(), events_.end());
305  }
306 
307  void ToThrift(TEventSequence* seq) const;
308 
309  private:
311  boost::mutex lock_;
312 
315 
318  };
319 
322  public:
323  std::string DebugString() const;
324 
325  void AddSample(int ms_elapsed) {
326  int64_t sample = sample_fn_();
327  samples_.AddSample(sample, ms_elapsed);
328  }
329 
330  private:
331  friend class RuntimeProfile;
332 
333  TimeSeriesCounter(const std::string& name, TUnit::type unit,
335  : name_(name), unit_(unit), sample_fn_(fn) {
336  }
337 
340  TimeSeriesCounter(const std::string& name, TUnit::type unit, int period,
341  const std::vector<int64_t>& values)
342  : name_(name), unit_(unit), sample_fn_(NULL), samples_(period, values) {
343  }
344 
345  void ToThrift(TTimeSeriesCounter* counter);
346 
347  std::string name_;
348  TUnit::type unit_;
351  };
352 
358  RuntimeProfile(ObjectPool* pool, const std::string& name,
359  bool is_averaged_profile = false);
360 
361  ~RuntimeProfile();
362 
365  const TRuntimeProfileTree& profiles);
366 
374  void AddChild(RuntimeProfile* child,
375  bool indent = true, RuntimeProfile* location = NULL);
376 
379  template <class Compare>
380  void SortChildren(const Compare& cmp) {
381  boost::lock_guard<boost::mutex> l(children_lock_);
382  std::sort(children_.begin(), children_.end(), cmp);
383  }
384 
390  void UpdateAverage(RuntimeProfile* src);
391 
398  void Update(const TRuntimeProfileTree& thrift_profile);
399 
405  Counter* AddCounter(const std::string& name, TUnit::type unit,
406  const std::string& parent_counter_name = "");
407 
410  HighWaterMarkCounter* AddHighWaterMarkCounter(const std::string& name,
411  TUnit::type unit, const std::string& parent_counter_name = "");
412 
418  DerivedCounter* AddDerivedCounter(const std::string& name, TUnit::type unit,
419  const DerivedCounterFunction& counter_fn,
420  const std::string& parent_counter_name = "");
421 
424  ThreadCounters* AddThreadCounters(const std::string& prefix);
425 
428  Counter* GetCounter(const std::string& name);
429 
432  void GetCounters(const std::string& name, std::vector<Counter*>* counters);
433 
436  void AddInfoString(const std::string& key, const std::string& value);
437 
442  EventSequence* AddEventSequence(const std::string& key);
443  EventSequence* AddEventSequence(const std::string& key, const TEventSequence& from);
444 
446  EventSequence* GetEventSequence(const std::string& name) const;
447 
450  const std::string* GetInfoString(const std::string& key) const;
451 
456 
457  int64_t local_time() { return local_time_ns_; }
458 
461  void PrettyPrint(std::ostream* s, const std::string& prefix="") const;
462 
465  void ToThrift(TRuntimeProfileTree* tree) const;
466  void ToThrift(std::vector<TRuntimeProfileNode>* nodes) const;
467 
472  std::string SerializeToArchiveString() const;
473  void SerializeToArchiveString(std::stringstream* out) const;
474 
476  void Divide(int n);
477 
478  void GetChildren(std::vector<RuntimeProfile*>* children);
479 
481  void GetAllChildren(std::vector<RuntimeProfile*>* children);
482 
484  int num_counters() const { return counter_map_.size(); }
485 
487  const std::string& name() const { return name_; }
488 
491  void set_name(const std::string& name) { name_ = name; }
492 
493  int64_t metadata() const { return metadata_; }
494  void set_metadata(int64_t md) { metadata_ = md; }
495 
497  static int64_t UnitsPerSecond(
498  const Counter* total_counter, const Counter* timer);
499 
501  static int64_t CounterSum(const std::vector<Counter*>* counters);
502 
508  Counter* AddRateCounter(const std::string& name, Counter* src_counter);
509 
512  Counter* AddRateCounter(const std::string& name, DerivedCounterFunction fn,
513  TUnit::type unit);
514 
522  Counter* AddSamplingCounter(const std::string& name, Counter* src_counter);
523 
525  Counter* AddSamplingCounter(const std::string& name, DerivedCounterFunction fn);
526 
529  void RegisterBucketingCounters(Counter* src_counter, std::vector<Counter*>* buckets);
530 
534  TimeSeriesCounter* AddTimeSeriesCounter(const std::string& name,
535  TUnit::type unit, DerivedCounterFunction sample_fn);
536 
540  TimeSeriesCounter* AddTimeSeriesCounter(const std::string& name, Counter* src_counter);
541 
545  void ComputeTimeInProfile();
546 
547  private:
551 
553  bool own_pool_;
554 
556  std::string name_;
557 
559  int64_t metadata_;
560 
564 
567  typedef std::map<std::string, Counter*> CounterMap;
569 
572  typedef std::map<std::string, std::set<std::string> > ChildCounterMap;
574 
576  std::set<std::vector<Counter*>* > bucketing_counters_;
577 
579  mutable boost::mutex counter_map_lock_;
580 
584  typedef std::map<std::string, RuntimeProfile*> ChildMap;
587  typedef std::vector<std::pair<RuntimeProfile*, bool> > ChildVector;
589  mutable boost::mutex children_lock_; // protects child_map_ and children_
590 
591  typedef std::map<std::string, std::string> InfoStrings;
593 
595  typedef std::vector<std::string> InfoStringsDisplayOrder;
597 
599  mutable boost::mutex info_strings_lock_;
600 
601  typedef std::map<std::string, EventSequence*> EventSequenceMap;
603  mutable boost::mutex event_sequence_lock_;
604 
605  typedef std::map<std::string, TimeSeriesCounter*> TimeSeriesCounterMap;
607  mutable boost::mutex time_series_counter_map_lock_;
608 
610 
614 
619 
623 
626  int64_t local_time_ns_;
627 
630  void Update(const std::vector<TRuntimeProfileNode>& nodes, int* idx);
631 
635  void ComputeTimeInProfile(int64_t total_time);
636 
638  static const std::string TOTAL_TIME_COUNTER_NAME;
639  static const std::string INACTIVE_TIME_COUNTER_NAME;
640  static const std::string ASYNC_TIME_COUNTER_NAME;
641 
645  const std::vector<TRuntimeProfileNode>& nodes, int* node_idx);
646 
648  static void PrintChildCounters(const std::string& prefix,
649  const std::string& counter_name, const CounterMap& counter_map,
650  const ChildCounterMap& child_counter_map, std::ostream* s);
651 };
652 
654 class ScopedEvent {
655  public:
656  ScopedEvent(RuntimeProfile::EventSequence* event_sequence, const std::string& label)
657  : label_(label),
658  event_sequence_(event_sequence) {
659  }
660 
664  }
665 
666  private:
668  ScopedEvent(const ScopedEvent& event);
669  ScopedEvent& operator=(const ScopedEvent& event);
670 
671  const std::string label_;
673 };
674 
679  public:
680  ScopedCounter(RuntimeProfile::Counter* counter, int64_t val) :
681  val_(val),
682  counter_(counter) {
683  if (counter == NULL) return;
684  counter_->Add(-1L * val_);
685  }
686 
689  if (counter_ != NULL) counter_->Add(val_);
690  }
691 
692  private:
694  ScopedCounter(const ScopedCounter& counter);
695  ScopedCounter& operator=(const ScopedCounter& counter);
696 
697  int64_t val_;
699 };
700 
704 template<class T>
705 class ScopedTimer {
706  public:
708  counter_(counter) {
709  if (counter == NULL) return;
710  DCHECK(counter->unit() == TUnit::TIME_NS);
711  sw_.Start();
712  }
713 
714  void Stop() { sw_.Stop(); }
715  void Start() { sw_.Start(); }
716 
717  void UpdateCounter() {
718  if (counter_ != NULL) {
719  counter_->Add(sw_.ElapsedTime());
720  }
721  }
722 
724  void ReleaseCounter() {
725  UpdateCounter();
726  counter_ = NULL;
727  }
728 
731  sw_.Stop();
732  UpdateCounter();
733  }
734 
735  private:
737  ScopedTimer(const ScopedTimer& timer);
738  ScopedTimer& operator=(const ScopedTimer& timer);
739 
740  T sw_;
742 };
743 
748  public:
750  stop_(false), counters_(counters) {
751  DCHECK(counters != NULL);
752  sw_.Start();
753  int ret = getrusage(RUSAGE_THREAD, &usage_base_);
754  DCHECK_EQ(ret, 0);
755  }
756 
758  void Stop() {
759  if (stop_) return;
760  stop_ = true;
761  sw_.Stop();
762  rusage usage;
763  int ret = getrusage(RUSAGE_THREAD, &usage);
764  DCHECK_EQ(ret, 0);
765  int64_t utime_diff =
766  (usage.ru_utime.tv_sec - usage_base_.ru_utime.tv_sec) * 1000L * 1000L * 1000L +
767  (usage.ru_utime.tv_usec - usage_base_.ru_utime.tv_usec) * 1000L;
768  int64_t stime_diff =
769  (usage.ru_stime.tv_sec - usage_base_.ru_stime.tv_sec) * 1000L * 1000L * 1000L +
770  (usage.ru_stime.tv_usec - usage_base_.ru_stime.tv_usec) * 1000L;
772  counters_->user_time_->Add(utime_diff);
773  counters_->sys_time_->Add(stime_diff);
774  counters_->voluntary_context_switches_->Add(usage.ru_nvcsw - usage_base_.ru_nvcsw);
776  usage.ru_nivcsw - usage_base_.ru_nivcsw);
777  }
778 
781  Stop();
782  }
783 
784  private:
788 
789  bool stop_;
790  rusage usage_base_;
793 };
794 
795 }
796 
797 #endif
T UpdateAndFetch(T delta)
Increments by delta (i.e. += delta) and returns the new val.
Definition: atomic.h:105
Counter * AddCounter(const std::string &name, TUnit::type unit, const std::string &parent_counter_name="")
boost::unordered_map< Counter *, int64_t > counter_value_map_
Map from counters to their existing values. Modified via UpdateCounter().
virtual int64_t value() const
void GetEvents(std::vector< Event > *events)
DerivedCounter * AddDerivedCounter(const std::string &name, TUnit::type unit, const DerivedCounterFunction &counter_fn, const std::string &parent_counter_name="")
EventSequence * AddEventSequence(const std::string &key)
ChildCounterMap child_counter_map_
DerivedCounter(TUnit::type unit, const DerivedCounterFunction &counter_fn)
void set_metadata(int64_t md)
TimeSeriesCounter(const std::string &name, TUnit::type unit, DerivedCounterFunction fn)
A set of counters that measure thread info, such as total time, user time, sys time.
void SortChildren(const Compare &cmp)
ScopedTimer(RuntimeProfile::Counter *counter)
Counter * AddSamplingCounter(const std::string &name, Counter *src_counter)
virtual double double_value() const
void AddInfoString(const std::string &key, const std::string &value)
client RuntimeProfile::EventSequence * events
Definition: coordinator.h:64
std::map< std::string, RuntimeProfile * > ChildMap
std::string SerializeToArchiveString() const
boost::mutex event_sequence_lock_
static RuntimeProfile * CreateFromThrift(ObjectPool *pool, const TRuntimeProfileTree &profiles)
Deserialize from thrift. Runtime profiles are allocated from the pool.
std::map< std::string, std::set< std::string > > ChildCounterMap
std::pair< std::string, int64_t > Event
An Event is a <label, timestamp> pair.
RuntimeProfile(ObjectPool *pool, const std::string &name, bool is_averaged_profile=false)
void RegisterBucketingCounters(Counter *src_counter, std::vector< Counter * > *buckets)
std::string name_
Name for this runtime profile.
void GetCounters(const std::string &name, std::vector< Counter * > *counters)
EventSequenceMap event_sequence_map_
boost::function< int64_t()> DerivedCounterFunction
std::map< std::string, Counter * > CounterMap
RuntimeProfile::Counter * counter_
bool TryAdd(int64_t delta, int64_t max)
Counter * AddRateCounter(const std::string &name, Counter *src_counter)
static int64_t UnitsPerSecond(const Counter *total_counter, const Counter *timer)
Derived counter function: return measured throughput as input_value/second.
void UpdateMax(T value)
Updates the int to 'value' if value is larger.
Definition: atomic.h:115
std::map< std::string, TimeSeriesCounter * > TimeSeriesCounterMap
int num_counters() const
Returns the number of counters in this profile.
void UpdateCounter(Counter *new_counter)
virtual void Set(double value)
virtual void Set(int64_t value)
std::vector< std::string > InfoStringsDisplayOrder
Keeps track of the order in which InfoStrings are displayed when printed.
boost::mutex time_series_counter_map_lock_
StreamingSampler< int64_t, 64 > StreamingCounterSampler
EventSequence * GetEventSequence(const std::string &name) const
Returns event sequence with the provided name if it exists, otherwise NULL.
static int64_t CounterSum(const std::vector< Counter * > *counters)
Derived counter function: return aggregated value.
void ToThrift(TTimeSeriesCounter *counter)
void Stop()
Stop and update the counter.
void UpdateAverage(RuntimeProfile *src)
void MarkEvent(const std::string &label)
void Divide(int n)
Divides all counters by n.
bool CompareAndSwap(T old_val, T new_val)
Returns true if the atomic compare-and-swap was successful.
Definition: atomic.h:131
bool own_pool_
True if we have to delete the pool_ on destruction.
std::map< std::string, EventSequence * > EventSequenceMap
ScopedCounter & operator=(const ScopedCounter &counter)
~ScopedCounter()
Increment the counter when object is destroyed.
static const std::string ASYNC_TIME_COUNTER_NAME
MonotonicStopWatch sw_
Timer which allows events to be timestamped when they are recorded.
void Start()
Starts the timer without resetting it.
ScopedEvent & operator=(const ScopedEvent &event)
ThreadCounters * AddThreadCounters(const std::string &prefix)
ThreadCounterMeasurement(RuntimeProfile::ThreadCounters *counters)
ScopedCounter(RuntimeProfile::Counter *counter, int64_t val)
ObjectPool pool
boost::mutex lock_
Protect access to events_.
~ThreadCounterMeasurement()
Update counter when object is destroyed.
uint64_t ElapsedTime() const
Returns time in nanosecond.
Definition: stopwatch.h:105
RuntimeProfile::ThreadCounters * counters_
RuntimeProfile::EventSequence * event_sequence_
void Update(const TRuntimeProfileTree &thrift_profile)
void ToThrift(TEventSequence *seq) const
int64_t metadata() const
std::vector< Event > EventList
An EventList is a sequence of Events, in increasing timestamp order.
std::set< std::vector< Counter * > * > bucketing_counters_
A set of bucket counters registered in this runtime profile.
TimeSeriesCounter * AddTimeSeriesCounter(const std::string &name, TUnit::type unit, DerivedCounterFunction sample_fn)
static void PrintChildCounters(const std::string &prefix, const std::string &counter_name, const CounterMap &counter_map, const ChildCounterMap &child_counter_map, std::ostream *s)
Print the child counters of the given counter name.
std::vector< std::pair< RuntimeProfile *, bool > > ChildVector
vector of (profile, indentation flag)
int64_t metadata_
user-supplied, uninterpreted metadata.
const std::string label_
HighWaterMarkCounter * AddHighWaterMarkCounter(const std::string &name, TUnit::type unit, const std::string &parent_counter_name="")
ThreadCounterMeasurement & operator=(const ThreadCounterMeasurement &timer)
Counter(TUnit::type unit, int64_t value=0)
~ScopedTimer()
Update counter when object is destroyed.
~ScopedEvent()
Mark the event when the object is destroyed.
Counter * GetCounter(const std::string &name)
TimeSeriesCounter(const std::string &name, TUnit::type unit, int period, const std::vector< int64_t > &values)
#define LIKELY(expr)
Definition: compiler-util.h:32
void PrettyPrint(std::ostream *s, const std::string &prefix="") const
RuntimeProfile::Counter * counter_
Utility class to mark an event when the object is destroyed.
ScopedTimer & operator=(const ScopedTimer &timer)
boost::mutex counter_map_lock_
protects counter_map_, counter_child_map_ and bucketing_counters_
ScopedEvent(RuntimeProfile::EventSequence *event_sequence, const std::string &label)
TimeSeriesCounterMap time_series_counter_map_
static const std::string INACTIVE_TIME_COUNTER_NAME
InfoStringsDisplayOrder info_strings_display_order_
EventSequence(const std::vector< int64_t > &timestamps, const std::vector< std::string > &labels)
Helper constructor for building from Thrift.
EventList events_
Stored in increasing time order.
std::map< std::string, std::string > InfoStrings
void AddSample(T sample, int ms)
virtual void Add(int64_t delta)
static const std::string TOTAL_TIME_COUNTER_NAME
Name of the counter maintaining the total time.
void AddChild(RuntimeProfile *child, bool indent=true, RuntimeProfile *location=NULL)
const std::string & name() const
Returns name of this profile.
const std::string * GetInfoString(const std::string &key) const
void GetChildren(std::vector< RuntimeProfile * > *children)
boost::mutex info_strings_lock_
Protects info_strings_ and info_strings_display_order_.
void ReleaseCounter()
Updates the underlying counter for the final time and clears the pointer to it.
void BitOr(int64_t delta)
Use this to update if the counter is a bitmap.
void set_name(const std::string &name)
void GetAllChildren(std::vector< RuntimeProfile * > *children)
Gets all profiles in tree, including this one.
void ToThrift(TRuntimeProfileTree *tree) const
Counter * total_time_counter()
Returns the counter for the total elapsed time.