mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Introduce partitioned unordered maps:
This commit implements partitioned unordered maps and makes it possible to traverse such a map in parallel, allowing for more efficient use of CPU resources. The `CachedSLEs`, `TaggedCache`, and `KeyCache` classes make use of the new functionality, which should improve performance.
This commit is contained in:
@@ -218,39 +218,47 @@ LedgerReplayer::gotReplayDelta(
|
||||
void
|
||||
LedgerReplayer::sweep()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
JLOG(j_.debug()) << "Sweeping, LedgerReplayer has " << tasks_.size()
|
||||
<< " tasks, " << skipLists_.size() << " skipLists, and "
|
||||
<< deltas_.size() << " deltas.";
|
||||
auto const start = std::chrono::steady_clock::now();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
JLOG(j_.debug()) << "Sweeping, LedgerReplayer has " << tasks_.size()
|
||||
<< " tasks, " << skipLists_.size()
|
||||
<< " skipLists, and " << deltas_.size() << " deltas.";
|
||||
|
||||
tasks_.erase(
|
||||
std::remove_if(
|
||||
tasks_.begin(),
|
||||
tasks_.end(),
|
||||
[this](auto const& t) -> bool {
|
||||
if (t->finished())
|
||||
{
|
||||
JLOG(j_.debug())
|
||||
<< "Sweep task " << t->getTaskParameter().finishHash_;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
tasks_.end());
|
||||
tasks_.erase(
|
||||
std::remove_if(
|
||||
tasks_.begin(),
|
||||
tasks_.end(),
|
||||
[this](auto const& t) -> bool {
|
||||
if (t->finished())
|
||||
{
|
||||
JLOG(j_.debug()) << "Sweep task "
|
||||
<< t->getTaskParameter().finishHash_;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
tasks_.end());
|
||||
|
||||
auto removeCannotLocked = [](auto& subTasks) {
|
||||
for (auto it = subTasks.begin(); it != subTasks.end();)
|
||||
{
|
||||
if (auto item = it->second.lock(); !item)
|
||||
auto removeCannotLocked = [](auto& subTasks) {
|
||||
for (auto it = subTasks.begin(); it != subTasks.end();)
|
||||
{
|
||||
it = subTasks.erase(it);
|
||||
if (auto item = it->second.lock(); !item)
|
||||
{
|
||||
it = subTasks.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
};
|
||||
removeCannotLocked(skipLists_);
|
||||
removeCannotLocked(deltas_);
|
||||
};
|
||||
removeCannotLocked(skipLists_);
|
||||
removeCannotLocked(deltas_);
|
||||
}
|
||||
JLOG(j_.debug()) << " LedgerReplayer sweep lock duration "
|
||||
<< std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - start)
|
||||
.count()
|
||||
<< "ms";
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user