Skip to content

Run test subprocesses without shell - #22957

Open
NickSdot wants to merge 2 commits into
php:masterfrom
NickSdot:perf/test-subprocesses-without-shell
Open

Run test subprocesses without shell#22957
NickSdot wants to merge 2 commits into
php:masterfrom
NickSdot:perf/test-subprocesses-without-shell

Conversation

@NickSdot

@NickSdot NickSdot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Extracted from #22917.

Runs eligible test, SKIPIF, and CLEAN subprocesses through structured proc_open() commands instead of a shell. This avoids shell parsing and Windows cmd.exe launch overhead; tests requiring shell semantics are unchanged.

This is actually more like a prerequisite for the rest, but has performance gain as well.

Result

Values in seconds; measured on macOS.

mode master this PR saved speedup
-j1 368.084 341.594 26.490 1.08×
-j10 64.496 55.843 8.653 1.15×

Reproduction:

Run on master and this PR:

nice -n 10 sapi/cli/php -n run-tests.php -n -q -j1 Zend/tests
nice -n 10 sapi/cli/php -n run-tests.php -n -q -j10 Zend/tests

@NickSdot
NickSdot marked this pull request as ready for review July 31, 2026 07:22

@arnaud-lb arnaud-lb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Representing commands as arrays is a good idea in general, and the speed up from the reduced overhead is nice.

However, can we always do that, and always skip the shell? Otherwise we are increasing complexity.

Comment thread run-tests.php
Comment on lines 475 to +476
$pass_options .= ' -n';
$pass_options_args[] = '-n';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It appears that both variables are equivalent except in representation. I suggest to remove $pass_options and to build that representation from $pass_options_args when needed: implode(' ', array_map(escapeshellarg(...), $pass_option_args)).

Comment thread run-tests.php
Comment on lines 2000 to +2001
$extra_options = '';
$extraOptionArgs = [];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here (also, variable name should use snake case for consistency with $extra_options)

Comment thread run-tests.php
return $data;
}

function can_run_with_structured_test_command(TestFile $test): bool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is unclear to me why these tests can not use structured commands. Is it because it's not implemented, or because of a technical limitation? We should try to implement if possible.

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