Skip to content
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

xref watcher should use thread pool with >1 parallelism level #4092

Closed
vladak opened this issue Nov 4, 2022 · 1 comment
Closed

xref watcher should use thread pool with >1 parallelism level #4092

vladak opened this issue Nov 4, 2022 · 1 comment

Comments

@vladak
Copy link
Member

vladak commented Nov 4, 2022

In my run within IDEA, I noticed this in one of the thread snapshots. There were 30 threads (running with --threads 32) parking at this spot:

"ForkJoinPool-1-worker-37" #22 daemon prio=5 os_prio=0 cpu=7362,01ms elapsed=223,51s tid=0x00007f7300285800 nid=0x3d33b waiting on condition  [0x00007f72eb2f6000]
   java.lang.Thread.State: WAITING (parking)
	at jdk.internal.misc.Unsafe.park(java.base@11.0.16/Native Method)
	- parking to wait for  <merged>(a java.util.concurrent.CompletableFuture$Signaller)
	at java.util.concurrent.locks.LockSupport.park(java.base@11.0.16/LockSupport.java:194)
	at java.util.concurrent.CompletableFuture$Signaller.block(java.base@11.0.16/CompletableFuture.java:1796)
	at java.util.concurrent.ForkJoinPool.managedBlock(java.base@11.0.16/ForkJoinPool.java:3118)
	at java.util.concurrent.CompletableFuture.waitingGet(java.base@11.0.16/CompletableFuture.java:1823)
	at java.util.concurrent.CompletableFuture.get(java.base@11.0.16/CompletableFuture.java:1998)
	at org.opengrok.indexer.analysis.plain.PlainAnalyzer.analyze(PlainAnalyzer.java:176)
	at org.opengrok.indexer.analysis.AnalyzerGuru.populateDocument(AnalyzerGuru.java:626)
	at org.opengrok.indexer.index.IndexDatabase.addFile(IndexDatabase.java:1068)
	at org.opengrok.indexer.index.IndexDatabase.lambda$indexParallel$4(IndexDatabase.java:1687)
	at org.opengrok.indexer.index.IndexDatabase$$Lambda$274/0x00007f72eb688968.apply(Unknown Source)
	at java.util.stream.Collectors.lambda$groupingByConcurrent$59(java.base@11.0.16/Collectors.java:1304)
	at java.util.stream.Collectors$$Lambda$276/0x00007f72eb2fed08.accept(java.base@11.0.16/Unknown 

which matches

CompletableFuture<XrefWork> future = CompletableFuture.supplyAsync(() -> {
try {
return new XrefWork(writeXref(args));
} catch (IOException e) {
return new XrefWork(e);
}
}, env.getIndexerParallelizer().getXrefWatcherExecutor()).
orTimeout(env.getXrefTimeout(), TimeUnit.SECONDS);

and interestingly the executor is instantiated like this:

private void createLazyXrefWatcherExecutor() {
lzXrefWatcherExecutor = LazilyInstantiate.using(() ->
new ScheduledThreadPoolExecutor(1,
new OpenGrokThreadFactory("xref-watcher")));
}

so it looks like there is just a single thread in the pool. Not completely sure if this is the problem, though.

Originally posted by @vladak in #4089 (reply in thread)

@vladak vladak self-assigned this Nov 4, 2022
vladak added a commit to vladak/OpenGrok that referenced this issue Nov 4, 2022
@vladak vladak added the bug label Nov 6, 2022
@vladak
Copy link
Member Author

vladak commented Nov 6, 2022

This bug was actually introduced by myself via e92cec6.

@vladak vladak closed this as completed in 4757cad Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant