Skip to content
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

[9.x] Allow disabling checks for expired views #44674

Closed
wants to merge 3 commits into from

Conversation

browner12
Copy link
Contributor

@browner12 browner12 commented Oct 21, 2022

One of the changes @nunomaduro made in #44487 reminded me of a similar PR (#31206) I'd done about 2 years ago that was merged and then reverted due to a reported edge case bug.

The reported bug was that the view:cache was not correctly caching registered vendor views. I wish I'd have looked closer 2 years ago, because I've been testing all day, and everything seems to be working well to me, and I can't find any noticeable change in the framework that would've changed this behavior.

With that said, this is a resubmission of that original PR (#31206), with essentially no changes. This change takes Nuno's optimization on compiled views a step further. The root of the problem is the $this->compiler->isExpired($path) method is a relatively expensive call, and it can get called a large number of times if:

  1. you have a large number of views/components necessary for the page rendering
  2. you render the same view/components multiple times on the page

So the goal is to avoid unnecessary calls to isExpired(). Nuno's change in #44487 solves scenario 2 by building up a local cache of file paths already compiled, and then checking for the path value in the array on subsequent calls. The changes in this PR actually solve both scenarios because you can now explicitly tell the CompilerEngine to never check if the path is expired and to assume the file is compiled validly. This is intended to be a production only feature, and will only work if you run php artisan view:cache as part of your deployment.

So to start, could I first get a little confirmation from others that vendor registered views are being compiling with artisan view:cache. After that the PR should be good to review.

Check out the previous PR for the performance improvement data.

add a new boolean on the `CompilerEngine` that lets us turn off checking if views are expired.

this provides performance improvements by avoiding the slightly costly filesystem checks.
@taylorotwell
Copy link
Member

How does this address the issues we had with the original PR?

Copy link
Contributor

@milwad-dev milwad-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

some package service providers will register their views using a relative path notation:

```php
$this->loadViewsFrom(__DIR__.'/../resources/views', 'courier');
```

this is causing a divergence for views compiled via `artisan view:cache` and views compiled on first load.

this change will register the "realpath" if available, and fallback on the given path.
@browner12
Copy link
Contributor Author

Temporarily converting to draft while I figure out the best course forward for the edge cases.

@browner12 browner12 marked this pull request as draft October 24, 2022 05:08
@driesvints
Copy link
Member

Hi there. We fixed the failing tests on 9.x which are causing this PR to fail as well. Can you please rebase your PR with 9.x? Thanks

@driesvints
Copy link
Member

@browner12 feel free to resend this once you've figured out a way forward here. Thanks.

@driesvints driesvints closed this Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants