Skip to content

Commit 4766737

Browse files
committed
[Docs] Update benchmark documents for hashing algorithms of prefix caching
1 parent 4af648c commit 4766737

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

benchmarks/hash_perf_demo.py renamed to benchmarks/benchmark_prefix_block_hash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Simple benchmark to compare prefix-cache block hashing algorithms.
66
77
Example:
8-
python benchmarks/hash_perf_demo.py --num-blocks 20000 --block-size 32
8+
python benchmark_prefix_block_hash.py --num-blocks 20000 --block-size 32
99
"""
1010

1111
from __future__ import annotations

docs/contributing/benchmarks.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,35 @@ vllm bench serve \
682682

683683
</details>
684684

685+
#### 🧪 Hashing Benchmarks
686+
687+
<details class="admonition abstract" markdown="1">
688+
<summary>Show more</summary>
689+
690+
Two helper scripts live in `benchmarks/` to compare hashing options used by prefix caching and related utilities. They are standalone (no server required) and help choose a hash algorithm before enabling prefix caching in production.
691+
692+
- `benchmarks/benchmark_hash.py`: Micro-benchmark that measures per-call latency of three implementations on a representative `(bytes, tuple[int])` payload.
693+
694+
```bash
695+
python benchmarks/benchmark_hash.py --iterations 20000 --seed 42
696+
```
697+
698+
- `benchmarks/benchmark_prefix_block_hash.py`: End-to-end block hashing benchmark that runs the full prefix-cache hash pipeline (`hash_block_tokens`) across many fake blocks and reports throughput.
699+
700+
```bash
701+
python benchmarks/benchmark_prefix_block_hash.py --num-blocks 20000 --block-size 32 --trials 5
702+
```
703+
704+
Supported algorithms: `sha256`, `sha256_cbor`, `xxhash`, `xxhash_cbor`. Install optional deps to exercise all variants:
705+
706+
```bash
707+
uv pip install xxhash cbor2
708+
```
709+
710+
If an algorithm’s dependency is missing, the script will skip it and continue.
711+
712+
</details>
713+
685714
#### ⚡ Request Prioritization Benchmark
686715

687716
<details class="admonition abstract" markdown="1">

0 commit comments

Comments
 (0)