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

Improved performance of LoggerDataCollector #29762

Merged
merged 1 commit into from
Jan 6, 2019

Conversation

javiereguiluz
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

My feeling is that Symfony's "dev" environment is more and more slow lately. After profiling the Symfony Demo app with Blackfire, I found that getContainerCompilerLogs() is one of the slowest methods.

Given that you rarely need or look at these "compiler logs", in this PR I propose to get them only when/if you really need them.

The before/after profile comparison confirms a nice performance improvement and thousands of functions no longer called.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jan 3, 2019

Does this really work?
lateCollect gathers data to be serialized.
getCompilerLogs is called in another request by the profiler.
To me, this PR improves performance by not saving logs, which is not what you want I fear.

@javiereguiluz
Copy link
Member Author

It worked for me when I added this in the lageCollect() method:

$this->data['compiler_logs_filepath'] = $this->containerPathPrefix.'Compiler.log';

Otherwise $this->containerPathPrefix is always null outside lateCollect() and we cannot get the log messages.

But of course it's not enough that this works for me. We need more people to confirm us that this is working for them too. Thanks!

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jan 3, 2019

OK, got it! What this does is share the same log file for all profiles, instead of snapshotting them per profiler. Works for me! (but tests are failing ;) )

@javiereguiluz
Copy link
Member Author

I've fixed tests ... but I'm not sure it's the right fix.

@fabpot
Copy link
Member

fabpot commented Jan 6, 2019

Thank you @javiereguiluz.

@fabpot fabpot merged commit 3b8d6d1 into symfony:master Jan 6, 2019
fabpot added a commit that referenced this pull request Jan 6, 2019
This PR was squashed before being merged into the 4.3-dev branch (closes #29762).

Discussion
----------

Improved performance of LoggerDataCollector

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | -   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | -

My feeling is that Symfony's "dev" environment is more and more slow lately. After profiling the Symfony Demo app with Blackfire, I found that `getContainerCompilerLogs()` is one of the slowest methods.

Given that you rarely need or look at these "compiler logs", in this PR I propose to get them only when/if you really need them.

[The before/after profile comparison](https://blackfire.io/profiles/compare/4959d918-8e00-4cd7-9b0b-41919e73ae62/graph) confirms a nice performance improvement and thousands of functions no longer called.

Commits
-------

3b8d6d1 Improved performance of LoggerDataCollector
nicolas-grekas added a commit that referenced this pull request Jan 25, 2019
…reguiluz)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[VarDumper] Improve performance of AbstractCloner

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | -   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | -

While profiling Symfony in "dev" environment (see #29762) I found that `VarCloner::addCasters()` was making thousands of `strtolower()` calls.

![varcloner-addcasters](https://user-images.githubusercontent.com/73419/50694461-40a1bd80-103a-11e9-83c0-a28b8f8f161e.png)

In this PR I propose to remove all those calls. I think it's possible to do it ... but I could be completely wrong, so please review.

-----

As a side note, in the past we did the same `strtolower()` to service IDs and parameter names. We stopped doing that in Symfony 3.3 and it gave us a small performance improvement (same as we could gain here).

If the `strtolower()` calls of `VarCloner::addCasters()` are made just to apply the caster even if the class name is wrongly spelled, I think we could make this change. My guess is that nothing would break for the user (unlike removing the `strtolower()` in DependencyInjection, which broke wrongly spelled services and params). Thanks!

Commits
-------

cff23e5 [VarDumper] Improve performance of AbstractCloner
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants