Replies: 2 comments
-
|
This reeks of AI slop, sorry. You can switch to OrbStack, or you can try this: https://www.halcyon.hr/posts/tweaking-docker-for-mac-performance-for-php-and-symfony/ |
Beta Was this translation helpful? Give feedback.
-
|
Hi Ondřej, I’ve been using Orbstack since its early days—the filesystem performance gains are excellent. That said, this approach still further reduces total runtime on large codebases with ~12 parallel processes. Since PHPStan runs after each Claude Code feature iteration, every saved second compounds quickly. Thought this might be useful to others as well, looking for the maximum performance. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Running PHPStan in parallel inside Docker on macOS (Docker for Mac, Orbstack, etc.) on large codebase suffers from two I/O bottlenecks caused by bind-mounted volumes:
Solution
All PHPStan file I/O is moved from the bind mount to RAM through a three-layer caching strategy:
Layer 1: RAM-Backed Filesystem
A Docker tmpfs volume (512 MB) shadows the bind-mounted PHPStan directory. On container start, the entrypoint script performs a one-time copy from the host bind mount into RAM. From that point on, all file access — phar reads, cache reads, cache writes — hits RAM instead of the virtualization layer.
PHPStan's
tmpDiris explicitly configured to reside within this tmpfs, ensuring the result cache benefits from the same optimization.Layer 2: PHP Process Memory
The phar archive is pre-loaded into PHP's process memory at startup via
phar.cache_list. When PHPStan spawns parallel workers, each worker already has the deserialized phar in memory — no filesystem access needed at all.Layer 3: Safety Net
A Makefile dependency target verifies the tmpfs is populated before every PHPStan invocation, handling edge cases where the entrypoint didn't run.
Data Flow
Host bind mount (slow)
→ one-time copy on container start →
→ tmpfs RAM volume (fast)
→ phar.cache_list on PHP startup →
→ PHP process memory (fastest)
Each layer eliminates a class of I/O:
Beta Was this translation helpful? Give feedback.
All reactions