From: Sage Weil Date: Thu, 15 Dec 2016 23:25:20 +0000 (-0500) Subject: common/TrackedOp: use preallocated vector for events X-Git-Tag: v12.0.0~45^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=370d53a0c6f00a5cce80cdcf89a93a5871b1315a;p=ceph-ci.git common/TrackedOp: use preallocated vector for events This avoids an allocation per mark_event() call. Signed-off-by: Sage Weil --- diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index df1a8bea356..8dda99c6562 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -25,6 +25,8 @@ #include "include/memory.h" #include "common/RWLock.h" +#define OPTRACKER_PREALLOC_EVENTS 20 + class TrackedOp; typedef boost::intrusive_ptr TrackedOpRef; @@ -173,7 +175,7 @@ protected: } }; - list events; /// list of events and their times + vector events; /// list of events and their times mutable Mutex lock; /// to protect the events list string current; /// the current state the event is in uint64_t seq; /// a unique value set by the OpTracker @@ -193,7 +195,9 @@ protected: lock("TrackedOp::lock"), seq(0), warn_interval_multiplier(1) - { } + { + events.reserve(OPTRACKER_PREALLOC_EVENTS); + } /// output any type-specific data you want to get when dump() is called virtual void _dump(Formatter *f) const {}