Avoid posting unnecessary async tasks
Former-commit-id: 08f63fdfd6c78388bba093ec2edda7d77fc9173e
This commit is contained in:
parent
635ddad7fc
commit
571718f774
8
src/gc.h
8
src/gc.h
@ -49,6 +49,12 @@ public:
|
|||||||
m_setepochOutstanding.clear();
|
m_setepochOutstanding.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty() const
|
||||||
|
{
|
||||||
|
std::unique_lock<fastlock> lock(m_lock);
|
||||||
|
return m_vecepochs.empty();
|
||||||
|
}
|
||||||
|
|
||||||
void endEpoch(uint64_t epoch, bool fNoFree = false)
|
void endEpoch(uint64_t epoch, bool fNoFree = false)
|
||||||
{
|
{
|
||||||
std::unique_lock<fastlock> lock(m_lock);
|
std::unique_lock<fastlock> lock(m_lock);
|
||||||
@ -109,7 +115,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fastlock m_lock { "Garbage Collector"};
|
mutable fastlock m_lock { "Garbage Collector"};
|
||||||
|
|
||||||
std::vector<EpochHolder> m_vecepochs;
|
std::vector<EpochHolder> m_vecepochs;
|
||||||
std::unordered_set<uint64_t> m_setepochOutstanding;
|
std::unordered_set<uint64_t> m_setepochOutstanding;
|
||||||
|
@ -2441,13 +2441,15 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
|||||||
ProcessPendingAsyncWrites();
|
ProcessPendingAsyncWrites();
|
||||||
|
|
||||||
run_with_period(10) {
|
run_with_period(10) {
|
||||||
// Server threads don't free the GC, but if we don't have a
|
if (!g_pserver->garbageCollector.empty()) {
|
||||||
// a bgsave or some other async task then we'll hold onto the
|
// Server threads don't free the GC, but if we don't have a
|
||||||
// data for too long
|
// a bgsave or some other async task then we'll hold onto the
|
||||||
g_pserver->asyncworkqueue->AddWorkFunction([]{
|
// data for too long
|
||||||
auto epoch = g_pserver->garbageCollector.startEpoch();
|
g_pserver->asyncworkqueue->AddWorkFunction([]{
|
||||||
g_pserver->garbageCollector.endEpoch(epoch);
|
auto epoch = g_pserver->garbageCollector.startEpoch();
|
||||||
});
|
g_pserver->garbageCollector.endEpoch(epoch);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pserver->cronloops++;
|
g_pserver->cronloops++;
|
||||||
|
@ -1852,6 +1852,11 @@ public:
|
|||||||
garbageCollectorGeneric.endEpoch(epochGeneric, fNoFree);
|
garbageCollectorGeneric.endEpoch(epochGeneric, fNoFree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty()
|
||||||
|
{
|
||||||
|
return garbageCollectorGeneric.empty() && garbageCollectorSnapshot.empty();
|
||||||
|
}
|
||||||
|
|
||||||
void shutdown()
|
void shutdown()
|
||||||
{
|
{
|
||||||
garbageCollectorSnapshot.shutdown();
|
garbageCollectorSnapshot.shutdown();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user