Skip to content

Commit dedefe0

Browse files
authored
Merge pull request #1039 from xiemaisi/js/parallel-extraction-env-vars
Approved by asger-semmle
2 parents 9d595aa + b1033b0 commit dedefe0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

change-notes/1.20/extractor-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
## Changes to code extraction
2020

21-
* 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.
21+
* 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.
2222
* 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.
2323
* The extractor now supports additional [Flow](https://flow.org/) syntax.
2424
* The extractor now supports [Nullish Coalescing](https://github.com/tc39/proposal-nullish-coalescing) expressions.

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
* <li><code>LGTM_INDEX_TYPESCRIPT</code>: whether to extract TypeScript
7070
* <li><code>LGTM_INDEX_FILETYPES</code>: a newline-separated list of ".extension:filetype" pairs
7171
* specifying which {@link FileType} to use for the given extension
72-
* <li><code>LGTM_INDEX_THREADS</code>: the maximum number of files to extract in parallel
72+
* <li><code>LGTM_THREADS</code>: the maximum number of files to extract in parallel
7373
* <li><code>LGTM_TRAP_CACHE</code>: the path of a directory to use for trap caching
7474
* <li><code>LGTM_TRAP_CACHE_BOUND</code>: the size to bound the trap cache to
7575
* </ul>
@@ -163,9 +163,9 @@
163163
* following environment variables are available:
164164
*
165165
* <ul>
166-
* <li><code>LGTM_INDEX_THREADS</code> determines how many threads are used for parallel
166+
* <li><code>LGTM_THREADS</code> determines how many threads are used for parallel
167167
* extraction of JavaScript files (TypeScript files cannot currently be extracted in
168-
* parallel). If left unspecified, the extractor uses as many threads as there are cores.
168+
* parallel). If left unspecified, the extractor uses a single thread.
169169
* <li><code>LGTM_TRAP_CACHE</code> and <code>LGTM_TRAP_CACHE_BOUND</code> can be used to specify
170170
* the location and size of a trap cache to be used during extraction.
171171
* </ul>
@@ -405,8 +405,8 @@ public void run() throws IOException {
405405
}
406406

407407
private void startThreadPool() {
408-
int defaultNumThreads = Runtime.getRuntime().availableProcessors();
409-
int numThreads = Env.systemEnv().getInt("LGTM_INDEX_THREADS", defaultNumThreads);
408+
int defaultNumThreads = 1;
409+
int numThreads = Env.systemEnv().getInt("LGTM_THREADS", defaultNumThreads);
410410
if (numThreads > 1) {
411411
System.out.println("Parallel extraction with " + numThreads + " threads.");
412412
threadPool = Executors.newFixedThreadPool(numThreads);

0 commit comments

Comments
 (0)