perf: Drop redundant liveness probe in redis_sock_read_bulk_reply

redis_sock_read_bulk_reply called redis_check_eof(), which issues a
php_stream_eof() probe (a recv(MSG_PEEK) syscall when the stream buffer
is drained), before reading the bulk body. Every caller reaches this
function only after successfully reading the bulk-length header on the
same socket, which already proved the stream live, so the probe is
redundant and adds a kernel round-trip to the dominant GET/HGET/MGET
read path.

Replace it with a cheap NULL-stream guard. A disconnect that happens
mid-read is still caught by the existing php_stream_eof() check inside
the read loop.
This commit is contained in:
Ilia Alshanetsky
2026-06-02 18:13:43 -04:00
committed by Michael Grunder
parent 9623a66320
commit 640ed13fcc
+6 -1
View File
@@ -784,7 +784,12 @@ redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes)
return NULL;
}
if (-1 == bytes || -1 == redis_check_eof(redis_sock, 1, 0)) {
/* The caller reaches this only after successfully reading the bulk
* header on this socket, which already proved the stream live, so the
* php_stream_eof() liveness probe redis_check_eof() performs is
* redundant here. A mid-read disconnect is still caught by the read
* loop below. Keep a cheap NULL-stream guard for safety. */
if (-1 == bytes || redis_sock->stream == NULL) {
return NULL;
}