mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-27 07:26:51 +00:00
perf: Raise the sweep worker cap to 8
A cap of 4 measured slower than the uncapped sweep on 8-core hosts, so raise the cap to 8 and take the question of the right value to review. Trim the sweep comments to the fact and its consequence.
This commit is contained in:
@@ -75,12 +75,10 @@ public:
|
||||
/**
|
||||
* Most worker threads a single sweep() may start.
|
||||
*
|
||||
* The cache is split into partitions and sweep() shares them out over its
|
||||
* workers. A worker takes several partitions when there are more of them
|
||||
* than this, so the thread count is fixed however many partitions the
|
||||
* cache holds and however many cores the host has.
|
||||
* A worker takes several partitions when there are more than this, so the
|
||||
* thread count does not follow the host's core count.
|
||||
*/
|
||||
static constexpr std::size_t kMaxSweepThreads = 4;
|
||||
static constexpr std::size_t kMaxSweepThreads = 8;
|
||||
|
||||
public:
|
||||
TaggedCache(
|
||||
@@ -370,12 +368,11 @@ private:
|
||||
* Sweeps one partition of a key/value cache, in the calling thread.
|
||||
*
|
||||
* @param whenExpire Entries last accessed at or before this point expire.
|
||||
* @param now Current time, used to pull back a timestamp set in the future.
|
||||
* @param now Current time, used to pull back a future timestamp.
|
||||
* @param partition The one partition to walk.
|
||||
* @param stuffToSweep Collects the evicted pointers so the caller can
|
||||
* destroy them once it has released the cache lock.
|
||||
* @param allRemovals Accumulates this partition's removal count across all
|
||||
* workers.
|
||||
* @param stuffToSweep Collects evicted pointers, destroyed once the caller
|
||||
* releases the cache lock.
|
||||
* @param allRemovals Accumulates removals across all workers.
|
||||
*/
|
||||
void
|
||||
sweepPartition(
|
||||
@@ -389,14 +386,12 @@ private:
|
||||
/**
|
||||
* Sweeps one partition of a key-only cache, in the calling thread.
|
||||
*
|
||||
* A key-only cache owns no pointers, so nothing is collected for later
|
||||
* destruction and the stuffToSweep parameter is unused.
|
||||
* A key-only cache owns no pointers, so stuffToSweep is unused.
|
||||
*
|
||||
* @param whenExpire Entries last accessed at or before this point expire.
|
||||
* @param now Current time, used to pull back a timestamp set in the future.
|
||||
* @param now Current time, used to pull back a future timestamp.
|
||||
* @param partition The one partition to walk.
|
||||
* @param allRemovals Accumulates this partition's removal count across all
|
||||
* workers.
|
||||
* @param allRemovals Accumulates removals across all workers.
|
||||
*/
|
||||
void
|
||||
sweepPartition(
|
||||
|
||||
@@ -262,10 +262,8 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
<< " aging at " << (now - whenExpire).count() << " of " << targetAge_.count();
|
||||
}
|
||||
|
||||
// Share the partitions out over a fixed number of workers, so the
|
||||
// thread count does not follow the partition count. Worker w takes
|
||||
// partitions w, w + workerCount, w + 2 * workerCount and so on, which
|
||||
// covers every partition exactly once.
|
||||
// Worker w takes partitions w, w + workerCount, w + 2 * workerCount
|
||||
// and so on, covering every partition exactly once.
|
||||
std::size_t const workerCount = std::min(cache_.partitions(), kMaxSweepThreads);
|
||||
|
||||
std::vector<std::thread> workers;
|
||||
|
||||
@@ -248,9 +248,9 @@ TEST(TaggedCacheTest, sweep_thread_count_is_capped)
|
||||
{
|
||||
using Cache = TaggedCache<LedgerIndex, std::string>;
|
||||
|
||||
// sweep() runs one worker per partition unless it is capped, and the
|
||||
// Without the cap, sweep() runs one worker per partition, and the
|
||||
// partition count follows the host's core count.
|
||||
EXPECT_EQ(Cache::kMaxSweepThreads, 4u);
|
||||
EXPECT_EQ(Cache::kMaxSweepThreads, 8u);
|
||||
}
|
||||
|
||||
TEST(TaggedCacheTest, sweep_evicts_from_every_partition)
|
||||
|
||||
Reference in New Issue
Block a user