My friend and I started working on a project that other people stopped developing a couple of years ago, and we are trying to resurrect it. We have already solved most of the problems associated with the installation, but there is really annoying one that we can not understand.
In our local hosts, all pages take A LOT of time to download / update. And I don't mean assets, scripts or anything else, the problem is the delay until the completion of the first request. In most cases, it takes from 15 to 30 seconds, which is unacceptable, and sometimes even reaches 1 or 2 minutes.
For example, here is a screenshot of the Network tab in Chrome dev tools. The first line is the view, the others are the assets.

We worked on the Internet for hours and tried several different things, but none of them worked. Some solutions, such as this one , point to some Apache httpd.conf options, but I dropped it as I use the same server for other projects, and it never happened (I tried it anyway, but it didn't work). Others point to conflicts in the PHP versions, so I tried changing PHP in my MAMP from 5.4.10 to 5.2.17 (the project requires 5.2.3+), but that didn't work either.
Besides installing MAMP, we also tested it on a Windows machine using WAMP (PHP5.5), as well as on another Mac with pure MAMP (PHP5.5), and the same thing happens in both environments. So, now we are wondering if the problem could be in CodeIgniter itself (which seems unlikely) or in some configuration of the project, but we are pretty new to CodeIgniter (and also not PHP experts) and did not find anything.
Oh, and we also tried to contact the original developers, but they said it was two years ago and sounded like they didnβt want to help. I really hope that they did not have this problem when developing the project then, because working with 30 second loading time was insane.
Anyone have an idea or find out about something else that we could try to find a problem? If necessary, I could send the code.
Update: I just found this unresolved question where the user had a similar problem with Laravel, but only occasionally. As I said, in my case it always happens, the waiting time is from 10 seconds to several minutes.
Update 2: As suggested by Wrikken, I ran it through the xdebug profiler, but I'm not sure how to interpret the results to see where the problem is. I opened the snapshot with the PHPStorm Xdebug Profiler Analysis tool and sorted it by the time used in each call. Here are some screenshots:


And sorted by proper time:

The fact that CashewModel displayed on some lines is a special library created by previous developers, which also causes some problems that we have already solved. I hope the problem is not hidden there, because I have no idea how most of this custom code works.
Any ideas? Again, I can send the code if necessary.
Update 3:. Digging into the code, the MY_Controller in the screenshot above is a file in which previous developers created several custom controllers that extend the CI_Controller . I just found out that they threw all the cashew code into GitHub, here is the MY_Controller file .
I will also add here all the relevant code on line 467 (in the GitHub version - 464), which includes the _remap function inside CashewController and where the profiler says that it is CashewController all the time. I translated some comments and names into English.
/** * * Extension of the default controller, adding support for templates * * Usage example: * * class Dummy extends EC_Controller * { * public function index() * { * $this->add_section('id_in_template', 'page_name'); * $this->render_page(); // Renders the default template. * } * } * */ class CashewController extends CI_Controller { // // Some attributes here // function __construct() { ... } /** * We use this _remap to automatically create the CRUD method calls * * @param string $method * @param string $params */ public function _remap($method, $params = array()) { // NEW if ($method == 'new') { $method = '_new'; } // CREATE else if ($method == 'index' && $this->request_method() == 'post') { $method = '_create'; } else if (is_numeric($method) && $this->request_method() == 'post' && count($params) == 0) { $params[0] = $method; $method = '_create'; } // SHOW else if (is_numeric($method) && count($params) == 0) { $params[0] = $method; $method = '_show'; } else if (is_numeric($method) && count($params) == 1 && $params[0] == 'edit') { // EDIT if ($this->request_method() == 'get') { $params[0] = $method; $method = '_edit'; } // UPDATE else if ($this->request_method() == 'post') { $params[0] = $method; $method = '_update'; } } // DELETE else if (is_numeric($method) && count($params) == 1 && $params[0] == 'delete') { $params[0] = $method; $method = '_delete'; } if (method_exists($this, $method)) { return call_user_func_array(array($this, $method), $params); } show_404(); } // // Some more functions // }
So, something is going on inside this call_user_func_array(array($this, $method), $params) , right?