From b1033b079f23a690580483477c41505c2da3c16c Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 5 Mar 2019 10:06:32 +0000 Subject: [PATCH] JavaScript: Make configuration of parallel extraction consistent with parallel evaluation. Just like parallel evaluation, the number of extractor threads is now determined by the `LGTM_THREADS` environment variable, and defaults to one. --- change-notes/1.20/extractor-javascript.md | 2 +- .../src/com/semmle/js/extractor/AutoBuild.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/change-notes/1.20/extractor-javascript.md b/change-notes/1.20/extractor-javascript.md index 5027573f30b3..b233e167faf7 100644 --- a/change-notes/1.20/extractor-javascript.md +++ b/change-notes/1.20/extractor-javascript.md @@ -18,7 +18,7 @@ ## Changes to code extraction -* Extraction of JavaScript files (but not TypeScript files) on LGTM is now parallelized. By default, the extractor uses as many threads as there are processors, but this can be overridden by setting the `LGTM_INDEX_THREADS` environment variable. In particular, setting `LGTM_INDEX_THREADS` to 1 disables parallel extraction. +* Parallel extraction of JavaScript files (but not TypeScript files) on LGTM is now supported. The `LGTM_THREADS` environment variable can be set to indicate how many files should be extracted in parallel. If this variable is not set, parallel extraction is disabled. * The extractor now offers experimental support for [E4X](https://developer.mozilla.org/en-US/docs/Archive/Web/E4X), a legacy language extension developed by Mozilla. * The extractor now supports additional [Flow](https://flow.org/) syntax. * The extractor now supports [Nullish Coalescing](https://github.com/tc39/proposal-nullish-coalescing) expressions. diff --git a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java index 5d0b10361f9f..db865c97e0ca 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java +++ b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java @@ -69,7 +69,7 @@ *
  • LGTM_INDEX_TYPESCRIPT: whether to extract TypeScript *
  • LGTM_INDEX_FILETYPES: a newline-separated list of ".extension:filetype" pairs * specifying which {@link FileType} to use for the given extension - *
  • LGTM_INDEX_THREADS: the maximum number of files to extract in parallel + *
  • LGTM_THREADS: the maximum number of files to extract in parallel *
  • LGTM_TRAP_CACHE: the path of a directory to use for trap caching *
  • LGTM_TRAP_CACHE_BOUND: the size to bound the trap cache to * @@ -163,9 +163,9 @@ * following environment variables are available: * * @@ -405,8 +405,8 @@ public void run() throws IOException { } private void startThreadPool() { - int defaultNumThreads = Runtime.getRuntime().availableProcessors(); - int numThreads = Env.systemEnv().getInt("LGTM_INDEX_THREADS", defaultNumThreads); + int defaultNumThreads = 1; + int numThreads = Env.systemEnv().getInt("LGTM_THREADS", defaultNumThreads); if (numThreads > 1) { System.out.println("Parallel extraction with " + numThreads + " threads."); threadPool = Executors.newFixedThreadPool(numThreads);