RDB load performance, eliminate useless reads

Former-commit-id: 68e5d1850dbba89a87710968d314cb8c0d3cb562
This commit is contained in:
John Sully 2020-04-22 00:47:49 -04:00
parent ea9b165e17
commit 8c0c00aae5
3 changed files with 10 additions and 6 deletions

View File

@ -210,13 +210,14 @@ robj *lookupKeyWriteOrReply(client *c, robj *key, robj *reply) {
return o;
}
bool dbAddCore(redisDb *db, robj *key, robj *val) {
bool dbAddCore(redisDb *db, robj *key, robj *val, bool fAssumeNew = false) {
serverAssert(!val->FExpires());
sds copy = sdsdupshared(szFromObj(key));
bool fInserted = db->insert(copy, val);
if (g_pserver->fActiveReplica)
val->mvcc_tstamp = key->mvcc_tstamp = getMvccTstamp();
bool fInserted = db->insert(copy, val, fAssumeNew);
if (fInserted)
{
if (val->type == OBJ_LIST ||
@ -307,7 +308,7 @@ int dbMerge(redisDb *db, robj *key, robj *val, int fReplace)
}
else
{
return (dbAddCore(db, key, val) == true);
return (dbAddCore(db, key, val, true) == true);
}
}
@ -2175,10 +2176,12 @@ void redisDb::initialize(int id)
this->setStorageProvider(g_pserver->m_pstorageFactory->create(id));
}
bool redisDbPersistentData::insert(char *key, robj *o)
bool redisDbPersistentData::insert(char *key, robj *o, bool fAssumeNew)
{
ensure(key);
if (!fAssumeNew)
ensure(key);
int res = dictAdd(m_pdict, key, o);
serverAssert(FImplies(fAssumeNew, res == DICT_OK));
if (res == DICT_OK)
{
if (m_pdbSnapshot != nullptr && m_pdbSnapshot->find_cached_threadsafe(key) != nullptr)

View File

@ -5282,6 +5282,7 @@ void loadDataFromDisk(void) {
serverLog(LL_NOTICE,"DB loaded from append only file: %.3f seconds",(float)(ustime()-start)/1000000);
} else if (g_pserver->rdb_filename != NULL || g_pserver->rdb_s3bucketpath != NULL) {
rdbSaveInfo rsi = RDB_SAVE_INFO_INIT;
rsi.fForceSetKey = false;
if (rdbLoad(&rsi,RDBFLAGS_NONE) == C_OK) {
serverLog(LL_NOTICE,"DB loaded from disk: %.3f seconds",
(float)(ustime()-start)/1000000);

View File

@ -1276,7 +1276,7 @@ public:
void getStats(char *buf, size_t bufsize) { dictGetStats(buf, bufsize, m_pdict); }
void getExpireStats(char *buf, size_t bufsize) { m_setexpire->getstats(buf, bufsize); }
bool insert(char *k, robj *o);
bool insert(char *k, robj *o, bool fAssumeNew = false);
void tryResize();
int incrementallyRehash();
void updateValue(dict_iter itr, robj *val);