Skip to content

Lower the cost of each launched wp process #385

Open

Description

@schlessera

Almost all of the suite's run time is spent in the wp processes the scenarios launch; the Behat process itself accounts for about 3% of a run. Each wp call costs about 0.3 seconds, and the bundled commands make around 9,300 of them per suite run, plus the ones the framework makes itself.

Two things make each process more expensive than it needs to be:

  1. Xdebug. When Xdebug is loaded locally, every child process pays for it. Turning it off for the launched processes took a local cache-command run from 126 to 98 seconds. It should stay off unless coverage is collected or step debugging is requested (see Enable Xdebug in Behat tests #257).
  2. No opcode cache. Every process compiles WP-CLI and the package code from scratch, although that code does not change during a run. Caching only that code took a typical call from about 300 to 200 ms locally. The per-scenario WordPress copies must stay uncached: they are rewritten during scenarios, and a stale compiled file would change what a test exercises.

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 the changes of #401.

    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%
    #401 13,909 s -3.3% 4,942 s +1.8%

    On CI, the difference is within the noise. Xdebug is only installed for the coverage job there, so only the opcode cache applies, and the PHP runners have opcache loaded with opcache.enable_cli off. A second pair of runs with the run time report enabled (baseline and #401 for core-command, baseline and #401 for cache-command) shows the average process taking about 3% less time (median over all jobs), against about 33% locally. On the runners, compiling the framework code is evidently a much smaller share of each wp call.

    Locally, where Xdebug is loaded, a full cache-command run went from 126 to 98 seconds with Xdebug off for the launched processes alone. So this mainly helps local runs, and is not worth it for CI on its own.

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