From 370d53a0c6f00a5cce80cdcf89a93a5871b1315a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Dec 2016 18:25:20 -0500 Subject: [PATCH] common/TrackedOp: use preallocated vector for events This avoids an allocation per mark_event() call. Signed-off-by: Sage Weil --- src/common/TrackedOp.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index df1a8bea35692..8dda99c65623b 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 {} -- 2.39.5