Compare commits

...

2 Commits

Author SHA1 Message Date
Valentin Balaschenko
607d0f7e02 remove temp vector 2025-07-25 14:03:31 +01:00
Valentin Balaschenko
8461c7d0b6 sweep every 10 sec instead of 1 min 2025-06-18 17:00:17 +01:00

View File

@@ -384,17 +384,10 @@ public:
{ {
auto const start = m_clock.now(); auto const start = m_clock.now();
// Make a list of things to sweep, while holding the lock
std::vector<MapType::mapped_type> stuffToSweep;
std::size_t total;
{ {
ScopedLockType sl(mLock); ScopedLockType sl(mLock);
MapType::iterator it(mLedgers.begin()); MapType::iterator it(mLedgers.begin());
total = mLedgers.size();
stuffToSweep.reserve(total);
while (it != mLedgers.end()) while (it != mLedgers.end())
{ {
auto const la = it->second->getLastAction(); auto const la = it->second->getLastAction();
@@ -404,11 +397,8 @@ public:
it->second->touch(); it->second->touch();
++it; ++it;
} }
else if ((la + std::chrono::minutes(1)) < start) else if ((la + std::chrono::seconds(10)) < start)
{ {
stuffToSweep.push_back(it->second);
// shouldn't cause the actual final delete
// since we are holding a reference in the vector.
it = mLedgers.erase(it); it = mLedgers.erase(it);
} }
else else
@@ -419,14 +409,6 @@ public:
beast::expire(mRecentFailures, kReacquireInterval); beast::expire(mRecentFailures, kReacquireInterval);
} }
JLOG(j_.debug())
<< "Swept " << stuffToSweep.size() << " out of " << total
<< " inbound ledgers. Duration: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
m_clock.now() - start)
.count()
<< "ms";
} }
void void