]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/TrackedOp: use preallocated vector for events
authorSage Weil <sage@redhat.com>
Thu, 15 Dec 2016 23:25:20 +0000 (18:25 -0500)
committerSage Weil <sage@redhat.com>
Fri, 27 Jan 2017 15:30:44 +0000 (10:30 -0500)
This avoids an allocation per mark_event() call.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/TrackedOp.h

index df1a8bea3569270322f9e1812d573d525c3fffe2..8dda99c65623b7d1ef17c1794e41e1a9c4ba0886 100644 (file)
@@ -25,6 +25,8 @@
 #include "include/memory.h"
 #include "common/RWLock.h"
 
+#define OPTRACKER_PREALLOC_EVENTS 20
+
 class TrackedOp;
 typedef boost::intrusive_ptr<TrackedOp> TrackedOpRef;
 
@@ -173,7 +175,7 @@ protected:
     }
   };
 
-  list<Event> events; /// list of events and their times
+  vector<Event> 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 {}