]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: reduce calls to rgw_obj.set_obj() 1863/head
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 25 Mar 2014 21:08:01 +0000 (14:08 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 6 Jun 2014 01:53:14 +0000 (18:53 -0700)
default manifest iterator construction did unneeded init of rgw_obj.
Also add a smarter copy constructor to RGWObjState that does not copy
manifest if not needed.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_common.h
src/rgw/rgw_rados.h

index 9550072af7a0f6e08306c66e48b49da3becabd68..eb5b3e3122d4601cac32d53cffab71529093ccd6 100644 (file)
@@ -1083,10 +1083,13 @@ public:
   }
 
   void set_obj(const string& o) {
+    object.reserve(128);
+
     orig_obj = o;
     if (ns.empty()) {
-      if (o.empty())
+      if (o.empty()) {
         return;
+      }
       if (o.size() < 1 || o[0] != '_') {
         object = o;
         return;
index 9ff5f3d2eaeea99d9a8e65d8d0af7b18266260bb..6af5568df91a579ec645d31e35ca57093934ecf2 100644 (file)
@@ -393,11 +393,15 @@ public:
     }
     obj_iterator(RGWObjManifest *_m) : manifest(_m) {
       init();
-      seek(0);
+      if (!manifest->empty()) {
+        seek(0);
+      }
     }
     obj_iterator(RGWObjManifest *_m, uint64_t _ofs) : manifest(_m) {
       init();
-      seek(_ofs);
+      if (!manifest->empty()) {
+        seek(_ofs);
+      }
     }
     void seek(uint64_t ofs);
 
@@ -675,6 +679,31 @@ struct RGWObjState {
   RGWObjState() : is_atomic(false), has_attrs(0), exists(false),
                   size(0), mtime(0), epoch(0), fake_tag(false), has_manifest(false),
                   has_data(false), prefetch_data(false), keep_tail(false) {}
+  RGWObjState(const RGWObjState& rhs) {
+    is_atomic = rhs.is_atomic;
+    has_attrs = rhs.has_attrs;
+    exists = rhs.exists;
+    size = rhs.size;
+    mtime = rhs.mtime;
+    epoch = rhs.epoch;
+    if (rhs.obj_tag.length()) {
+      obj_tag = rhs.obj_tag;
+    }
+    write_tag = rhs.write_tag;
+    fake_tag = rhs.fake_tag;
+    if (rhs.has_manifest) {
+      manifest = rhs.manifest;
+    }
+    has_manifest = rhs.has_manifest;
+    shadow_obj = rhs.shadow_obj;
+    has_data = rhs.has_data;
+    if (rhs.data.length()) {
+      data = rhs.data;
+    }
+    prefetch_data = rhs.prefetch_data;
+    keep_tail = rhs.keep_tail;
+    objv_tracker = rhs.objv_tracker;
+  }
 
   bool get_attr(string name, bufferlist& dest) {
     map<string, bufferlist>::iterator iter = attrset.find(name);