Diagnosing large delay in file sync to Docker for Mac Preface: I understand that Docker for Mac has file syncing performance issues, but everything I've read about the issues is related to slow read access. I don't really have a problem with slow read access. My problem is that updates I make to files on my host machine can sometimes take 10+ seconds to update on the running container!

Here's my docker-compose file:

version: '2'

services:
  ps-cms:
    image: [obfuscated]
    container_name: ps-cms
    mem_limit: 2048M
    ports:
      - "9080:80"
      - "9443:443"
    volumes:
      - .:/var/www/html/site:cached
      - ./xdebug.ini:/etc/php/conf.d/docker-php-ext-xdebug.ini
    environment:
      - MYSQL_HOST=ps-db
    networks:
      - connector
    extra_hosts:
     - "mysite.localhost:127.0.0.1"

  ps-db:
    image: mysql:5.6
    container_name: ps-db
    mem_limit: 512M
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
    ports:
      - 33006:3306
    networks:
      - connector

networks:
  connector:


Software:

Docker Engine: 18.03.1-ce
Docker Compose: 1.21.1
Docker Machine: 0.14.0
PHP Storm: 2018.1

In the Docker for Mac preferences, under "file sharing", I removed everything there and just added my one project folder, since I heard that can affect performance.

Does anyone have advice on what could be causing this sync delay?
I figured this out, and it was related to the opcache settings for PHP in my docker image. The opcache re-validate frequency was set to 60 seconds, meaning that PHP caches files in memory for that long before referring to the filesystem again. Changing this to 2 seconds resolve the issue, but adds a significant performance penalty :(.

See more info: https://drupal.stackexchange.com/questions/253111/delay-in-code-changes-on-custom-pages-in-drupal-8-in-a-docker-environment