Skip to content

ext/curl: speed up tests - #23228

Open
Sjord wants to merge 3 commits into
php:masterfrom
Sjord:curl-faster-tests
Open

ext/curl: speed up tests#23228
Sjord wants to merge 3 commits into
php:masterfrom
Sjord:curl-faster-tests

Conversation

@Sjord

@Sjord Sjord commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

By waiting shorter for the server to be ready. In my setup, this takes it from 26 to 15 seconds for all curl tests.

The first check for output on stderr takes approximately 10ms, so we wait 20ms to make sure its ready. The second check for the open port typically succeeds immediately, so move the sleep to after we have tried.

Disable Expect: 100-continue to prevent libcurl's 1-second delay.

By waiting shorter for the server to be ready. In my setup, this takes
it from 26 to 15 seconds for all curl tests.

The first check for output on stderr takes approximately 10ms, so we
wait 20ms to make sure its ready. The second check for the open port
typically succeeds immediately, so move the sleep to after we have
tried.
Sjord added 2 commits August 12, 2026 12:44
Disable Expect: 100-continue to prevent libcurl's 1-second delay
@Sjord
Sjord marked this pull request as ready for review August 12, 2026 13:04
@Sjord
Sjord requested a review from adoy as a code owner August 12, 2026 13:04
@Sjord

Sjord commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@NickSdot Could you take a look at this?

@NickSdot NickSdot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Can confirm it's ~40% faster -- nice! Added one nit.

try {
// Give the server time to start
sleep(1);
for ($i = 0; $i < 100; $i++) {

@NickSdot NickSdot Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for ($i = 0; $i < 100; $i++) {
for ($i = 0; $i < 50; $i++) {

Maybe 50 is enough? Would match the previous 1s; fsockopen already adds extra.


if (CURLOPT_INFILE == $curl_option) {
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Expect:']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disable Expect: 100-continue to prevent libcurl's 1-second delay.

May I ask where the 1 second delay come from?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants