For future reference:
I just had to troubleshoot a script that ran so long that it eventually died without any relevant errors ([pid 6048:tid 139809649469184] (104)Connection reset by peer: [client 184.4.89.70:0] FastCGI: comm with server "/var/run/a49982b9-remi-safe-php81.fcgi" aborted: read failed, referer
was getting written to the Apache error logs).
Thankfully I was able to reproduce the issue locally. Here are the steps I took in Warden to troubleshoot:
In pub/index.php
I added this line: set_time_limit(15);
above the $bootstrap->run($app);
cd <PATH TO MAGENTO 2 DIRECTORY>
# I then reproduced the error on my frontend, ensuring that the 15 second time limit had been hit
# Then, I enabled the "Profile" option in the Xdebug helper: https://take.ms/1HYDh
# Reload the frontend to generate the cachegrind profile
# Now, copy the cachegrind file to a place where it will sync to the host Mac machine
warden env exec php-debug bash
ls -lha /tmp/
mv /tmp/cachegrind.out.1701815273._var_www_html_pub_index_php__customer_account_index_.gz /var/www/htm
# Now, on my Mac
brew install qcachegrind
qcachegrind
# Now, open the <PATH TO MAGENTO 2 DIRECTORY> cachegrind.out.1701815273._var_www_html_pub_index_php__customer_account_index_.gz file
In qcachegrind, you can analyze what code was run to find the issue:
MCG is another option for a cachegrind GUI: http://mcg-app.com/
I find its UI a little easier to navigate: