Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blackfire: Add distributed profilling support #2586

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 25, 2023

As per blackfire docs this is what is necessary to use distributed profiles with blackfire.

I was not yet able to verify it works, since the plan I am on seems to not include distributed profilling.
I have to double check on my personal notebook, where I have more advanced features available.

In case PHPStan has a license with distributed profilling enabled, you may be able to test on your own, whether it works.

The goal is, to gather profiles which show the main and the worker processes at the same time like shown in

subprofiles

https://blackfire.io/docs/profiling-cookbooks/distributed-profiling#distributed-profiling

until now, I was using blackfire only without parallel workers enabled, but this might help to also profile the parallel scenario which is what the PHPStan users are in the end using most likely.

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@@ -60,9 +60,16 @@ public function start(callable $onData, callable $onError, callable $onExit): vo
if ($tmpStdErr === false) {
throw new ShouldNotHappenException('Failed creating temp file for stderr.');
}

$env = $_ENV;
if (class_exists('BlackfireProbe') && \BlackfireProbe::isEnabled()) {
Copy link
Contributor Author

@staabm staabm Aug 25, 2023

Choose a reason for hiding this comment

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

this class is available when the php process was started via blackfire CLI like

blackfire run --ignore-exit-status php bin/phpstan analyse

@staabm staabm changed the base branch from 1.11.x to 1.10.x August 25, 2023 12:37
@ondrejmirtes
Copy link
Member

When I try a parallel run with this PR and Blackfire enabled, it gets stuck on:

phpstan pr2586 $ blackfire run php -d memory_limit=448M bin/phpstan
The profile will be stored in your Personal environment. The "--environment" option can be used to specify the target environment.
Note: Using configuration file /Users/ondrej/Development/phpstan/phpstan.neon.
    0/1559 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%

And does not move.

It'd be nice if it worked but it's not a big deal, we can profile performance issues in a single thread.

@ondrejmirtes
Copy link
Member

Oh it moves, but it's very very slow. Much slower than profiling a single thread.

@staabm staabm marked this pull request as draft August 26, 2023 09:27
@staabm staabm closed this Sep 29, 2023
@staabm staabm deleted the distri branch September 29, 2023 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants