From 96b3f36789a3bb8e42f5d8786e4f97e6434f4eeb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 25 Feb 2009 12:19:54 -0800 Subject: [PATCH] mon: only do big sync if we're flushing lots of states The rest of the time, fsync them individually. --- src/mon/Paxos.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index fc983e3c26d6d..f0188a8056d79 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -214,14 +214,16 @@ void Paxos::handle_last(MMonPaxos *last) stash_latest(last_committed, last->latest_value); } */ + bool big_sync = last->last_committed - last_committed > 5; for (version_t v = last_committed+1; v <= last->last_committed; v++) { - mon->store->put_bl_sn(last->values[v], machine_name, v, false); + mon->store->put_bl_sn(last->values[v], machine_name, v, !big_sync); dout(10) << "committing " << v << " " << last->values[v].length() << " bytes" << dendl; } - mon->store->sync(); + if (big_sync) + mon->store->sync(); last_committed = last->last_committed; mon->store->put_int(last_committed, machine_name, "last_committed"); dout(10) << "last_committed now " << last_committed << dendl; @@ -491,6 +493,7 @@ void Paxos::handle_commit(MMonPaxos *commit) } // commit locally. + bool big_sync = commit->values.size() > 2; for (map::iterator p = commit->values.begin(); p != commit->values.end(); ++p) { @@ -498,10 +501,11 @@ void Paxos::handle_commit(MMonPaxos *commit) if (p->first == last_committed+1) { last_committed = p->first; dout(10) << " storing " << last_committed << " (" << p->second.length() << " bytes)" << dendl; - mon->store->put_bl_sn(p->second, machine_name, last_committed, false); + mon->store->put_bl_sn(p->second, machine_name, last_committed, !big_sync); } } - mon->store->sync(); + if (big_sync) + mon->store->sync(); mon->store->put_int(last_committed, machine_name, "last_committed"); delete commit; @@ -982,4 +986,3 @@ version_t Paxos::get_latest(bufferlist& bl) dout(10) << "get_latest v" << latest_stashed << " len " << bl.length() << dendl; return latest_stashed; } - -- 2.39.5