Skip to content

TS: do more work in parallel #479

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

Merged
merged 3 commits into from
Nov 19, 2018

Conversation

asger-semmle
Copy link
Contributor

This PR speeds up TypeScript extraction by making the Java process and Node.js process do more work in parallel.

When the Node.js process has sent an AST, it immediately starts to work on the next AST while the Java process is processing the first one. In order for the Node.js process knows which file to work on next, a list of files to work on is sent in advance using the new prepare-files command.

In principle the Node.js process could prepare more than one file in advance, but then we risk being busy when the Java process is ready to receive the next file, delaying overall extraction. So it only looks one file ahead.

Extraction-time benchmarks:

Project Before After Difference
vscode
Basic 133s 114s 19s (14%)
Full 259s 211s 48s (19%)
TypeScript
Basic 48s 41s 7s (15%)
Full 466s 455s 11s (2%)
Angular
Basic 153s 138s 15s (10%)
Full 295s 235s 60s (20%)

The full-mode extraction for TypeScript itself is a bit of an outlier, but I'll look into that separately.

@asger-semmle asger-semmle requested a review from a team as a code owner November 15, 2018 16:47
@asger-semmle
Copy link
Contributor Author

@xiemaisi it will most likely conflict with the parallel extraction PR. I'm happy to withhold this until that lands, as long as it gets in before feature freeze.

@asger-semmle asger-semmle force-pushed the typescript-extractor-perf1 branch from a0021f3 to b5d3dd5 Compare November 16, 2018 10:39
Copy link

@xiemaisi xiemaisi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, otherwise LGTM. I really like the idea of this PR, and I don't think it needs to wait until the parallel extraction has landed (which is looking doubtful again anyway).

extractorState.getTypeScriptParser().prepareFiles(files);
for (File f : files) {
Path path = f.toPath();
if (extractedFiles.add(path)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we skip a file here (because it has already been extracted), won't the TypeScript parser throw an error on the next file we request an AST for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. It can't happen, but it's not very obvious at the moment.

The list of files given here has been built to only contain unextracted files, so the return value of add really doesn't need to be checked. I'll try to make this a bit more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, there was a huge bug in the last commit here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out the attempt to get AutoBuildTest working actually introduced a bug. The extracted file was added twice, and thereby skipped in the extraction step.

We'll obviously need some better testing for this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put up an internal PR that fixes the test that should catch this.

I've confirmed that the test fails for the previous commit, and passes after 84c1ba0.

@xiemaisi xiemaisi added the JS label Nov 19, 2018
@semmle-qlci semmle-qlci merged commit 328c86c into github:master Nov 19, 2018
cklin pushed a commit that referenced this pull request May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants