Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WebServerBundle] Add support for Xdebug's Profiler#28298

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@maidmaid
Copy link
Contributor

@maidmaidmaidmaid commentedAug 28, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets/
LicenseMIT
Doc PR/

Xdebug's Profiler is a powerful tool that gives you the ability to analyze your PHP code and determine bottlenecks or generally see which parts of your code are slow and could use a speed boost.

https://xdebug.org/docs/profiler

When we run/start the web server, it would be useful to enable the trigger for the Xdebug's Profiler. That means we could easily trigger the creation of a Xdebug profile and analysing itthanks to PhpStorm which provides anExecution Statistics panel (examine the summary information about execution metrics of every called function) and aCall Tree panel (explore the execution paths of all called functions). You can see these two panels in actionhere for a better understanding.

return$this->hostname.':'.$this->port;
}

publicfunctionisXdebugUsed()

Choose a reason for hiding this comment

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

I'm not sure adding this publilc method makes sense.
Let's useextension_loaded inline instead, don't you think?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

If we inline it, the developers could no longer disable this feature if wanted. Ok for you ?

Copy link
Member

Choose a reason for hiding this comment

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

Nobody is going to extend this class anyway.

@nicolas-grekasnicolas-grekas added this to thenext milestoneAug 30, 2018
@fabpot
Copy link
Member

I would add a flag instead.

@maidmaid
Copy link
ContributorAuthor

Could you be more precise please ?

@fabpot
Copy link
Member

Being able to use an option (sorry, doing too much of that other language that is not PHP) on commands:--enable-xdebug or something similar.

@maidmaid
Copy link
ContributorAuthor

--enable-xdebug

IMO, this feature should be enabled by default (if xdebug extension is loaded of course), so if we really want make this feature controllable,--disable-xdebug should make more sense. But I'd prefer to make it simple by not making it controllable : if xdebug extension is loaded, then use it, else do not.

@maidmaidmaidmaidforce-pushed thewebserverbundle-xdebug branch 2 times, most recently frome25fe30 to62852abCompareAugust 30, 2018 19:01
@nicolas-grekas
Copy link
Member

I'm wondering: why would you need to do this? I mean: can't you change your php.ini instead and get the same result in a more flexible way (i.e. don't force the setting to everyone?)

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedAug 31, 2018
edited
Loading

Or can't we makephp -dxdebug.profiler_enable_trigger=1 bin/console server:run work instead?

@maidmaid
Copy link
ContributorAuthor

php -dxdebug.profiler_enable_trigger=1 bin/console server:run

I thought that worked firstly, but it actually does not because we enable it only in the main process, not in the sub process runningphp -S 127.0.0.1:8000

@nicolas-grekas
Copy link
Member

Yep I know, but wecan make it work. It would be better IMHO. We could even make it work for all xdebug ini settings if it makes sense, isn't it?

@maidmaid
Copy link
ContributorAuthor

maidmaid commentedAug 31, 2018
edited
Loading

We could even make it work for all xdebug ini settings

After checking again the settings described inhttps://xdebug.org/docs/all_settings, just enabling the trigger of the profiler seems relevant IMO.

}

$process =newProcess(array_merge(array($binary),$finder->findArguments(),array('-dvariables_order=EGPCS','-S',$config->getAddress(),$config->getRouter())));
$xdebugArgs =\extension_loaded('xdebug') ?array('-dxdebug.profiler_enable_trigger=1') :array();
Copy link
Member

Choose a reason for hiding this comment

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

should we check whether this setting is enabled in the current PHP instead of always adding them ? AFAIK, turning on this feature adds overhead to the execution of PHP, as Xdebug needs to instrument the code (even though it does not actually collect the profiling data).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It's the reason why I turn on only the trigger of the profiler but not the profiler itself, whose the overhead is insignifiant.

@nicolas-grekas
Copy link
Member

I would really prefer this to be made to work withphp -dxdebug.profiler_enable_trigger=1 bin/console server:run instead.

@maidmaid
Copy link
ContributorAuthor

@nicolas-grekas Could you review the last version I committed ?

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

(with minor comment)

$config =newWebServerConfig($documentRoot,$env,$input->getArgument('addressport'),$input->getOption('router'));

$io->success(sprintf('Server listening on http://%s',$config->getAddress()));
if (\extension_loaded('xdebug') &&'1' ===ini_get('xdebug.profiler_enable_trigger')) {

Choose a reason for hiding this comment

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

if (ini_get('xdebug.profiler_enable_trigger')) { would be enough to me (same below)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done

$config =newWebServerConfig($documentRoot,$env,$input->getArgument('addressport'),$input->getOption('router'));

$io->success(sprintf('Server listening on http://%s',$config->getAddress()));
if ('1' ===ini_get('xdebug.profiler_enable_trigger')) {

Choose a reason for hiding this comment

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

The'1' === doesn't make really sense.
The really correct way to check a boolean ini setting is by using filter_var:
filter_var(ini_get('xdebug.profiler_enable_trigger'), FILTER_VALIDATE_BOOLEAN)
Seehttp://php.net/manual/fr/function.filter-var.php#121263
I'd suggest to either make a loose comparison (thus my original proposal:if (ini_get('xdebug.profiler_enable_trigger')) {) or a strict one using filter_var, but not something in between.

Copy link
Contributor

Choose a reason for hiding this comment

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

ini_get return the normalized value instead of the one present in thephp.ini file, so the return value will be'1' ou'' here (orfalse if xdebug is not loaded).

Choose a reason for hiding this comment

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

Oh great! Let's useif (ini_get('xdebug.profiler_enable_trigger')) { then, to be consistent with the code base at least.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done

@nicolas-grekas
Copy link
Member

Thank you@maidmaid.

@nicolas-grekasnicolas-grekas merged commit0f4c0a6 intosymfony:masterSep 9, 2018
nicolas-grekas added a commit that referenced this pull requestSep 9, 2018
…aidmaid)This PR was merged into the 4.2-dev branch.Discussion----------[WebServerBundle] Add support for Xdebug's Profiler| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | /| License       | MIT| Doc PR        | /> Xdebug's Profiler is a powerful tool that gives you the ability to analyze your PHP code and determine bottlenecks or generally see which parts of your code are slow and could use a speed boost.https://xdebug.org/docs/profilerWhen we run/start the web server, it would be useful to enable the trigger for the Xdebug's Profiler. That means we could easily trigger the creation of a Xdebug profile and analysing it [thanks to PhpStorm](https://www.jetbrains.com/help/phpstorm/analyzing-xdebug-profiling-data.html) which provides an **Execution Statistics** panel (examine the summary information about execution metrics of every called function) and a **Call Tree** panel (explore the execution paths of all called functions). You can see these two panels in action [here](https://youtu.be/_ua_O01IICg?t=1m22s) for a better understanding.Commits-------0f4c0a6 Add support for Xdebug Profiler
@nicolas-grekasnicolas-grekas removed this from thenext milestoneNov 1, 2018
@nicolas-grekasnicolas-grekas added this to the4.2 milestoneNov 1, 2018
This was referencedNov 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof approved these changes

+1 more reviewer

@jvasseurjvasseurjvasseur left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

6 participants

@maidmaid@fabpot@nicolas-grekas@stof@jvasseur@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp