Skip to content

[perf] Restart without Xdebug before the container is built - #8713

Open
SanderMuller wants to merge 1 commit into
rectorphp:mainfrom
SanderMuller:xdebug-check-before-container
Open

SanderMuller wants to merge 1 commit into
rectorphp:mainfrom
SanderMuller:xdebug-check-before-container

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

When Xdebug is loaded, XdebugHandler restarts Rector without it. The check ran in ConsoleApplication::doRun(), after bin/rector had loaded the configs and built the container. The restarted process then did all of that work again.

The check now runs in bin/rector, right after the autoloaders and before the configs load. It still calls setPersistent() and is still skipped with --xdebug, so the behaviour from #5544 stays the same. Workers still start without Xdebug.

I measured on an M4 Pro with Herd's PHP 8.5 and Xdebug in its default develop mode. All runs used a warm cache and --dry-run, with the two sides interleaved:

  • rector-src src/Console, 10 runs per side: CPU median 1.15 s before, 0.76 s after. The ranges, 1.06 to 1.29 s and 0.71 to 0.83 s, do not overlap.
  • Shopware v6.7.6.2 with its own rector.php, 10 runs per side: CPU median 4.98 s before, 4.15 s after. The machine was busy, so the ranges overlap. 7 of the 10 pairs were faster after the change.
  • Without Xdebug there is no restart, and there was no difference: 0.43 s and 0.46 s CPU.

Each run gave the same output on both sides.

-v, the version alias, used to return before the check. With Xdebug loaded, it now restarts first and then prints the same version.

XdebugHandler::check() ran in ConsoleApplication::doRun(), after bin/rector had loaded the configs and built the container. When Xdebug was loaded, the restarted process did that work again.

The check now runs in bin/rector, right after the autoloaders. It still calls setPersistent() and is still skipped with --xdebug.
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.

1 participant