Remove unnecessary key comparisons in perf critical snapshot paths
Former-commit-id: 40f8a8d102fdca9443399ef03a47df609b146d58
This commit is contained in:
parent
0311011131
commit
a14b2097c3
@ -613,7 +613,7 @@ void dictRelease(dict *d)
|
|||||||
zfree(d);
|
zfree(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
dictEntry *dictFindWithPrev(dict *d, const void *key, uint64_t h, dictEntry ***dePrevPtr, dictht **pht)
|
dictEntry *dictFindWithPrev(dict *d, const void *key, uint64_t h, dictEntry ***dePrevPtr, dictht **pht, bool fShallowCompare)
|
||||||
{
|
{
|
||||||
dictEntry *he;
|
dictEntry *he;
|
||||||
uint64_t idx, table;
|
uint64_t idx, table;
|
||||||
@ -626,7 +626,7 @@ dictEntry *dictFindWithPrev(dict *d, const void *key, uint64_t h, dictEntry ***d
|
|||||||
he = d->ht[table].table[idx];
|
he = d->ht[table].table[idx];
|
||||||
*dePrevPtr = &d->ht[table].table[idx];
|
*dePrevPtr = &d->ht[table].table[idx];
|
||||||
while(he) {
|
while(he) {
|
||||||
if (key==he->key || dictCompareKeys(d, key, he->key)) {
|
if (key==he->key || (!fShallowCompare && dictCompareKeys(d, key, he->key))) {
|
||||||
return he;
|
return he;
|
||||||
}
|
}
|
||||||
*dePrevPtr = &he->next;
|
*dePrevPtr = &he->next;
|
||||||
|
@ -167,7 +167,7 @@ dictEntry *dictUnlink(dict *ht, const void *key);
|
|||||||
void dictFreeUnlinkedEntry(dict *d, dictEntry *he);
|
void dictFreeUnlinkedEntry(dict *d, dictEntry *he);
|
||||||
void dictRelease(dict *d);
|
void dictRelease(dict *d);
|
||||||
dictEntry * dictFind(dict *d, const void *key);
|
dictEntry * dictFind(dict *d, const void *key);
|
||||||
dictEntry * dictFindWithPrev(dict *d, const void *key, uint64_t h, dictEntry ***dePrevPtr, dictht **ht);
|
dictEntry * dictFindWithPrev(dict *d, const void *key, uint64_t h, dictEntry ***dePrevPtr, dictht **ht, bool fShallowCompare = false);
|
||||||
void *dictFetchValue(dict *d, const void *key);
|
void *dictFetchValue(dict *d, const void *key);
|
||||||
int dictResize(dict *d);
|
int dictResize(dict *d);
|
||||||
dictIterator *dictGetIterator(dict *d);
|
dictIterator *dictGetIterator(dict *d);
|
||||||
|
@ -246,8 +246,11 @@ void redisDbPersistentDataSnapshot::freeTombstoneObjects(int depth)
|
|||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
while ((de = dictNext(di)) != nullptr)
|
while ((de = dictNext(di)) != nullptr)
|
||||||
{
|
{
|
||||||
dictEntry *deObj = dictFind(m_pdbSnapshot->m_pdict, dictGetKey(de));
|
dictEntry **dePrev = nullptr;
|
||||||
if (deObj != nullptr && dictGetVal(deObj) != nullptr)
|
dictht *ht = nullptr;
|
||||||
|
sds key = (sds)dictGetKey(de);
|
||||||
|
dictEntry *deObj = dictFindWithPrev(m_pdbSnapshot->m_pdict, key, (uint64_t)dictGetVal(de), &dePrev, &ht, !!sdsisshared(key));
|
||||||
|
if (deObj != nullptr)
|
||||||
{
|
{
|
||||||
decrRefCount((robj*)dictGetVal(deObj));
|
decrRefCount((robj*)dictGetVal(deObj));
|
||||||
void *ptrSet = nullptr;
|
void *ptrSet = nullptr;
|
||||||
@ -309,7 +312,7 @@ void redisDbPersistentData::endSnapshot(const redisDbPersistentDataSnapshot *psn
|
|||||||
{
|
{
|
||||||
dictEntry **dePrev;
|
dictEntry **dePrev;
|
||||||
dictht *ht;
|
dictht *ht;
|
||||||
dictEntry *deSnapshot = dictFindWithPrev(m_spdbSnapshotHOLDER->m_pdict, dictGetKey(de), (uint64_t)dictGetVal(de), &dePrev, &ht);
|
dictEntry *deSnapshot = dictFindWithPrev(m_spdbSnapshotHOLDER->m_pdict, dictGetKey(de), (uint64_t)dictGetVal(de), &dePrev, &ht, !!sdsisshared((sds)dictGetKey(de)));
|
||||||
if (deSnapshot == nullptr && m_spdbSnapshotHOLDER->m_pdbSnapshot)
|
if (deSnapshot == nullptr && m_spdbSnapshotHOLDER->m_pdbSnapshot)
|
||||||
{
|
{
|
||||||
// The tombstone is for a grand child, propogate it (or possibly in the storage provider - but an extra tombstone won't hurt)
|
// The tombstone is for a grand child, propogate it (or possibly in the storage provider - but an extra tombstone won't hurt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user