8000 Odd data in performance tab of the profiler · Issue #49677 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

Odd data in performance tab of the profiler #49677

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
nicolas-grekas opened this issue Mar 13, 2023 · 3 comments
Closed

Odd data in performance tab of the profiler #49677

nicolas-grekas opened this issue Mar 13, 2023 · 3 comments

Comments

@nicolas-grekas
Copy link
Member

Symfony version(s) affected

= 5.4

Description

This profile is strange (RouterListener should span that much). Maybe it's because the listener is throwing?

image

How to reproduce

symfony new test-profiler --version=5.4
cd test-profiler/
composer req profiler
symfony serve

Go to https://127.0.0.1:8000/ and open the "Performance tab" in the Profiler Toolbar.

Possible Solution

No response

Additional Context

No response

@MatTheCat
Copy link
Contributor
MatTheCat commented Mar 15, 2023

Wrapping

($this->optimizedListener ?? $this->listener)($event, $eventName, $dispatcher);
if ($e->isStarted()) {
$e->stop();
}
in try/finally seems to produce the expected output.

try {
    ($this->optimizedListener ?? $this->listener)($event, $eventName, $dispatcher);
} finally {
    if ($e->isStarted()) {
        $e->stop();
    }
 }

@stof
Copy link
Member
stof commented Mar 15, 2023

@MatTheCat can you send a PR ?
And maybe also fix other places using the Stopwatch to do the same.

@MatTheCat
Copy link
Contributor

I also found

$e = $this->stopwatch->start('controller.get_callable');
$ret = $this->resolver->getController($request);
$e->stop();
and
$e = $this->stopwatch->start('controller.get_arguments');
$ret = $this->resolver->getArguments($request, $controller);
$e->stop();

@fabpot fabpot closed this as completed Mar 17, 2023
fabpot added a commit that referenced this issue Mar 17, 2023
This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

Stop stopwatch events in case of exception

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #49677
| License       | MIT
| Doc PR        | N/A

Stopwatch events need to be stopped even if an exception occurred, else they will appear to span across the whole request timeline.

The following screenshots were taken with `RouterListener` throwing in debug mode following a [`NoConfigurationException`](https://github.com/symfony/symfony/blob/0362350a720e38df55531ab0cf726a082d3d34d4/src/Symfony/Component/Routing/Exception/NoConfigurationException.php):

<details>
<summary>Before</summary>
<img src="https://user-images.githubusercontent.com/243674/224777379-1209dfde-8086-49e3-af56-147ceda3e6c9.png" alt="">
</details>

<details>
<summary>After</summary>
<img src="https://user-images.githubusercontent.com/1898254/225371948-a21acf87-203c-49f9-b73a-4947e9a5092a.png" alt="">
</details>

Commits
-------

beca17a Stop stopwatch events in case of exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0