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

[FrameworkBundle][HttpKernel] Add the ability to enable the profiler using a parameter#43138

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

@dunglas
Copy link
Member

@dunglasdunglas commentedSep 22, 2021
edited
Loading

QA
Branch?5.4
Bug fix?no
New feature?yes
Deprecations?no
Ticketsn/a
LicenseMIT
Doc PRtodo

The Symfony Profiler is a convenient development tool, however, in some cases, it has a huge overhead.
I used Blackfire to benchmark a development environment on a real-world project and noticed that the average response time was reduced by 30% just by disabling the profiler.

This PR adds a new configuration option allowing to enable and disable the profiler on a per request basis using a query parameter, a form field (forPOST requests), or a request attribute. This PR allows keeping the benefit of this tool while improving the developer experience.

To enable it:

framework:profiler:collect:false# Disable collection by defaultcollect_parameter:profile# Enable it if the parameter is set

Note: it's also possible to enable the collection by default and to disable it using the parameter

Then, to have the profiler, the user just has to add?profile=1 to any URL.

chalasr, rmikalkenas, COil, bastien-wink, divine, mmenozzi, eerison, mathieu-coingt, IonBazan, bastnic, and 9 more reacted with thumbs up emojibabeuloula, B-Galati, florentdestremau, and rvanlaak reacted with heart emoji
@carsonbotcarsonbot added this to the5.4 milestoneSep 22, 2021
@carsonbotcarsonbot changed the title[HttpKernel][FrameworkBundle] Add the ability to enable the profiler …[FrameworkBundle][HttpKernel] Add the ability to enable the profiler …Sep 22, 2021
@dunglasdunglas changed the title[FrameworkBundle][HttpKernel] Add the ability to enable the profiler …[FrameworkBundle][HttpKernel] Add the ability to enable the profiler using a parameterSep 22, 2021
@dunglasdunglasforce-pushed thefeat/profiler-collect-parameter branch 2 times, most recently from161e027 to5dcb5c5CompareSeptember 22, 2021 18:00
Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

Some tests are broken

@stof
Copy link
Member

Symfony 2.0 used to have a config setting allowing to provide a RequestMatcher service to activate collecting. This is more flexible than giving a parameter name in the config.

Also note that part of the overhead is caused by the fact that services are decorated with Traceable wrappers, and those would still be used if you enable the profiler withcollect: false

@dunglas
Copy link
MemberAuthor

dunglas commentedSep 23, 2021
edited
Loading

@stof most of the overhead looks caused by the extra IOs, at least on my configuration (Docker for Mac). I checked and just disabling the collection improves the performance of 30%.

Regarding the request matcher, do you know why it has been removed? This probably more flexible but less practicable. Here you can just pass a query parameter to enable/disable the tool without having to change the config. We could even think about a tiny WebExtension to do that (similar to the Blackfire companion).

@florentdestremau
Copy link
Contributor

Suggestion: why not enabling / disabling with a cookie or with some switch in the symfony debug bar ?

onEXHovia reacted with thumbs up emoji

@chalasr
Copy link
Member

The motivation for removing it was to discourage using the profiler in production, as thematcher option was mostly used for that:#24158.

But as you can see in the PR discussion, it was already useful to save some resources in dev at the time, and the performance cost related to collectors is growing since then.
IMHO a query param is good enough.

dunglas reacted with thumbs up emoji

xabbuh added a commit that referenced this pull requestOct 1, 2021
This PR was merged into the 4.4 branch.Discussion----------[HttpKernel] Relax some transient tests| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | no| New feature?  | no| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -As observed in#42824 and more recently#43138, these tests randomly break for some reason.Replaces#42824Commits-------30fa29f [HttpKernel] Relax some transient tests
@chalasr
Copy link
Member

Rebase needed to make the CI green


$request =$event->getRequest();
if (null !==$this->collectParameter &&null !==$collectParameterValue =$request->get($this->collectParameter)) {
true ===$collectParameterValue ||filter_var($collectParameterValue, \FILTER_VALIDATE_BOOLEAN) ?$this->profiler->enable() :$this->profiler->disable();

Choose a reason for hiding this comment

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

no need for thetrue === $collectParameterValue || part, it's a µoptim that we can remove imho

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.

(just one minor comment)

@fabpotfabpotforce-pushed thefeat/profiler-collect-parameter branch fromc196897 toeecff07CompareOctober 30, 2021 10:22
@fabpot
Copy link
Member

Thank you@dunglas.

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

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@Neirda24Neirda24Neirda24 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

8 participants

@dunglas@stof@florentdestremau@chalasr@fabpot@nicolas-grekas@Neirda24@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp