Skip to content

Avoid the extra PHP process in the wp launcher #389

Open

Description

@schlessera

The wp launcher script starts PHP twice for every command: once to run php -r "echo PHP_OS;", which is only needed to detect Cygwin, and once to run WP-CLI itself. Together with the shell wrappers this adds about 30 ms to every call (121 ms versus 92 ms for wp cli version locally).

The test suites make well over 10,000 wp calls per run of the bundled commands, so this adds up to several minutes for each CI configuration. It also slows down every real-world invocation.

The fix belongs in bin/wp in wp-cli/wp-cli. It is tracked here because the test suite is where the impact is largest.

Measuring: take the baseline from #384, then open a draft PR, run the same CI jobs against it and record both results here before we decide.

Activity

  1. schlessera commented on Oct 30, 2026

    @schlessera
    MemberAuthor

    Measurement

    Measured on GitHub Actions with the full test matrix of core-command and cache-command, run on measure/* branches of wp-cli/core-command#350 and wp-cli/cache-command#137. All runs use wp-cli-tests at the same base commit (9298472) and differ only in using wp-cli/wp-cli from wp-cli/wp-cli#6442 instead of its main branch.

    The metric is the Behat wall time of each job, from the start of the Behat step to its last summary, for the 49 Linux jobs present in all runs. "Total" is the sum over these jobs, "per job" the median of each job's change against the mean of the two baseline runs. Both baselines run the identical code, so their spread is the noise level: about ±1% for cache-command and about ±5% for core-command. All runs executed the same scenarios (about 4,518 for core-command and 1,162 for cache-command across the Linux jobs).

    core-command total core-command per job cache-command total cache-command per job
    Baseline A 13,585 s -5.4% 4,943 s -0.3%
    Baseline B 14,644 s +5.4% 5,062 s +0.3%
    wp-cli/wp-cli#6442 13,770 s -8.4% 4,380 s -11.7%

    This is the clearest gain so far: about 12% for cache-command, whose scenarios consist almost entirely of short wp calls, and about 8% per job for core-command (-2.4% in total, which the noise of that package can hide). It also saves a PHP process for every wp command run outside of the tests.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions