-
Notifications
You must be signed in to change notification settings - Fork 889
Run linting logic in spawned threads #2328
Comments
Some random thoughts: async processing:
multiple threads:
result cache:
|
Glad the reaction has been favorable so far. :) I'll start work on some of the low hanging fruit. Re the downsides of multiple threads: agreed, and this should definitely not be used for "normal" (most) projects. The scenario I'm approaching this for is overpowered 16-core monstrosities (dev machines, build lab machines, obscene Azure VMs, and the like) made to deal with huge code bases. They're fantastic at MSBuild/gcc/etc. but amusingly running TSLint tasks slows them down something terrible. The argument could (and should) be made that projects big enough to slow down TSLint should be split up into sub-projects, and those sub-projects' TSLint tasks should be parallelized... but that's not always possible. |
maybe merge-able with #943 |
parallel linting is not supported so far, my workaround is find src -name '*.ts' | parallel node_modules/.bin/tslint -p . --fix sometimes also use git status to skip some files. |
Hi there, I have one suggestion for this: what if we'll move all rules, which doesn't require a type checking into separate processes and split all files between them, but all rules, which require a type checking we'll leave in the main thread (to avoid compilation of the project multiple times)? 🤔 I just played with that and have some results.
I've created 3 separate processes ( In my runs each process works ~70-85 seconds, the main thread lints all files ~70 seconds. Time to create To summarize the results:
So, the parallel version is ~40% faster in my case. What do you think about that? For me (I'm not familiar with tslint's code a lot) there is still some open questions:
|
This looks like a great start @timocov! Super exciting that you got this to work 👏
Why not? Can you elaborate? https://nodejs.org/api/child_process.html#child_process_options_stdio implies there are some built-in options there. Applying fixes is done by a formatter AFAICS. For both 2/fixes and 3/sorting, from my perspective it should be possible to run something like:
Thoughts? |
I meant that we can't just send the whole instance of some class from one process to another process without implementing (de)serialization code. Or we can? If so, I can't realize how nodejs does it 🙂 If you wish I can prepare the code (actually you already can see rough solution here, but I need to make it more readable and remove duplications) of the first implementation and we can discuss on it. |
Awesome, that's exactly what we'd need. +1 to preparing the code! |
@JoshuaKGoldberg @adidahiya I just created #4483 with a little bit prepared code of parallel running the linter. As I said before - I'm not familiar with tslint's code base a lot and can made an epic fails in the PR - keep this in mind 🙂. |
☠️ TSLint's time has come! ☠️ TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. ✨ It was a pleasure open sourcing with you all! |
Followup to #389 & #1131. I'm taking a look at this for work because we have a few thousand files to lint. Running them in serial takes a long time. Our options are:
Within option 2 I see there being two possibilities:
Runner
andLinter
to be asynchronousLinter
in particular would be a breaking API changeProcessSplitter
class betweentslint-cli.ts
andRunner
--parallel
is provided and > 1--parallel
1/<--parallel>
of those filesThoughts?
The text was updated successfully, but these errors were encountered: