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

Performance profiler loading "Processing profile..." forever #109

Closed
natenatters opened this issue Sep 20, 2022 · 6 comments
Closed

Performance profiler loading "Processing profile..." forever #109

natenatters opened this issue Sep 20, 2022 · 6 comments

Comments

@natenatters
Copy link

natenatters commented Sep 20, 2022

Using a fresh Laravel install curl -s "https://laravel.build/example-app" | bash and ran ./vendor/bin/sail artisan migrate.

Added these to my .env:

SAIL_XDEBUG_MODE=profile
SAIL_XDEBUG_CONFIG="client_host=host.docker.internal output_dir=/var/www/html/storage/app"

Then ./vendor/bin/sail composer require itsgoingd/clockwork.
Then ./vendor/bin/sail up.

When I have http://localhost/clockwork/app open in Chrome, then make a request to http://localhost in another Chrome tab, the request appears in the Clockwork app! But, if I click "Profiler", it is stuck on "Processing profile..." forever.

I also get a JS bug in Chrome dev tools, I tracked it down to this line:
https://github.com/underground-works/clockwork-app/blob/master/src/features/callgrind/callgrind.js#L62

The line is a string of value "0", but other times its undefined... So it cant split it by ' '.

Do you know if this is valid? Or if its something wrong with my Xdebug setup/ profiling?

My uneducated guess is that the cachegrind.out.%p files are still being written too when Clockwork requests them, so its only reading half or none of a line. I only think this because I opened one of them and it was always being updated. BUT, could be a red herring.

Thanks for any help. Clockwork is and has always been a great addition to my tools :D

@natenatters
Copy link
Author

natenatters commented Sep 20, 2022

Resolved. It was an issue with my naming convention for the filename.

I changed my .env:

SAIL_XDEBUG_MODE=profile
SAIL_XDEBUG_CONFIG="client_host=host.docker.internal profiler_output_name=cachegrind.out.%R"

This is after advice from Dericks video here: https://www.youtube.com/watch?v=ttQgLBSpVvc

@itsgoingd
Copy link
Member

Hey, have you figured out why do you need to change the profile file name? The default filename uses PID as part of the name, I wonder if the processes get reused under php-fpm and different requests end up writing to the same file effectively corrupting the profile. 🤔

@natenatters
Copy link
Author

natenatters commented Sep 20, 2022

Good guess. The profiler only output 2 files, here are their headers:

cachegrind.out.15

version: 1
creator: xdebug 3.1.5 (PHP 8.1.10)
cmd: /var/www/html/artisan
part: 1
positions: line

cachegrind.out.16

version: 1
creator: xdebug 3.1.5 (PHP 8.1.10)
cmd: /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php
part: 1
positions: line

So I think all the HTTP requests were appended to that cachegrind.out.16 file. If you watch the YouTube video at 1:15 (https://youtu.be/ttQgLBSpVvc?t=74), he says the default profiler_output_name isnt very useful 😆 and recomends the %R (See allowed specifiers here: https://xdebug.org/docs/all_settings#trace_output_name).

@natenatters
Copy link
Author

Sorry if I am posting too much, I am now learning more about Xdebug 😄 In another video, he uses the timestamp in the filename too:

output_dir=/tmp/profiles
profiler_output_name=cachegrind.out.%R.%u

@itsgoingd
Copy link
Member

No, I appreciate the info. I wonder why keep the default tho if it's the case it doesn't work well with php-fpm, which is by far the most used way to run php nowdays.

Personally I would probably use the pid (%p) in combination with timestamp (%u) or random number (%r), but Clockwork shouldn't care.

It might be a good idea to bring this up with Xdebug devs and suggest better defaults here. I will also update Clockwork docs to mention changing this setting.

@natenatters
Copy link
Author

I used WebGrind to read the default filename and it worked fine, so it makes me think its something with Clockwork parsing the file wrong. But not a huge issue.

Perhaps the default file is to make it easier to cleanup, as it could endup filling your tmp directory.

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

No branches or pull requests

2 participants