bscan / PerlNavigator

Perl Language Server that includes syntax checking, perl critic, and code navigation
MIT License
206 stars 40 forks source link

Critic timeout #108

Open pjcj opened 10 months ago

pjcj commented 10 months ago

I have some large modules where critic times out and so no problems are reported. The timeout is currently set to 25 seconds. Would it be possible to make this configurable? This could be either per diagnostic or as a common value.

bscan commented 10 months ago

Sure, this is a good idea. The 25 seconds is fairly arbitrary. I didn't want Critic processes hanging around forever, especially if they've hung or are otherwise not needed. Some related thoughts below:

A config parameter would be straightforward. Alternatively, I could add a "large document mode" for files > N lines that would automatically increase this value. The other piece worth considering is the delay between making changes and kicking off diagnostics. When editing, the Navigator doesn't run critic (or perl -c) on every change event, it waits until the user hasn't typed for 1 second. If we're in "large document mode", it might be worth waiting an extra second or so since it's going to take a long time anyway. https://github.com/bscan/PerlNavigator/blob/fc14c477caeb9f1113ddc8f1da102177af5a8bcf/server/src/server.ts#L228

Related, the Navigator doesn't kill processes that are no longer needed. If you are editing a file (with typing gaps of at least 1 second), the Navigator will keep spinning off subprocesses to run perl -c and perlcritic. These can pile up a bit and starve other processes of resources, especially on machines/containers with fewer cores. The 1 second wait prevents too many from running simultaneously, but killing processes is another option.

pjcj commented 10 months ago

Thanks for thinking about this.

A "large document mode" is interesting and makes sense. Or perhaps values which are proportional to the size of the document? But in any case there still might be times the values need to be overridden somehow.

I currently have debounce_text_changes = 5000 in my neovim perlnavigator config which, I think, does something similar and won't run navigator more then once every five seconds. I'm happy to wait a little longer to get answers and use a little less power.

In the meantime I have increased the timeout locally and everything is working well.

pjcj commented 3 months ago

This is probably mostly for my benefit, but may help others who have hit the same problem. To change the timeout I run:

perl -pi.bak -e 's/\b25000\b/120000/' ~/.local/share/nvim/mason/packages/perlnavigator/node_modules/perlnavigator-server/{src,out}/{formatting,diagnostics}.?s

Change the path to match where the code is installed for you.