-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[7.x] Allow disabling checks for expired views #31206
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
Conversation
add a new boolean on the `CompilerEngine` that lets us turn off checking if views are expired and recompiling them.
make sure we keep the behavior the same if the config variable doesn't exist
|
What are the results without blackfire. Blackfire doesn't give an accurate view of the real improvements, because of the profiling overhead. Could you do a comparison just by timing the http requests? |
|
It's very difficult to get a good grasp of the impact this makes when comparing across multiple requests, because of the variance we see when just refreshing a simple page. For example, from my simple example above I can see variation from 400ms to 900ms by just refreshing the page without changing anything. That's why I went the route of showing, on average, how much time the Therefore, the important thing to focus on is that if you're loading 50 views, on average you will take off 35ms from whatever your total request time would have been. |
|
Just had a go at running this in production (setting It seems that I wonder if there is an easy way to include views from packages in the precompilation, or whether there should be a clear caveat in |
|
I have the exact same issue but this time with Horizon: I really like this feature but it looks like the (I've opened up an issue #31789 to track this) |
|
I've encountered the same bug and did some research to try to fix it. In my case, it was related to Laravel telescope. My understanding of what was happening is:
$this->loadViewsFrom(
__DIR__.'/../resources/views', 'telescope'
);
A way to fix thisThis bug could be solved if hinted paths from the Index: src/Illuminate/View/FileViewFinder.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/Illuminate/View/FileViewFinder.php (revision eac5d68779cc7e9db91a9546ce93f6af605de51f)
+++ src/Illuminate/View/FileViewFinder.php (revision 372448c1e2c4a4fd9ae65f60cbc7a828dfed645d)
@@ -192,7 +192,7 @@
*/
public function addNamespace($namespace, $hints)
{
- $hints = (array) $hints;
+ $hints = array_map([$this, 'resolvePath'], (array) $hints);
if (isset($this->hints[$namespace])) {
$hints = array_merge($this->hints[$namespace], $hints);
@@ -210,7 +210,7 @@
*/
public function prependNamespace($namespace, $hints)
{
- $hints = (array) $hints;
+ $hints = array_map([$this, 'resolvePath'], (array) $hints);
if (isset($this->hints[$namespace])) {
$hints = array_merge($hints, $this->hints[$namespace]);
@@ -228,7 +228,7 @@
*/
public function replaceNamespace($namespace, $hints)
{
- $this->hints[$namespace] = (array) $hints;
+ $this->hints[$namespace] = array_map([$this, 'resolvePath'], (array) $hints);
}
/** |
|
well this sucks. sorry guys. I'll do a little digging to see if we can make this play nicely with everything. |
|
As far as I can tell @ksdcsk is on the correct path and #31804 should have fixed the problems. To provide some extra context / story: The The If we look at how Horizon registers it views (source -> source) but these namespaces are stored as hinst "as is" without resolving the real paths (source). So this means that a Horizon view is cached as: instead of how the So either |
|
I really like the idea of this PR. It does seem very unnecessary to run these checks in an environment where the files never change (of course assuming the performance difference is noticeable). Would it make sense to only skip the modified check, and still always check for file existence? This would solve the issue here, and it would not crash if the cached files for any reason are removed. The big question is of course how this affects the performance gain, i.e. the relative weight of one |
This is a resubmission of #31195 with some performance results.
I did my best to isolate this change, so we could see the performance impact specifically from this change, so I kept the request as simple as possible.
Route:
Controller:
Parent View:
Child View:
The execution savings are entirely dependent on how many views need to be rendered for a given request. In the example above it is set at 51 (1 parent + 50 children). I varied this number to see savings for different scenarios.
The following is the inclusive time of the
isExpired()method:The following are the total times of the request:
Based on these numbers our average savings per request by implementing this feature are:
So we see, as expected, the more views that need to be rendered, the bigger percentage it takes up of your request. Looking through some of our sites, it's not uncommon to see some pages with 40-50 views rendered.
Here is a screenshot of Blackfire comparing a 100 view run with the new feature disabled to with it enabled.
We can see the calls are identical, except we drop a large number of calls to
isExpired()and the filesystem functions it calls.