-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
php-cs-fixer chokes on this file #3996
Comments
worst case scenario: automatically skip files that are bigger than 1MB or sth... |
@keradus I don't think the file size is the problem here. I just deleted half the lines and ran again (630 KB), and still nothing. My first try to anonymize the file was to do |
Actually, ignore my last remark. Turns out I made an error in the PHP anonymized version and had accidentally also replaced the opening |
in case it helps: I tried running the |
crazy idea - did you let rule run for 30 minutes ? I wonder is it simply slow, but in the end finishing, or it fall into some never-ending loop |
I let it run for about an hour, but then I had to reboot the machine because of something else. Will try again tomorrow and see if it finishes before the weekend.. |
thanks for info. with 1 hours execution time, I bet more time won't help, it's some infinite loop in that case |
if we instert sth in the middle of tokens, we shall rearrange the token instances, yes but that shall still finish execution ultimately, like @flack run it for an hour |
Small update: I tried running it again, and it actually finished eventually:
so it took almost four hours to run one fixer on this file. I think it's safe to say that fixing it manually would have been faster, even if I took a lunch break in between :-) Isn't there a way to optimize this? The file contains 66307 commas, so (if we assume every one of those needed a whitespace), it took 0.2s per comma to process. |
thanks for running it !
if you would find one, you are welcome to incorporate it ;) File is big, way bigger than file created by human. Maybe we shall officially suggest to not bother about CS for autogenerated, DB-migration/dump files... Overall issue is that if we have 50k places to insert new token, we need to move the following tokens 50k times, as @kubawerlos mentioned. In general, it is possible to change how we operate on tokens collection:
Of course, there may be more possible solutions. From my point of view, amount of work to even try a single solution is huge, while issue we are facing here is not common (almost nobody try to run a PHP CS Fixer against that kind of files) |
@keradus yeah, that sounds like a lot of effort. A naive idea I just has would be maybe not to insert tokens into the existing stream, but rather write (both existing and new tokens) to a new one. So the function gets the old stream in and returns the modified one. Would use more memory (probably twice as much?), but if you only append to the new stream, you wouldn't have to move so much stuff. Anyhow, I agree it's a rather exotic situation, and skipping these kinds of files is fine. But when you run against a large file tree, you still have the problem that |
P.S.: Just for completeness's sake: I ran again aginst the fixed file, and as expected it's a lot faster now:
|
awesome, thanks for checking that ;) |
I know it took a while, @flack , but the fix for this was not obvious. What you reported originally is:
What I experience on my PR with my laptop is:
3.7h vs 4s ;) |
@keradus thanks for the followup! And wow, those are some impressive numbers :-) I've checked out #4250 locally and let it run against the same project as earlier. Unfortunately, there still seems to be something wrong with my local setup, I've started the run like 30mins ago, and it's still ongoing and hogging 100% of one CPU core. I'll try to narrow it down a bit more tomorrow and if I find something interesting, I'll post on the PR |
I only updated one of the rule, maybe other one would require similar improvement. feel free to dig into it, let's solve it as well. thanks ! |
@keradus looks like this was a false alarm: Turns out when you run So my real numbers look like this:
So everything looks good now. Thanks again for the massive speedup! |
Great to hear , love to see it working ! |
#4250 got merged, closing this topic for now |
As discussed in #3224, here's my standalone report:
The PHP version you are using (
$ php -v
):PHP CS Fixer version you are using (
$ php-cs-fixer -V
):The command you use to run PHP CS Fixer:
If applicable, please provide minimum samples of PHP code (as plain text, not screenshots):
I had to rename the file to
.txt
, otherwise github wouldn't let me upload it. Should be changed back beofre trying to reproducet_user.txt
The text was updated successfully, but these errors were encountered: