Add support for PHP resp-bench - #28
Open
prateek-kumar-improving wants to merge 4 commits into
Open
prateek-kumar-improving wants to merge 4 commits into
prateek-kumar-improving wants to merge 4 commits into
Conversation
Signed-off-by: Kumar <kupratec@amazon.com>
added 2 commits
September 14, 2026 10:07
Signed-off-by: Kumar <kupratec@amazon.com>
Signed-off-by: Kumar <kupratec@amazon.com>
Resolve conflicts from the merged Node.js engine (#27), which touched the same shared files as the PHP engine PR. All resolutions are additive — both engines coexist: - scripts/{run_benchmark_matrix,generate_graphs}.py: keep php + node driver maps - Makefile: keep both PHP and Node engine target sections and .PHONY entries - README.md: keep PHP and Node rows in languages/structure/target tables - .github/workflows/benchmark.yml: keep test-php + benchmark-php and benchmark-node jobs; add 'php' to the engines input; generate-graphs needs all four engines
prateek-kumar-improving
force-pushed
the
php/resp-bench
branch
from
September 15, 2026 17:18
fae89db to
df25b03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the PHP benchmark engine, at parity with the Java (reference), Ruby, and C# engines.
What
php/(composer install,php bin/resp-bench), driving:valkey-glide-php— the Valkey GLIDE PHP client (nativeext-valkey_glideextension, PHPRedis-compatible API)phpredis— PHPRedis (ext-redis), the de-facto standard PHP client and the incumbent comparison baseline (analogous to redis-rb for Ruby / StackExchange.Redis for C#)recording— in-memory driver for server-free testsunit:"us", uppercased command keys, HDR compressed base64).Concurrency model
PHP's GLIDE client is synchronous and the standard PHP build is non-thread-safe (NTS), which rules out
ext-parallel. The engine therefore uses process-per-connection viapcntl— the faithful, dependency-free analogue of Java's virtual-thread-per-client and Ruby's thread-per-client:connections = N→ fork N worker processes (capped at 256), each with one in-flight request at a time (theclient == connectioninvariant), keeping results comparable across engines.stream_socket_pair; the parent reconstructs and merges the HdrHistograms losslessly (sparse bucket counts) before writing NDJSON.rps_limitis divided across workers so the aggregate matches the target.inlinemode (--concurrency inline) runs all connections sequentially in one process; it's selected automatically for therecordingdriver and whenpcntlis unavailable, and exercises the full pipeline for server-free tests.Cross-engine parity
JavaRandomLCG port — verified byte-identical to Java's canonicalnew Random(0).nextInt()sequence[-1155484576, -723955400, 1033096058, -1690734402, -1557280266, ...]. PHP lacks 64-bit integer overflow wraparound, so the multiply uses a 24-bit split to preserve the low 48 bits.sequential_intwalks the keyspace;uniform_randseeds per worker (seed + idx) for reproducible-yet-distinct sequences. Key formatting%0Ndhonoringkey_size_bytes.(1, 600_000_000, 3); the V2 compressed base64 payload is byte-structured to match Java'sencodeIntoCompressedByteBuffer(). Leaky-bucket rate limiter.Harness
php-build/test/integration-test/run/clean/infotargets.driver_idinscripts/run_benchmark_matrix.py(DRIVER_ENGINE_MAP) andscripts/generate_graphs.py(DRIVER_LANGUAGE_MAP).configs/drivers/{default,high-throughput}/+example-*-standalone.json, plusconfigs/matrices/php-driver-comparison.json(GLIDE-PHP vs PHPRedis across connection counts — the head-to-head that mirrors the Java/Node comparison matrices).test-phpjob (unit + integration) and abenchmark-phpjob that builds thevalkey_glideextension from source and runs against a live server; wired intogenerate-graphsneeds.php/README.md,docs/BENCHMARKS_PHP.md, README "Supported Languages" + Make Targets updates.Tests
58 tests (
cd php && vendor/bin/phpunit): parity anchors (JavaRandom seed-0 Java anchor, key generator), rate limiter, command selector, config loader, client factory, HDR encode structure + percentiles; integration tests covering the recording-driver pipeline (NDJSON schema, inline + process fork modes, agreement on totals), rate limiting (RPS enforcement, shared limit across concurrent connections, unlimited throughput), error metrics (per-command error counts, errors excluded from latency histogram), and NDJSON/metrics output. Gated live tests for bothvalkey-glide-phpandphpredisskip cleanly without their extension + a server. No server needed for the 50 non-live tests.Verified locally (PHP 8.5, no server, no extension): full suite = 58 tests pass, 8 skipped (the gated live tests for the two real drivers). CLI smoke test with the
recordingdriver produces valid NDJSON with correct totals (WARMUP 400, STEADY 1000 = GET+SET) and non-empty HDR payloads in both inline and--concurrency process(fork) modes.Notes
valkey-glide-phpfollows thevalkey-glide-ruby/valkey-glide-csharpnaming convention (not the barevalkey-glide, which is Java's).valkey_glideextension installed (php/README.mddocuments install via pie/PECL/source; thebenchmark-phpCI job builds it). The recording-driver e2e covers the engine paths without it.decodeFromCompressedByteBuffer()was not run in this environment (no JRE); it's ported from the Java-validated Ruby encoder.