craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

opcache not invalidating when working with twig files #302

Closed aloco closed 3 years ago

aloco commented 3 years ago

Description

With opcache enabled, PHP file changes are recognized as expected and are invalidating the opcache. However, when making changes in twig files, it seems like those are not recognized. The HTML output stays the same. When disabling opcache, changes are always recognized

Steps to reproduce

  1. enable opcache
  2. make changes in a twig file
  3. changes are not visible

Additional info

jasonmccallister commented 3 years ago

Can you disable template caching and see if the changes are updated?

jskrivanek commented 3 years ago

How do I disable opcache with nitro?

aloco commented 3 years ago

Unfortunately still no changes are updating

jasonmccallister commented 3 years ago

@jskrivanek the opcache extension is installed but not enabled by default. If you enable opcache using iniset you can disable it in the same way.

image

jasonmccallister commented 3 years ago

@aloco I just tried and I am getting the same thing. I know Twig has its own template caching. I'm going to ask someone who knows more than I do (aka Brad) and chat with him about it this morning because I know we had this discussion in the past.

aloco commented 3 years ago

Thank you for looking into this! The reason behind using opcache in develoment is performance, currently the control panel is very slow without opcache. (it feels slower than with nitro 1) - enabling makes a huge difference, would be nice if we can use opcache also when working with twig so we don´t have to switch it on and off

jasonmccallister commented 3 years ago

@aloco can you answer the following questions so we can perform some investigation?

  1. What is the average response time (network tab in the browser) for the users page with opcache enabled?
  2. What is the average response time (network tab in the browser) for the users page with opcache disabled?
  3. How much RAM and CPU are assigned to Docker Desktop (Settings -> Resources)?
  4. What paths to you have listed for sharing with mounts (Settings -> Resources -> File Sharing)?
  5. Are you mounting a single site or an entire "dev" folder?
jasonmccallister commented 3 years ago

I found a way to make this work, but may require an upstream change in Craft. Discussing with the team to verify it will not break other changes as expected.

I made this change locally and enabling opcache I can see response times consistently below 300ms with fast updates to Twig templates! 🥳

aloco commented 3 years ago

Hi Jason,

I made some tests with one of our sites in development mode. Currently there is no eagerloading, cache tag etc. configured

1) What is the average response time (network tab in the browser) for the users page with opcache enabled?

2) What is the average response time (network tab in the browser) for the users page with opcache disabled?

3) How much RAM and CPU are assigned to Docker Desktop (Settings -> Resources)?

4) What paths to you have listed for sharing with mounts (Settings -> Resources -> File Sharing)?

/Users /Volumes /private /tmp /var/folders

5) Are you mounting a single site or an entire "dev" folder?

Single site, currently there are 5 sites running.

aloco commented 3 years ago

I found a way to make this work, but may require an upstream change in Craft. Discussing with the team to verify it will not break other changes as expected.

I made this change locally and enabling opcache I can see response times consistently below 300ms with fast updates to Twig templates! 🥳

Hi Jason,

can you point out where to make those changes so we can temporary get this boost as well till it finds it way into a release?

Thank you!

jasonmccallister commented 3 years ago

@aloco after a ton of debugging and investigation with @angrybrad, we have determine this is not a Craft upstream issue but an issue related to the opcache settings, specifically the validate timestamp options.

We are going to make a change to our docker images to set it as an argument and environment variable as well as add a nitro iniset option to manage it for the next release.

For now, here is a quick way you can modify the setting (and any other PHP setting).

Let me know if this helps!

aloco commented 3 years ago

@jasonmccallister @angrybrad thank you guys for looking into this! Looking forward when we can set this via nitro iniset, but for now this works for me!