[Store] Add BatchEvict candidate-selection benchmark#2584
[Store] Add BatchEvict candidate-selection benchmark#2584jacklin78911-collab wants to merge 5 commits into
Conversation
Add BatchEvictBenchTest friend declaration
There was a problem hiding this comment.
Code Review
This pull request introduces a new benchmark-only test, BatchEvictBenchTest, to evaluate the candidate-selection cost of MasterService::BatchEvict at scale. It also adds the necessary friend class declarations in MasterService and updates the CMake configuration. The reviewer suggested a performance optimization in the benchmark helper function PercentileValue to pass the vector by reference instead of by value, preventing redundant copies.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| return static_cast<size_t>(parsed); | ||
| } | ||
|
|
||
| static uint64_t PercentileValue(std::vector<uint64_t> values, |
There was a problem hiding this comment.
Passing std::vector<uint64_t> by value to PercentileValue causes the vector to be copied on every call. Since PercentileValue is called multiple times on the same vectors (total_us and wait_us) in the benchmark, we can avoid these redundant copies by passing the vector by non-const reference. Sorting the vector in-place on the first call is perfectly fine and avoids any copy overhead.
| static uint64_t PercentileValue(std::vector<uint64_t> values, | |
| static uint64_t PercentileValue(std::vector<uint64_t>& values, |
There was a problem hiding this comment.
Thanks, applied — passing by reference now. The two vectors are local and discarded after use, so in-place sorting is fine and avoids the copies.
some changes
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Sorry to ask, but can we add result from this benchmark here? |
|
Before changing the production data structure, I think it would be useful to break down like:
We might need more detailed data to trade off what kind of an optimization we should make. |
|
Thanks @yokinoshitayoki. Yes — here is what the benchmark in this PR produces on my current build. Running The lock probe also runs at the small scale: For the larger 1M-object case, my earlier investigation for #2560 on A separately instrumented build, not included in this PR, attributed about 73–75% of the cycle to candidate scan/traversal, about 0.1% to I can also run the 1M case on this exact PR build and paste the output if that would be useful. On the per-shard metadata RW-lock hold time and the direct |
Description
Adds a benchmark-only gtest that drives the real
MasterService::BatchEvictpath at controlled metadata scale, to make the eviction-cycle cost and lock-hold behavior from #2560 reproducible and reviewable.It changes no production behavior. The only non-test change is adding
BatchEvictBenchTestas a test friend ofMasterService(matching the existing test-friend pattern) so the benchmark can populate metadata and takesnapshot_mutex_from the test.The benchmark has two parts:
RealBatchEvictScales(always on): end-to-endBatchEvictwall-clock time vs object count. Default scales are small (10k, 100k) to stay cheap in CI; setMOONCAKE_EVICT_BENCH_LARGE=1to also run 1M.SingleWaiterSnapshotMutexProbe(opt-in viaMOONCAKE_EVICT_BENCH_LOCK_PROBE=1): per trial, a singleunique_lockwaiter onsnapshot_mutex_arrives shortly after aBatchEvictcycle begins; the test records how long it waits to acquire, and reports p50/p95/max over N trials.The workload is synthetic (single tenant, all objects expired, all no-pin, one completed memory replica each). It is meant as a reproducible baseline for the scan/lock-hold cost, not a production-latency claim.
Module
mooncake-store)Type of Change
How Has This Been Tested?
cmake --build build --target batch_evict_bench_test -j$(nproc)./build/mooncake-store/tests/batch_evict_bench_testMOONCAKE_EVICT_BENCH_LOCK_PROBE=1 MOONCAKE_EVICT_BENCH_LOCK_OBJECTS=10000 MOONCAKE_EVICT_BENCH_LOCK_TRIALS=3 ./build/mooncake-store/tests/batch_evict_bench_testclang-format-20applied.Relates to #2560.
Checklist