ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

Linting very slow #5

Closed thijsw closed 8 years ago

thijsw commented 8 years ago

First of all, thanks for this extension! It is very helpful :)

Unfortunately, I encounter very slow linting performance in my project. It is a very straightforward project with just a bunch of classes, some Composer dependencies, and that's it.

Linting a single file in Visual Studio Code takes about a whole minute ("phpcs is linting 1 document ... /"), whereas if I run the sniffer from the command line, it takes around 25-50ms for every file.

Any idea how this is possible?

System: OSX 10.11.4 / 8GB RAM / 4GHz i7

natesilva commented 8 years ago

I am seeing the same problem on Windows, though curiously not on my Mac -- same file being linted. This happens when I'm linting a small controller class file. No other files are open in the Explorer tab of VS Code. Linting is fast from the command prompt.

VS Code: Version 1.0.0 Commit fa6d0f03813dfb9df4589c30121e9fcffa8a8ec8 Date 2016-04-13T14:08:36.599Z Shell 0.35.6 Renderer 45.0.2454.85 Node 4.1.1

PHPCS: PHP_CodeSniffer version 2.6.0 (stable) by Squiz (http://www.squiz.net)

phpcs extension: 0.4.0

OS: Windows 10 Pro (64-bit)

ikappas commented 8 years ago

Hello and thank you for your feedback.

I have just released 0.5.0 which has updated dependencies for vscode 1.0.0 Please update to this version and let me know whether this fixes the issues you are experiencing.

@thijsw Does the file have a lot of linting errors?

marco-kretz commented 8 years ago

I encapsulated the problem. The child_process, which actually does the linting, triggers the stdout, stderr and close stuff, but it takes far too long. I will investigate further!

ikappas commented 8 years ago

@temkretz I am at the same point and tested both spawn and exec but the slowdown is massive...

marco-kretz commented 8 years ago

@ikappas Yes. My observation: The phpcs process created through spawn() is waiting in "SLEEP" state as seen in "ps". Dunno why, will investigate further :)

On my system it gets a nice value of "31" which is very high.. screenshot 2016-04-25 16 40 28

ikappas commented 8 years ago

@temkretz I can also confirm that phpcs 2.6.0 is way too slower than phpcs 2.4.0

marco-kretz commented 8 years ago

Yeah, but if I run the command from commandline it instant finishes.

ikappas commented 8 years ago

True

marco-kretz commented 8 years ago

What confuses me is, that I forked the vscode-language-server-example project from MS, do a cp.exec(phpcs....) and it instantly runs oO

ikappas commented 8 years ago

Maybe I missed something when I ported from that source code ...

marco-kretz commented 8 years ago

I will try to do this with the --format=json as well!

ikappas commented 8 years ago

there is a bug with --format=json reported https://github.com/squizlabs/PHP_CodeSniffer/issues/969

ikappas commented 8 years ago

Let me push some changes on develop and work on those... How does that sound?

ikappas commented 8 years ago

@temkretz I just pushed some changes on develop. Can you please do your testing against that source code?

marco-kretz commented 8 years ago

@ikappas Alright, just checked it out ;)

marco-kretz commented 8 years ago

I don't think that phpcs is the problem, the process just doesn't get executed instantly.

ikappas commented 8 years ago

On develop I switched to child_process exec instead of spawn but this does not seem to affect the problem in any way

marco-kretz commented 8 years ago

Nope it doesn't :( For what reason ever the spawned process waits to be executed. I will try something.

ikappas commented 8 years ago

@temkretz I just pushed some changes to develop and I think I nailed it. Let me know if this works for you.

marco-kretz commented 8 years ago

@ikappas Work wonderful! Damn processes >.>

I think you can merge it into master :)

ikappas commented 8 years ago

@temkretz That is good to hear! Thank you for your assistance

marco-kretz commented 8 years ago

No problem 👍

marco-kretz commented 8 years ago

@ikappas merge? :P

ikappas commented 8 years ago

Fixing Windows issue and will merge ;)

ikappas commented 8 years ago

I just published phpcs 0.6.0 which should take care of this issue. Please let me know if this works!

marco-kretz commented 8 years ago

@ikappas works fantastic. thx!

ikappas commented 8 years ago

Good to hear, closing this issue.