Skip to content

[FrameworkBundle] Don't load the profiler when it is disabled #7071

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

Closed
wants to merge 2 commits into from

Conversation

dlsniper
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? yes (not sure)
Deprecations? no
Tests pass? yes
Fixed tickets #7064
License MIT
Doc PR ~

This fixes the loading of Collector classes seen in #7064 at the cost of not loading them at all in any environment which doesn't use enable: true.

Due to the nature of the change I'm not sure if this is or not a BC break or a bug fix, I'll leave this to you to judge.

Also, I'm happy with this change as it really means that if I want to have debugging tools running in my application I should run with debugging enabled but I'm not sure about others.

Thanks.

@stof
Copy link
Member

stof commented Feb 14, 2013

This is wrong. The profiler configuration has an enabled flag (which default to false so it is disabled in prod by default).

This now forbids enabling it, even when setting it explicitly to enabled: true. It is bug creation, not a bug fix

@stof
Copy link
Member

stof commented Feb 14, 2013

hmm, actually, the issue is that setting it to disabled does not remove the profiler entirely but only disable collecting the data. @fabpot should we had a setting to disable it entirely ?

@dlsniper
Copy link
Contributor Author

@stof that's right. I'm sure the way I've did it is not the best possible but there should be a way to describe that we don't want to need any debugging/profiling related classes loaded at all.

I'll fix the tests/patch things up once we got a direction for this.

Thanks.

@vicb
Copy link
Contributor

vicb commented Feb 15, 2013

@dlsniper I don't have time to lok at the details but the profiler is meant to be activable in prod (you can enable the profiler on a specific URL / IP in such a case) to debug an issue that would occur in prod only.

@stof
Copy link
Member

stof commented Feb 15, 2013

@vicb but the issue is it means that collectors are still registered and so on, even if you never use them. I think we should have a way to remove the profiler entirely if we don't want them (still keeping the config of the default state of the profiler itself between enabled and disabled when the service is registered)

@dlsniper
Copy link
Contributor Author

@vicb I know but in this case I don't think anyone should panic in the other ticket about adding 'debug' classes to the compiled class file as they are loaded anyway, right?

So this ticket would either provide a way to disable the profiler loading in a different way and still allow for usage in prod environment or just close this ticket and carry on.

Clearly I'd prefer the first option, provide a better way to disable the loading of unnecessary collectors and so on. I'll be able to work on this during weekend hopefully.

@vicb
Copy link
Contributor

vicb commented Feb 15, 2013

@stof I understand, it was just a kind warning

@dlsniper

I know but in this case I don't think anyone should panic in the other ticket about adding 'debug' classes to the compiled class file as they are loaded anyway, right?

So let's add all the classes from Symfony, any of them might be use from time to times ! The goal of the cache aggregation is to aggregate the most comonly used classes - really no reason to be offensive here.

@stof
Copy link
Member

stof commented Feb 15, 2013

@vicb the profiler and its collectors are used on all requests as the profiler is a dependency of the kernel.request listener enabling it conditionally.

@vicb
Copy link
Contributor

vicb commented Feb 15, 2013

@stof yes @stof, I understand perfectly. The goal of my message was only to tell that the profiler must not always be disabled in prod as it the case with this PR.

@stof
Copy link
Member

stof commented Feb 15, 2013

@vicb Actually, I think the listener should be removed when there is no RequestMatcher and the profiler is disabled by default

@stof
Copy link
Member

stof commented Feb 15, 2013

hmm, no, it may not work as the profiler still need to run on kernel.request to be able to be activated later during the request :(

@dlsniper
Copy link
Contributor Author

@vicb I didn't wanted to sound aggressive, I apologize if it sounded like that.

I'm well aware that just adding a bunch of classes to cache is not a good thing but given the current situation they are loaded anyway. That's why I said that nobody should panic :) And like @stof said, since those classes are loaded on every request, now, I think we can classify them as commonly used.

Maybe we could add a new parameter in the framework that says skip_profiler, default true. Would that make sense?

@vicb
Copy link
Contributor

vicb commented Feb 16, 2013

@dlsniper no problem. I don't have time to help more these days. both Your pr address true issues but I think the solutions are not the good ones, hence my comments.

@dlsniper
Copy link
Contributor Author

I've reworked the patch to rely on the profiler enabled flag instead of kernel.
Also I've changed the way the Web Profiler Bundle loads as disabling the profiler in dev env will crash the application. I'm not sure this is compatible with Silex, it should be, but let me know how to fix it if not.

I'll fix the tests asap as they are failing on my computer.

@dlsniper
Copy link
Contributor Author

I actually don't know how to fix the tests. I've set the profiler on true, removed it but the tests still fail.
Any help would be much appreciated.

Thanks.

@dlsniper
Copy link
Contributor Author

The last commit should fix the tests, please confirm that the tests still make sense.
I'm almost certain that this will break change will break some functionality, like the one for exceptions only which seems a bit wonky, at least in tests, but I've run out of horses on this one :)

@dlsniper
Copy link
Contributor Author

Note, the tests failed on Travis because random reasons but sure not in the code I've changed :)

@dlsniper
Copy link
Contributor Author

@fabpot any feedback on this one?

@@ -93,7 +93,11 @@ public function load(array $configs, ContainerBuilder $container)
$this->registerValidationConfiguration($config['validation'], $container, $loader);
$this->registerEsiConfiguration($config['esi'], $container, $loader);
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);

if (isset($config['profiler']) && isset($config['profiler']['enabled']) && $config['profiler']['enabled']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

First isset is unnecessary, isn't it?

@fabpot fabpot mentioned this pull request Apr 26, 2013
2 tasks
@fabpot
Copy link
Member

fabpot commented Apr 26, 2013

I've just open a new PR #7859 with some changes. Feedback welcome there.

@fabpot fabpot closed this Apr 26, 2013
fabpot added a commit that referenced this pull request Apr 26, 2013
This PR was merged into the master branch.

Discussion
----------

Profiler activation

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7064, #7071
| License       | MIT
| Doc PR        | symfony/symfony-docs#2565

As stated in #7071, there is no way to disable the profiler completely. Even when the `enabled` flag is set to `false`, the profiler is still registered but the data collectors are not activated.

Now, when `enabled` is `false`, the profiler is disabled. To get the old `false` behavior, you now need to set `enabled` to `true` and set the new `collect` flag to `false`.

Todo:

 - [x] update docs
 - [x] update Symfony SE -- not needed

Commits
-------

88ebd62 fixed the registration of the web profiler when the profiler is disabled
a11f901 [FrameworkBundle] added a way to disable the profiler
f675dd8 Truly disabled profiler in prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants