@robert:
Are you sure, that the PHP process runs 24 h a day?
On some cheap installations, the PHP process dies after some time of not running. The PHP process then needs to start for the āfirstā webpage, what needs some time. The next webpage is very much fasterā¦
What @anon77445132 wrote is correct. Starting up a PHP worker takes a lot of time (a few seconds), so if there is none because there havenāt been requests in a while, itās normal for the first page load to be slower. And because that startup time is spent before Kirby is even loaded, we canāt do anything against that.
What you could try to verify if this worker timeout is the issue:
Load a page with many thumbs, note down the response time.
Load the page again, note down the response time.
Wait for a ālonger periodā.
Load a page that doesnāt have any thumbs and note down the response time.
If the page without thumbs takes long to load as well, it canāt be related to thumbs.
@lukasbestle@anon77445132 No, itās not the starting up of a PHP worker:
The concrete website is hosted at a provider and starts with a login-page - without any image. This login-page comes as fast as it should. The website is a gallery of a approx. hundred of images. This gallery is paginated, so that on every page a dozen of images are shown. The long loads are on every new (paginated) page. When a page is reloaded the loads are very quick.
To mention it explicit: The load times are measured on server side.
@robert:
Does the website or your hoster use any cache or CDN?
Does your browser use any add-in that shows something like a cache?
Have you changed your /site/config/config.php to use the Kirby cache or another cache or CDN?
Thanks for the details. I agree that it canāt be the worker processes then. Iād also rule out the OpCache as that only caches the code files, not any type of generated content.
But the issue is still strange. I donāt know where to start debugging as I canāt reproduce it.
@anon77445132 Deactivating the opcache-module results only in slower overall performance of execution of kirby.
@lukasbestle As mentioned in my post from 2017-01-30 there seems to be a problem with the execution of call_user_func_array($function, $arguments) in toolkit/helpers.php. The calls results in slow āfirst time executionā for the image-objects. Maybe this is an PHP-internal effect?!
Theoretically, the execution of call_user_func_array() was optimized in PHP7, but in this case it is not faster.
As I have not enough PHP-knowledge, Iām not able to further investigate the specific calls, which are executed during getting/preparing an image.
I canāt be call_user_func_array(), especially not because we use this function (with Kirbyās call() helper) a lot, not only for thumbs.
But of course call_user_func_array() calls a function and that function might/will be the bottleneck (or some other function that is called by that function). However we donāt know where to start debugging if we canāt reproduce the issue.
@lukasbestle Is there a way to produce a log (including timing) with āallā inner-calls for call_user_func_array()? Iām not that familiar with PHP, so I need assistance to do that. After that I can give you the resulting log-file.
@lukasbestle Itās curious. When Xdebug is enabled, the logged timings says that the site runs faster with Xdebug enabled in comparison to when Xdebug is disabled. That canāt be right. And the fact is, that the site doesnāt runs faster, only Xdebug tells it runs fast. ???
E.g. Xdebug says that in worst case the site needs 670 ms to load (best case 120 ms - both would be fine). But in real the site needs approx. 4500 ms (timings measured by FireFox). The GET page itself needs this time (page-size: 2,4 KiB). All other elements like images and scripts are taken from FireFoxās cache (0 ms).
The results tell us that site/snippets/gallery.php is the file that generates the largest part of the delay in this request. But they donāt tell us which function that is called by the snippet is the issue (the thumb stuff itself is very fast with 34ms). Could you please post the gallery snippet?
To identify the part of code, where the most time is spent, I inserted profiling code in Lines 17 and 23. The long running part is the statement $newimage = $item->image()->crop($width, $height, 15);.
@robert:
What are the times, if you delete temporarily for a test:
->crop($width, $height, 15)
If this is quicker, it may be the crop function. Otherwise these files may be very big and therefore the loading of the files takes some time respectively the hard drive needs some timeā¦
@anon77445132: The tests I did before showed, that kirby does not create the thumbs when they exists. As it should be, kirby delivers the previous generated thumbs. I think the most of the time is required by determining the file-properties by PHP. But as I told before (in previous posts) Iām not familiar with PHP, so I cannot investigate deeper. So I hope you and others can help me.
And as you can see in the graphs attached below, the images for the gallery have a size of a few KiB. The original images are much bigger in size. This is required due to show them in a detailed-view.
@anon77445132, @lukasbestle: For your information the timings at FireFox. FireFox uses the cached files! The page-generation lasts 8007 ms!