Skip to content

[Form][EventDispatcher] Fix VarDumper usage related to perf regression #19986

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

Merged
merged 1 commit into from
Sep 21, 2016

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Sep 20, 2016

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

@nicolas-grekas nicolas-grekas changed the title [EventDispatcher] Fix VarDumper usage related to perf regression [Form][EventDispatcher] Fix VarDumper usage related to perf regression Sep 20, 2016
@nicolas-grekas nicolas-grekas force-pushed the fix-perf branch 4 times, most recently from 992bf19 to b31562d Compare September 20, 2016 12:12
@nicolas-grekas
Copy link
Member Author

Not that this PR will also fix the remaining failure on Travis on 3.1.

@nicolas-grekas nicolas-grekas force-pushed the fix-perf branch 2 times, most recently from 23a5e1f to 2be77f5 Compare September 20, 2016 13:34
},
));
} else {
@trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since version 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

this will say that using FormDataCollector::cloneVar without the component is deprecated, but this is a private method. You should probably talk about the public API triggering it instead

Copy link
Member Author

@nicolas-grekas nicolas-grekas Sep 20, 2016

Choose a reason for hiding this comment

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

This has to be done this way: the implementation is changed when the component is not loaded: a string is returned. This mirrors the profiler_dump function that is able to cope with both Data and strings (deprecated). There is nothing related on the public surface.

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw, the same is done in the base DataCollector for BC.

return array(
Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(),
Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(),
Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(),
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't you include the message too ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just checked in the original code. This just mirrors it. LGTM.

/**
* {@inheritdoc}
*/
protected function cloneVar($var)
Copy link
Member Author

Choose a reason for hiding this comment

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

must be protected (as in parent)

@nicolas-grekas
Copy link
Member Author

Now limiting to max-depth=2, which looks more generic than 50 items to me. Internal cache also added to prevent re-cloning the same structures several times. Enhances both perf and serialize payload size.
See https://blackfire.io/profiles/compare/d8d9804b-1939-4a5f-9f47-4ae33c6fc97a/graph

*
* @return array Information about the listener
*/
private function getListenerInfo($listener, $eventName)
Copy link
Member Author

Choose a reason for hiding this comment

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

This method is removed for two reasons:

  • computed values are not used anymore in the profiler panel, only the data-clones are (same king of cleanup already done in FormDataExtractor and in DebugAccessDecisionManager);
  • to prevent computing the same info several times, it needs to be persistent, and this responsibility belongs to the WrappedListener class, that knows best about its wrapped listener.

@@ -67,6 +67,7 @@ protected function cloneVar($var)
if (null === $this->cloner) {
if (class_exists(ClassStub::class)) {
$this->cloner = new VarCloner();
$this->cloner->setMaxItems(250);
Copy link
Member Author

Choose a reason for hiding this comment

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

the default is 2500, too much for here

@fabpot
Copy link
Member

fabpot commented Sep 21, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 294868e into symfony:master Sep 21, 2016
fabpot added a commit that referenced this pull request Sep 21, 2016
…f regression (nicolas-grekas)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[Form][EventDispatcher] Fix VarDumper usage related to perf regression

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

Commits
-------

294868e [Form][EventDispatcher] Fix VarDumper usage related to perf regression
@nicolas-grekas nicolas-grekas deleted the fix-perf branch September 21, 2016 20:48
@fabpot fabpot mentioned this pull request Oct 27, 2016
fabpot added a commit that referenced this pull request Dec 2, 2016
This PR was merged into the 3.2 branch.

Discussion
----------

[Form] Remove unused var cloner property

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

Not used anymore after #19986

EDIT: add missing `use` too.

Commits
-------

0708003 [Form] Remove unused var cloner property
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.

4 participants