Skip to content

perf: Drop redundant liveness probe in redis_sock_read_bulk_reply#2858

Merged
michael-grunder merged 1 commit into
phpredis:developfrom
iliaal:perf/skip-redundant-bulk-eof
Jun 2, 2026
Merged

perf: Drop redundant liveness probe in redis_sock_read_bulk_reply#2858
michael-grunder merged 1 commit into
phpredis:developfrom
iliaal:perf/skip-redundant-bulk-eof

Conversation

@iliaal
Copy link
Copy Markdown
Contributor

@iliaal iliaal commented Jun 2, 2026

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 reading the bulk-length header on the same socket, which already proved the stream live, so the probe adds a redundant kernel round-trip to the dominant GET/HGET/MGET read path.

Replace it with a cheap NULL-stream guard. A disconnect mid-read is still caught by the existing php_stream_eof check inside the read loop.

Built on PHP 8.4; smoke tests plus bulk edge cases (empty, binary with NUL/CRLF, 1MB, null to false) pass.

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.
@michael-grunder michael-grunder merged commit 640ed13 into phpredis:develop Jun 2, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants