laravel/pint

Pint is painful to use in large projects

mortenscheel opened this issue · 7 comments

Pint Version

1.18.1

PHP Version

8.3.4

Description

I know that Pint's lack of parallelization has been discussed before in #93, #275 and #299 - but I would like to provide an example of how just how big this problem can be.

My team works on a very large modularized monolith Laravel app. Pint has to process 4698 php files.
On a new Macbook Pro with top specs, this takes at least 12 minutes, and that's when there's nothing it has to fix. When we used php-cs-fixer it took only a fraction of that time.
Of course it only takes this long when there are no cached results, but there are a lot of things that will cause the cache to be busted:

  • If the php-cs-fixer dependency is updated to a newer version.
  • Every time you rebuild your docker container, unless you configure Pint to store the cache inside the project folder.
  • If php is updated to a newer version, even a patch release. This happens rather frequently, especially if run in a docker container using a :latest base image.
  • If you run pint on your host machine and the existing cache was created in docker (or vice versa), because the results are cached using absolute paths.

Every time one of these things happen, we have to sit and wait for at least 12 minutes. That is more than just a minor annoyance, and I hope you'll agree that it's worth looking into.

Steps To Reproduce

  1. Have a Laravel project containing several thousand files.
  2. Run pint.
  3. Go for a walk.

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

12 minutes for 4698 files seems high. For reference, I have a project with 2993 files, and it only takes 56 seconds without using cache on a Macbook Pro with an M3 Pro CPU. I'm using the Laravel preset. Maybe running pint within Docker is causing it to run slower?

@mortenscheel

Since the pull request (#325) has not been merged, you can try the following two methods to see if they fix the performance issue:

XDEBUG_MODE=off php vendor/bin/pint

or

php -d "xdebug.mode=off" vendor/bin/pint

@bepsvpt that was an easy 10x performance improvement 😂 Now it takes ~1 minute. I hope @taylorotwell reconsiders merging your PR.

@mortenscheel

I'm glad to hear that the methods provided above were able to resolve the performance issue you encountered!

Zen0x7 commented

@mortenscheel just to know, which types of files takes more time? On my case #299, i had a couple of files with large arrays declared, just to understand the reason behind the slow performance.

@mortenscheel just to know, which types of files takes more time? On my case #299, i had a couple of files with large arrays declared, just to understand the reason behind the slow performance.

How do you find that out? All I can say is that the process was sluggish, but it didn't seem like it was only a couple of files that were slow.