RDB load performance, eliminate useless reads
Former-commit-id: 68e5d1850dbba89a87710968d314cb8c0d3cb562
This commit is contained in:
parent
ea9b165e17
commit
8c0c00aae5
13
src/db.cpp
13
src/db.cpp
@ -210,13 +210,14 @@ robj *lookupKeyWriteOrReply(client *c, robj *key, robj *reply) {
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dbAddCore(redisDb *db, robj *key, robj *val) {
|
bool dbAddCore(redisDb *db, robj *key, robj *val, bool fAssumeNew = false) {
|
||||||
serverAssert(!val->FExpires());
|
serverAssert(!val->FExpires());
|
||||||
sds copy = sdsdupshared(szFromObj(key));
|
sds copy = sdsdupshared(szFromObj(key));
|
||||||
bool fInserted = db->insert(copy, val);
|
|
||||||
if (g_pserver->fActiveReplica)
|
if (g_pserver->fActiveReplica)
|
||||||
val->mvcc_tstamp = key->mvcc_tstamp = getMvccTstamp();
|
val->mvcc_tstamp = key->mvcc_tstamp = getMvccTstamp();
|
||||||
|
|
||||||
|
bool fInserted = db->insert(copy, val, fAssumeNew);
|
||||||
|
|
||||||
if (fInserted)
|
if (fInserted)
|
||||||
{
|
{
|
||||||
if (val->type == OBJ_LIST ||
|
if (val->type == OBJ_LIST ||
|
||||||
@ -307,7 +308,7 @@ int dbMerge(redisDb *db, robj *key, robj *val, int fReplace)
|
|||||||
}
|
}
|
||||||
else
|
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));
|
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);
|
int res = dictAdd(m_pdict, key, o);
|
||||||
|
serverAssert(FImplies(fAssumeNew, res == DICT_OK));
|
||||||
if (res == DICT_OK)
|
if (res == DICT_OK)
|
||||||
{
|
{
|
||||||
if (m_pdbSnapshot != nullptr && m_pdbSnapshot->find_cached_threadsafe(key) != nullptr)
|
if (m_pdbSnapshot != nullptr && m_pdbSnapshot->find_cached_threadsafe(key) != nullptr)
|
||||||
|
@ -5282,6 +5282,7 @@ void loadDataFromDisk(void) {
|
|||||||
serverLog(LL_NOTICE,"DB loaded from append only file: %.3f seconds",(float)(ustime()-start)/1000000);
|
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) {
|
} else if (g_pserver->rdb_filename != NULL || g_pserver->rdb_s3bucketpath != NULL) {
|
||||||
rdbSaveInfo rsi = RDB_SAVE_INFO_INIT;
|
rdbSaveInfo rsi = RDB_SAVE_INFO_INIT;
|
||||||
|
rsi.fForceSetKey = false;
|
||||||
if (rdbLoad(&rsi,RDBFLAGS_NONE) == C_OK) {
|
if (rdbLoad(&rsi,RDBFLAGS_NONE) == C_OK) {
|
||||||
serverLog(LL_NOTICE,"DB loaded from disk: %.3f seconds",
|
serverLog(LL_NOTICE,"DB loaded from disk: %.3f seconds",
|
||||||
(float)(ustime()-start)/1000000);
|
(float)(ustime()-start)/1000000);
|
||||||
|
@ -1276,7 +1276,7 @@ public:
|
|||||||
void getStats(char *buf, size_t bufsize) { dictGetStats(buf, bufsize, m_pdict); }
|
void getStats(char *buf, size_t bufsize) { dictGetStats(buf, bufsize, m_pdict); }
|
||||||
void getExpireStats(char *buf, size_t bufsize) { m_setexpire->getstats(buf, bufsize); }
|
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();
|
void tryResize();
|
||||||
int incrementallyRehash();
|
int incrementallyRehash();
|
||||||
void updateValue(dict_iter itr, robj *val);
|
void updateValue(dict_iter itr, robj *val);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user