Skip to content

Commit

Permalink
rgw: reduce calls to rgw_obj.set_obj()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
yehudasa committed Jun 6, 2014
1 parent 0b35e61 commit 524a155
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/rgw/rgw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1083,10 +1083,13 @@ class rgw_obj {
}

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;
Expand Down
33 changes: 31 additions & 2 deletions src/rgw/rgw_rados.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,15 @@ class RGWObjManifest {
}
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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 524a155

Please sign in to comment.