Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

opcache not invalidating when working with twig files #302

Closed
aloco opened this issue Mar 18, 2021 · 12 comments
Closed

opcache not invalidating when working with twig files #302

aloco opened this issue Mar 18, 2021 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@aloco
Copy link

aloco commented Mar 18, 2021

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

  • Nitro version: 2.0.6
  • Docker version: 3.2.1
@aloco aloco added the bug Something isn't working label Mar 18, 2021
@jasonmccallister
Copy link
Member

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

@jasonmccallister jasonmccallister self-assigned this Mar 18, 2021
@jskrivanek
Copy link

How do I disable opcache with nitro?

@aloco
Copy link
Author

aloco commented Mar 18, 2021

Unfortunately still no changes are updating

@jasonmccallister
Copy link
Member

@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
Copy link
Member

@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
Copy link
Author

aloco commented Mar 18, 2021

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
Copy link
Member

@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
Copy link
Member

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
Copy link
Author

aloco commented Mar 22, 2021

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?
  • Frontend Home single: 2.0-2.2 seconds
  • Frontend Simple sprig component: 0.2 seconds
  • CP Dashboard: 1 second
  • CP Settings: 0.6 seconds
  1. What is the average response time (network tab in the browser) for the users page with opcache disabled?
  • Frontend Home single: 3.2-3.5 seconds
  • Frontend Simple sprig component: 1 second
  • CP Dashboard: 2.2 - 2.4 seconds
  • CP Settings: 1.8 seconds
  1. How much RAM and CPU are assigned to Docker Desktop (Settings -> Resources)?
  • CPUs: 4
  • Memory: 4GB
  • Swap: 1GB
  • Disk Size: 59.6 GB (12 GB used)
  1. What paths to you have listed for sharing with mounts (Settings -> Resources -> File Sharing)?

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

  1. Are you mounting a single site or an entire "dev" folder?

Single site, currently there are 5 sites running.

@aloco
Copy link
Author

aloco commented Mar 24, 2021

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
Copy link
Member

@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
Copy link
Author

aloco commented Mar 26, 2021

@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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants