Skip to content

[Store] Make batch_evict_bench scale and eviction ratios configurable#2855

Open
jacklin78911-collab wants to merge 3 commits into
kvcache-ai:mainfrom
jacklin78911-collab:bench-params-env
Open

[Store] Make batch_evict_bench scale and eviction ratios configurable#2855
jacklin78911-collab wants to merge 3 commits into
kvcache-ai:mainfrom
jacklin78911-collab:bench-params-env

Conversation

@jacklin78911-collab

@jacklin78911-collab jacklin78911-collab commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Description

Adds three optional gflags CLI flags to the BatchEvict benchmark so the 10M-objects / 5%-eviction workload discussed in the eviction-optimization work can be reproduced directly from the main-branch benchmark:

  • --num_objects: run a single custom scale when greater than 0; 0 preserves the default scale list
  • --evict_ratio_target: eviction target ratio (default 0.50)
  • --evict_ratio_lowerbound: lower-bound ratio (default 0.25)

Switched from environment variables to gflags CLI flags per review.

Defaults are unchanged: without these flags, the benchmark runs the same scales (10k, 100k, +1M with MOONCAKE_EVICT_BENCH_LARGE=1) with the same ratios and identical CSV output. Invalid ratio combinations and invalid flag values fail with a non-zero exit. The existing lock-probe environment variables and their parsing are untouched. This is a benchmark-only change; no production code is modified.

Follow-up to the benchmark added in #2584; relates to the eviction-cycle discussion in #2560.

Module

  • Mooncake Store (mooncake-store)

Type of Change

  • Other (benchmark-only configurability change)

How Has This Been Tested?

Test commands:

# Default regression
./build/mooncake-store/benchmarks/batch_evict_bench

# Invalid ratio combination: exits non-zero
./build/mooncake-store/benchmarks/batch_evict_bench \
  --evict_ratio_target=0.05 \
  --evict_ratio_lowerbound=0.5

# Invalid non-numeric flag value: exits non-zero
./build/mooncake-store/benchmarks/batch_evict_bench \
  --num_objects=invalid

# Custom workloads
./build/mooncake-store/benchmarks/batch_evict_bench \
  --num_objects=1000000 \
  --evict_ratio_target=0.05 \
  --evict_ratio_lowerbound=0.05

./build/mooncake-store/benchmarks/batch_evict_bench \
  --num_objects=10000000 \
  --evict_ratio_target=0.05 \
  --evict_ratio_lowerbound=0.05

Add three optional environment variables to the BatchEvict benchmark so
the 10M-objects / 5%-eviction workload discussed in the eviction
optimization work can be reproduced directly from the main-branch
benchmark:

- MOONCAKE_EVICT_BENCH_OBJECTS: run a single custom scale
- MOONCAKE_EVICT_BENCH_TARGET_RATIO: eviction target ratio (default 0.50)
- MOONCAKE_EVICT_BENCH_LOWERBOUND_RATIO: lower-bound ratio (default 0.25)

Defaults are unchanged: without these variables the benchmark runs the
same scales (10k, 100k, +1M with MOONCAKE_EVICT_BENCH_LARGE=1) with the
same ratios and identical CSV output. Invalid values fail loudly with a
non-zero exit instead of silently falling back. Benchmark-only change.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces dynamic configuration of eviction ratios and benchmark object counts via environment variables in the batch eviction benchmark. It adds helper functions to parse and validate these environment variables. The feedback highlights a critical issue in ReadStrictEnvSize where std::getenv can return nullptr, leading to undefined behavior when constructing a std::string_view without a prior null check.

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.

Comment thread mooncake-store/benchmarks/batch_evict_bench.cpp Outdated
@codecov-commenter

codecov-commenter commented Jul 11, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mooncake-store/benchmarks/batch_evict_bench.cpp 0.00% 18 Missing ⚠️

📢 Thoughts on this report? Let us know!

return false;
}

if (std::getenv("MOONCAKE_EVICT_BENCH_OBJECTS") != nullptr ||

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we expose these three new benchmark parameters as gflags command-line options instead of environment variables, for example --num_objects, --evict_ratio_target, and --evict_ratio_lowerbound. This benchmark already uses gflags, and CLI flags are consistent with the other Store benchmarks, discoverable through --help, and avoid unnecessary custom environment-variable parsing.

@yokinoshitayoki yokinoshitayoki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, this PR looks good to me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants