Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon: add a cache layer over MonitorDBStore #5698

Merged
1 commit merged into from
Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ OPTION(mon_sync_fs_threshold, OPT_INT, 5) // sync() when writing this many obj
OPTION(mon_compact_on_start, OPT_BOOL, false) // compact leveldb on ceph-mon start
OPTION(mon_compact_on_bootstrap, OPT_BOOL, false) // trigger leveldb compaction on bootstrap
OPTION(mon_compact_on_trim, OPT_BOOL, true) // compact (a prefix) when we trim old states
OPTION(mon_osd_cache_size, OPT_INT, 10) // the size of osdmaps cache, not to rely on underlying store's cache

OPTION(mon_tick_interval, OPT_INT, 5)
OPTION(mon_subscribe_interval, OPT_DOUBLE, 300)
OPTION(mon_delta_reset_interval, OPT_DOUBLE, 10) // seconds of inactivity before we reset the pg delta to 0
Expand Down
29 changes: 29 additions & 0 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, OSDMap& osdmap) {
<< ").osd e" << osdmap.get_epoch() << " ";
}

OSDMonitor::OSDMonitor(Monitor *mn, Paxos *p, string service_name)
: PaxosService(mn, p, service_name),
inc_osd_cache(g_conf->mon_osd_cache_size),
full_osd_cache(g_conf->mon_osd_cache_size),
thrash_map(0), thrash_last_up_osd(-1) { }

bool OSDMonitor::_have_pending_crush()
{
return pending_inc.crush.length();
Expand Down Expand Up @@ -1770,6 +1776,29 @@ void OSDMonitor::send_incremental(epoch_t first, entity_inst_t& dest, bool oneti
}
}

int OSDMonitor::get_version(version_t ver, bufferlist& bl)
{
if (inc_osd_cache.lookup(ver, &bl)) {
return 0;
}
int ret = PaxosService::get_version(ver, bl);
if (!ret) {
inc_osd_cache.add(ver, bl);
}
return ret;
}

int OSDMonitor::get_version_full(version_t ver, bufferlist& bl)
{
if (full_osd_cache.lookup(ver, &bl)) {
return 0;
}
int ret = PaxosService::get_version_full(ver, bl);
if (!ret) {
full_osd_cache.add(ver, bl);
}
return ret;
}



Expand Down
10 changes: 7 additions & 3 deletions src/mon/OSDMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using namespace std;

#include "include/types.h"
#include "common/simple_cache.hpp"
#include "msg/Messenger.h"

#include "osd/OSDMap.h"
Expand Down Expand Up @@ -139,6 +140,8 @@ class OSDMonitor : public PaxosService {
* optimization to try to avoid sending the same inc maps twice.
*/
map<int,epoch_t> osd_epoch;
SimpleLRU<version_t, bufferlist> inc_osd_cache;
SimpleLRU<version_t, bufferlist> full_osd_cache;

void check_failures(utime_t now);
bool check_failure(utime_t now, int target_osd, failure_info_t& fi);
Expand Down Expand Up @@ -358,9 +361,7 @@ class OSDMonitor : public PaxosService {
bool prepare_remove_snaps(struct MRemoveSnaps *m);

public:
OSDMonitor(Monitor *mn, Paxos *p, string service_name)
: PaxosService(mn, p, service_name),
thrash_map(0), thrash_last_up_osd(-1) { }
OSDMonitor(Monitor *mn, Paxos *p, string service_name);

void tick(); // check state, take actions

Expand All @@ -384,6 +385,9 @@ class OSDMonitor : public PaxosService {
send_incremental(m, start);
}

int get_version(version_t ver, bufferlist& bl);
int get_version_full(version_t ver, bufferlist& bl);

epoch_t blacklist(const entity_addr_t& a, utime_t until);

void dump_info(Formatter *f);
Expand Down
4 changes: 2 additions & 2 deletions src/mon/PaxosService.h
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ class PaxosService {
* @param bl The bufferlist to be populated
* @return 0 on success; <0 otherwise
*/
int get_version(version_t ver, bufferlist& bl) {
virtual int get_version(version_t ver, bufferlist& bl) {
return mon->store->get(get_service_name(), ver, bl);
}
/**
Expand All @@ -867,7 +867,7 @@ class PaxosService {
* @param bl The bufferlist to be populated
* @returns 0 on success; <0 otherwise
*/
int get_version_full(version_t ver, bufferlist& bl) {
virtual int get_version_full(version_t ver, bufferlist& bl) {
string key = mon->store->combine_strings(full_prefix_name, ver);
return mon->store->get(get_service_name(), key, bl);
}
Expand Down