From: Haomai Wang Date: Mon, 14 Jul 2014 06:32:57 +0000 (+0800) Subject: Reduce ObjectCacher flush overhead X-Git-Tag: v0.84~55^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b8a56685fec2de0f0a49fa75c9e95a19d5cf97f9;p=ceph.git Reduce ObjectCacher flush overhead Flush op in ObjectCacher will iterate the whole active object set, each dirty object also may own several BufferHead. If the object set is large, it will consume too much time. Use dirty_bh instead to reduce overhead. Now only dirty BufferHead will be checked. Signed-off-by: Haomai Wang --- diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index d3626884fcd2..b52de928a678 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -1613,22 +1613,28 @@ bool ObjectCacher::flush_set(ObjectSet *oset, Context *onfinish) // we'll need to wait for all objects to flush! C_GatherBuilder gather(cct); + set waitfor_commit; + + set::iterator next, it; + next = it = dirty_bh.begin(); + while (it != dirty_bh.end()) { + next++; + BufferHead *bh = *it; + waitfor_commit.insert(bh->ob); + bh_write(bh); + it = next; + } - for (xlist::iterator i = oset->objects.begin(); - !i.end(); ++i) { + for (set::iterator i = waitfor_commit.begin(); + i != waitfor_commit.end(); ++i) { Object *ob = *i; - if (ob->dirty_or_tx == 0) - continue; - - if (!flush(ob, 0, 0)) { - // we'll need to gather... - ldout(cct, 10) << "flush_set " << oset << " will wait for ack tid " - << ob->last_write_tid - << " on " << *ob - << dendl; - ob->waitfor_commit[ob->last_write_tid].push_back(gather.new_sub()); - } + // we'll need to gather... + ldout(cct, 10) << "flush_set " << oset << " will wait for ack tid " + << ob->last_write_tid + << " on " << *ob + << dendl; + ob->waitfor_commit[ob->last_write_tid].push_back(gather.new_sub()); } return _flush_set_finish(&gather, onfinish);