|
| 1 | +# L2 adapter benchmark (`lmcache bench l2`) |
| 2 | + |
| 3 | +End-to-end store / lookup / load benchmarks for [`AerospikeL2Plugin`](../../src/lmcache_aerospike/l2_plugin.py) using the same [`parse_args_to_l2_adapters_config`](https://docs.lmcache.ai/mp/configuration.html) + `create_l2_adapter` path as production MP mode. |
| 4 | + |
| 5 | +Upstream docs: [lmcache bench l2](https://docs.lmcache.ai/cli/bench_l2.html). |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +| Piece | Why | |
| 10 | +| ----- | --- | |
| 11 | +| **LMCache `dev`** | PyPI `lmcache` 0.4.x does not ship `lmcache bench l2` or `L2StoreResult`. | |
| 12 | +| **This package** (`pip install -e .`) | Provides `type: plugin` → `AerospikeL2Plugin`. | |
| 13 | +| **torch + openai** | Bench CLI and `TensorMemoryObj` payloads (see `benchmarks/l2/requirements.txt`). | |
| 14 | +| **Aerospike CE** (for real runs) | `./scripts/start_aerospike_ce.sh` → `.aerospike-ci.env`. | |
| 15 | + |
| 16 | +`native_storage_ops` is optional for bench: `benchmarks/l2/bootstrap.py` installs the same Python fallback used in integration tests when the extension module is missing. |
| 17 | + |
| 18 | +## One-time setup |
| 19 | + |
| 20 | +```bash |
| 21 | +# LMCache dev clone (default: ../LMCache next to this repo) |
| 22 | +git clone https://github.com/LMCache/LMCache.git ../LMCache |
| 23 | +cd ../LMCache && git checkout dev |
| 24 | + |
| 25 | +cd /path/to/lmcache-aerospike |
| 26 | +./scripts/setup_l2_bench.sh |
| 27 | +``` |
| 28 | + |
| 29 | +Override the LMCache path: |
| 30 | + |
| 31 | +```bash |
| 32 | +LMCACHE_SRC=/path/to/LMCache ./scripts/setup_l2_bench.sh |
| 33 | +``` |
| 34 | + |
| 35 | +Preflight only: |
| 36 | + |
| 37 | +```bash |
| 38 | +python3 scripts/preflight_l2_bench.py |
| 39 | +``` |
| 40 | + |
| 41 | +## Running (when you are ready) |
| 42 | + |
| 43 | +Start Aerospike and load connection env (dynamic port is written to `.aerospike-ci.env`): |
| 44 | + |
| 45 | +```bash |
| 46 | +./scripts/start_aerospike_ce.sh |
| 47 | +set -a && source .aerospike-ci.env && set +a |
| 48 | +``` |
| 49 | + |
| 50 | +Smoke (store → lookup → load, defaults from [bench_l2 docs](https://docs.lmcache.ai/cli/bench_l2.html)): |
| 51 | + |
| 52 | +```bash |
| 53 | +./benchmarks/l2/run.sh |
| 54 | +``` |
| 55 | + |
| 56 | +Stress profile and single operation: |
| 57 | + |
| 58 | +```bash |
| 59 | +./benchmarks/l2/run.sh --profile stress |
| 60 | +./benchmarks/l2/run.sh --only store |
| 61 | +./benchmarks/l2/run.sh -- --no-skip-verify # round-trip byte check on last round |
| 62 | +``` |
| 63 | + |
| 64 | +Direct CLI (equivalent; `run.sh` sets `L2_ADAPTER_JSON` from `adapters/` + `.aerospike-ci.env`): |
| 65 | + |
| 66 | +```bash |
| 67 | +python3 benchmarks/l2/bootstrap.py |
| 68 | +export L2_ADAPTER_JSON="$(cat benchmarks/l2/adapters/aerospike_smoke.json)" |
| 69 | +lmcache bench l2 --l2-adapter "$L2_ADAPTER_JSON" --num-keys 32 --in-flight 1 |
| 70 | +``` |
| 71 | + |
| 72 | +## Layout |
| 73 | + |
| 74 | +| Path | Purpose | |
| 75 | +| ---- | ------- | |
| 76 | +| `adapters/*.json` | Plugin specs (`type: plugin`, `AerospikeL2Plugin`). Hosts/port overridden by `run.sh`. | |
| 77 | +| `profiles/*.env` | Default CLI flag bundles (`BENCH_L2_EXTRA_ARGS`). | |
| 78 | +| `bootstrap.py` | `native_storage_ops` fallback + `init_remote_metadata_info(1)`. | |
| 79 | +| `run.sh` | Sources Aerospike env, renders adapter JSON, runs `lmcache bench l2`. | |
| 80 | +| `env.example` | Optional `benchmarks/l2/.env.local` knobs. | |
| 81 | + |
| 82 | +Bench records use set **`kv_chunks_bench_l2`** by default (not `it_chunks` or `kv_chunks_l2_it`). |
| 83 | + |
| 84 | +## Cold-cache / isolated operations |
| 85 | + |
| 86 | +For adapters backed by the OS page cache, run operations separately and drop caches between runs (see upstream note in [bench_l2](https://docs.lmcache.ai/cli/bench_l2.html)): |
| 87 | + |
| 88 | +```bash |
| 89 | +./benchmarks/l2/run.sh --only store |
| 90 | +sync && echo 3 | sudo tee /proc/sys/vm/drop_caches |
| 91 | +./benchmarks/l2/run.sh --only lookup |
| 92 | +``` |
| 93 | + |
| 94 | +Aerospike has no local page cache; the default combined `run.sh` pass is usually representative. |
0 commit comments