-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel][VarDumper] Truncate profiler data & optim perf #23465
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
Conversation
nicolas-grekas
commented
Jul 10, 2017
•
edited
Loading
edited
Q | A |
---|---|
Branch? | 3.3 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #23415, #21547 and hopefully #23110 and #23175 |
License | MIT |
Doc PR | - |
protected function getCasters() | ||
{ | ||
return array( | ||
'*' => function ($v, array $a, Stub $s, $isNested) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be the main fix: nested objects are truncated, which prevent deep recursion into nested structures by default (eg "object" of the security decision log, requests attributes, etc.)
$i = 0; | ||
$prefixedKeys = array(); | ||
foreach ($a as $k => $v) { | ||
if (isset($k[0]) && "\0" !== $k[0] && !property_exists($class, $k)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as shown by profiles in linked issue, this is a hot code path and calling property_exists()
should be prevented
@@ -210,14 +210,12 @@ public function cloneVar($var, $filter = 0) | |||
$this->filter = $filter; | |||
|
|||
try { | |||
gc_disable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shown also in linked profiles: cloning involves lots of Stub
objects, thus can trigger lots of GC calls, for no benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt we only re-enable based on gc_enabled()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Hey, I have just tried this fix and it indeed improves performance a lot. Basically it runs as fast as 3.2 did. Good job :) |
02c613e
to
0b3ee2d
Compare
Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), | ||
); | ||
}, | ||
ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add this caster in the new Validator panel in 3.4 too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's for you @ogizanagi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll check this once this is merged on 3.4.
13d571a
to
1037f82
Compare
return array( | ||
'*' => function ($v, array $a, Stub $s, $isNested) { | ||
if (!$v instanceof Stub) { | ||
foreach ($a as &$v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-grekas have you checked whether the usage of a reference here could be the reason why #23110 and #23175 happen (replacing the EntityManager somewhere it should not be replaced, and replacing the content of $_SESSION
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the reference so that if this is correct, then it might be fixed
1037f82
to
1d00ba8
Compare
1d00ba8
to
22c0e5d
Compare
22c0e5d
to
754d3a7
Compare
…f (nicolas-grekas) This PR was merged into the 3.3 branch. Discussion ---------- [HttpKernel][VarDumper] Truncate profiler data & optim perf | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23415, #21547 and hopefully #23110 and #23175 | License | MIT | Doc PR | - Commits ------- 754d3a7 [HttpKernel][VarDumper] Truncate profiler data & optim perf
This PR was merged into the 3.3 branch. Discussion ---------- [Profiler] Fix data collector getCasters() call | Q | A | ------------- | --- | Branch? | 3.3 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Relates to #23465. Calling `DataCollector::getCasters()` using self results into overridden methods in child classes never been called. Also removes an unused property. Commits ------- 34e7094 [Profiler] Fix data collector getCasters() call
…taCollector::getCasters() method (ogizanagi) This PR was merged into the 3.4 branch. Discussion ---------- [Profiler][Validator] ValidatorDataCollector: use new DataCollector::getCasters() method | Q | A | ------------- | --- | Branch? | 3.4 <!-- see comment below --> | Bug fix? | no | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #23465 (comment) <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A ~~First commit targets 3.3; see #23516 I didn't re-used the `ConstraintViolationInterface` caster used in the form collector, as it's the purpose of the validator collector to show the constraints data. Commits ------- c725a70 [Profiler][Validator] ValidatorDataCollector: use new DataCollector::getCasters() method
Could we have an opt-in for this? As we can see in a few issues, this loses some information that might be useful to the developer. It could be nice to be able to "tune" a "deep debug" or "simple debug" something like that... 🤔 |
… objects (ogizanagi) This PR was merged into the 4.4 branch. Discussion ---------- [Messenger][Profiler] Remove cutting caster to dump full objects | Q | A | ------------- | --- | Branch? | 4.4 <!-- see below --> | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Obviously, not the ideal solution, but might open the discussion. Not being able to inspect more than 1 level deep in the profiler when dealing with DTOs and VOs in your messages is a pain 😕. You can't either access the `HandledStamp` `result` for instance. This caster truncating collectors data was originally added in #23465 to mitigate performances issues, especially with the Form profiler. But actually a lot of useful information are now hidden to the developper. Opting-out per collector might be a start. Either allowing to do it through config, or directly in code where sensible. Commits ------- e4fc5c0 [Messenger][Profiler] Remove cutting caster to dump full objects