Skip to content

Enable TCP_NODELAY on connections - #149

Merged
kelunik merged 1 commit into
amphp:3.xfrom
nicolas-grekas:tcp-nodelay
Nov 1, 2026
Merged

kelunik merged 1 commit into
amphp:3.xfrom
nicolas-grekas:tcp-nodelay

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

Fixes #55

COM_STMT_CLOSE gets no reply from the server. With Nagle's algorithm enabled, the next command then stays in the client kernel until the server acknowledges the close packet. That's typically the COM_STMT_PREPARE of the next execute(), and Linux delays the ACK by 40 ms. mysqlnd sets TCP_NODELAY right after connecting, which is why PDO and mysqli don't have this issue.

On MySQL 8.4, execute('SELECT ?', [1]) goes from 44 ms to 1.5 ms per call. Found while profiling the AMPHP SQL transport of Symfony Messenger (symfony/symfony#67521).

@kelunik
kelunik merged commit e402ab8 into amphp:3.x Nov 1, 2026
7 checks passed
@kelunik

kelunik commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Perf issues with prepared statements ?

2 participants