The repository has four scenarios plus validation scripts in bench/. Every number here was measured locally on macOS 15 ARM64 with PHP 8.5.5 against Valkey 9.0.3 on the loopback interface (the 0.3.0 release itself requires PHP 8.6). Run the same scripts on your own hardware before trusting the numbers; loopback latency and CPU model both matter.
bench/validate_01_structure_parity.php confirms the C parser produces output identical to both pure-PHP parsers via md5(serialize($value)).
Pure parser throughput
Synthetic XREADGROUP-shaped buffer, one stream with ten entries of three fields each (2,187 bytes per iteration). No work after parse.
| Parser | Iterations per second | MB per second |
|---|---|---|
| ext-resp3 (C) | 511,332 | 1,066.5 |
Fledge RespParser (PHP) |
16,573 | 34.6 |
Amp\Redis\RespParser (PHP) |
16,640 | 34.7 |
About 31x faster in parser isolation.
Allocation pressure
Twenty messages of 25 entries with four fields each (141,140 bytes per iteration), output held to keep the parsed arrays alive.
| Parser | Iterations per second | MB per second |
|---|---|---|
| ext-resp3 (C) | 8,728 | 1,174.8 |
Fledge RespParser (PHP) |
33 | 4.4 |
Amp\Redis\RespParser (PHP) |
32 | 4.2 |
About 265x on this shape. Neither parser triggered a GC cycle in the measurement window; the gap is allocation count, not GC overhead.
Batched fetch
XREADGROUP with COUNT=100, draining a 50,000 entry stream in 500 round-trips. The loop only calls count() on the outer array.
| Stack | Variant | Entries per second |
|---|---|---|
| Fledge | stock | 77,193 |
| Fledge | + ext-resp3 | 623,262 |
| amphp/redis | stock | 79,235 |
| amphp/redis | + ext-resp3 | 609,131 |
About 8x. This loop is parser-bound by construction: it shows the gain when the work after parsing is negligible.
Realistic worker simulation
XREADGROUP with COUNT=10, then for each entry: igbinary_unserialize the payload, run a tiny handler that hashes the job, then XACK and XDEL. 5,000 jobs, 15,000+ round-trips.
| Stack | Variant | Jobs per second |
|---|---|---|
| Fledge | stock | 13,838 |
| Fledge | + ext-resp3 | 14,739 |
| amphp/redis | stock | 13,858 |
| amphp/redis | + ext-resp3 | 15,036 |
Gains of 6.5% (Fledge) and 8.5% (amphp/redis). Three round-trips per job and per-entry handler work mean loopback latency and server CPU dominate.
Cache-heavy reads
MGET of 1000 keys per call, igbinary_unserialize each value, no writes back. 1,000 calls per measurement.
| Stack | Variant | Reads per second |
|---|---|---|
| Fledge | stock | 419,080 |
| Fledge | + ext-resp3 | 1,329,098 |
| amphp/redis | stock | 402,398 |
| amphp/redis | + ext-resp3 | 1,365,005 |
Gains of 217% (Fledge) and 239% (amphp/redis), about 3.2x to 3.4x. One round-trip returns a thousand small bulk strings and the per-value work is light: the shape where the parser swap matters.
When the parser pays off
It pays off when:
- One round-trip returns many small values (cache-heavy
MGET,HGETALLon big hashes). - The application work per parsed value is light.
- Latency to the Redis instance is low relative to the time spent materialising PHP values.
It does not pay off when:
- Per-job work is heavy.
- Per-job round-trip count is greater than one (XACK and XDEL after every XREADGROUP entry).
- The Redis instance is a network hop away and round-trip latency drowns out everything else.
Reproduce
# Build the extension (from repo root)phpize./configure --enable-resp3make # Install the dev dependencies that the bench harness needscomposer install --ignore-platform-req=ext-resp3 # Start a Redis or Valkey on 127.0.0.1:6379, then run everything (about 90 seconds)bench/run.sh # Or skip the scenarios that need Redisbench/run.sh --skip-e2e
The harness writes per-scenario reports to bench/results/*.md.