/admin/modules and Views Edit pages take forever to load I recently noticed that two specific sections of my site are taking forever to load, /admin/modules and /admin/structure/views/view/{any-view}/edit. Before I disabled the PHP max_execution_time (only temporarily), it kept timing out at 5 minutes. 

Now that the timeout is disabled, the mysql server is going away. I've seen a lot of suggestions that max_allowed_packet should be 100M+, so I set it to 500M for some ridiculously high value. Last time I hit that page had to have been ~15-20 minutes ago, and it's still just sitting there.

The only thing I have done recently to it was moving a TON of images into sites/default/files from another web server. (~ 25Gb)

Does anyone know why admin/modules and the View Edit pages are taking forever? It's only those two sections. The public side of the site is fine, the other admin parts are fine, it's just those two places.
I found more information on this and have fixed it.

I guess that when Drupal has enabled modules that are missing from the filesystem (this happened as we're using Capistrano to deploy and I didn't sync the two sites correctly), it recursively keeps calling file_scan_directory() trying to find the missing modules, and that causes the site to timeout.

References:

Avoid re-scanning module directory when multiple modules are missing

Drupal 7 speed issue: file_scan_directory called > 1000 times per page load

Used XHProf to see what the call stack looked like over the course of loading /admin/modules and found over 5,000,000 function calls. By contrast, any other page had about 30,000 ~ 50,000 function calls.